|
|
|
|
|
|
|
|
$totalVat = 0; |
|
|
$totalVat = 0; |
|
|
$ordersArray = $this->orders; |
|
|
$ordersArray = $this->orders; |
|
|
|
|
|
|
|
|
foreach ($ordersArray as $order) { |
|
|
|
|
|
|
|
|
// Méthode de calcul via les commandes liées |
|
|
|
|
|
/*foreach ($ordersArray as $order) { |
|
|
$order->init($this->tax_calculation_method); |
|
|
$order->init($this->tax_calculation_method); |
|
|
$amount += $order->getAmount($type); |
|
|
$amount += $order->getAmount($type); |
|
|
$totalVat += $order->getTotalVat($type); |
|
|
$totalVat += $order->getTotalVat($type); |
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
// Méthode de calcul via getProductOrders() |
|
|
|
|
|
foreach($this->getProductsOrders() as $productOrderArray) { |
|
|
|
|
|
foreach($productOrderArray as $productOrder) { |
|
|
|
|
|
$priceLine = $productOrder->getPriceByTypeTotal($type) * $productOrder->quantity; |
|
|
|
|
|
$amount += $priceLine; |
|
|
|
|
|
$totalVat += Price::getVat($priceLine, $productOrder->taxRate->value, $this->tax_calculation_method); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($this->isTaxCalculationMethodRoundingOfTheSum()) { |
|
|
if ($this->isTaxCalculationMethodRoundingOfTheSum()) { |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
$totalVatArray = []; |
|
|
$totalVatArray = []; |
|
|
|
|
|
|
|
|
$ordersArray = $this->orders; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Méthode de calcul via les commandes liées |
|
|
|
|
|
/*$ordersArray = $this->orders; |
|
|
foreach ($ordersArray as $order) { |
|
|
foreach ($ordersArray as $order) { |
|
|
$order->init($this->tax_calculation_method); |
|
|
$order->init($this->tax_calculation_method); |
|
|
$fieldNameVat = $order->getFieldNameAmount($typeTotal, 'vat'); |
|
|
$fieldNameVat = $order->getFieldNameAmount($typeTotal, 'vat'); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
$totalVatArray[$idTaxRate] += $vat; |
|
|
$totalVatArray[$idTaxRate] += $vat; |
|
|
} |
|
|
} |
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
// Méthode de calcul via getProductOrders() |
|
|
|
|
|
foreach($this->getProductsOrders() as $productOrderArray) { |
|
|
|
|
|
foreach ($productOrderArray as $productOrder) { |
|
|
|
|
|
|
|
|
|
|
|
$idTaxRate = $productOrder->taxRate->id; |
|
|
|
|
|
if (!isset($totalVatArray[$idTaxRate])) { |
|
|
|
|
|
$totalVatArray[$idTaxRate] = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$totalVatArray[$idTaxRate] += Price::getVat( |
|
|
|
|
|
$productOrder->getPriceByTypeTotal($typeTotal) * $productOrder->quantity, |
|
|
|
|
|
$productOrder->taxRate->value, |
|
|
|
|
|
$this->tax_calculation_method |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $totalVatArray; |
|
|
return $totalVatArray; |