Browse Source

Processus de commande

feature/export_comptable
Fab 4 years ago
parent
commit
ef150e281b
2 changed files with 42 additions and 11 deletions
  1. +5
    -0
      ShopBundle/Services/Price/OrderProductPriceUtils.php
  2. +37
    -11
      ShopBundle/Services/Price/OrderShopPriceUtils.php

+ 5
- 0
ShopBundle/Services/Price/OrderProductPriceUtils.php View File

$this->getTotalWithTax($orderProduct) $this->getTotalWithTax($orderProduct)
); );
} }

//inclus toujours les réductions catalogues
public function getTotalTaxes(OrderProductInterface $orderProduct){
return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct);
}
} }



+ 37
- 11
ShopBundle/Services/Price/OrderShopPriceUtils.php View File

$this->orderProductPriceUtils = $orderProductPriceUtils ; $this->orderProductPriceUtils = $orderProductPriceUtils ;
} }


public function getTotal(OrderShopInterface $orderShop)
//Inclus les ReductionCatalog des OrderProducts
public function getTotalOrderProducts(OrderShopInterface $orderShop):float
{ {
// A tester calculer ce montant en faisant TotalOrderWithTax - TotalOrderTaxes


$total = 0;
foreach ($orderShop->getOrderProducts() as $orderProduct) {
$total += $this->orderProductPriceUtils->getTotalWithReduction($orderProduct);
}
return $total;
} }


public function getTotalWithReductionCatalog(OrderShopInterface $orderShop)
public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop):float
{ {
$total = 0;
foreach ($orderShop->getOrderProducts() as $orderProduct) {
$total += $this->orderProductPriceUtils->getTotalWithTaxAndReduction($orderProduct);
}
return $total;


} }


public function getTotalWithReductionCart(OrderShopInterface $orderShop)
{


public function getTotalOrderProductsTaxes(OrderShopInterface $orderShop):float {
} }


public function getTotalWithReductions(OrderShopInterface $orderShop)
public function getOrderProductsTaxesAsArray(OrderShopInterface $orderShop):array
{ {
$orderProductsTaxes = [];
foreach ($orderShop->getOrderProducts() as $orderProduct) {


}
$idTaxRate = $orderProduct->getTaxRate()->getId() ;


public function getTotalWithTax(OrderShopInterface $orderShop)
{
if(!isset($orderProductsTaxes[$idTaxRate])) {
$orderProductsTaxes[$idTaxRate] = [
'label' => $orderProduct->getTaxRate()->getValue() . '%',
'totalOrderProducts' => 0,
'totalTaxes' => 0,
];
}

$orderProductsTaxes[$idTaxRate]['totalOrderProducts'] += $this->orderProductPriceUtils->getTotalWithReduction($orderProduct) * $this->getReductionsCoef($orderShop);
$orderProductsTaxes[$idTaxRate]['totalTaxes'] += $this->orderProductPriceUtils->getTotalTaxes($orderProduct) * $this->getReductionsCoef($orderShop) ;
}


return $orderProductsTaxes ;
} }


public function getTotalWithTaxAndReductionCatalog(OrderShopInterface $orderShop)
private function getReductionsCoef(OrderShopInterface $orderShop) :float
{ {

return $this->getTotalOrderProducts($orderShop) / $this->getTotalOrderProductsWithReductions($orderShop);
} }


public function getTotalWithTaxAndReductionCart(OrderShopInterface $orderShop)


public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop)
{ {


} }



public function getTotalWithTaxAndReductions(OrderShopInterface $orderShop) public function getTotalWithTaxAndReductions(OrderShopInterface $orderShop)
{ {



Loading…
Cancel
Save