|
|
@@ -135,10 +135,20 @@ class Document extends ActiveRecordCommon |
|
|
|
$totalVat = 0; |
|
|
|
$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); |
|
|
|
$amount += $order->getAmount($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()) { |
|
|
@@ -160,8 +170,8 @@ class Document extends ActiveRecordCommon |
|
|
|
{ |
|
|
|
$totalVatArray = []; |
|
|
|
|
|
|
|
$ordersArray = $this->orders; |
|
|
|
|
|
|
|
// Méthode de calcul via les commandes liées |
|
|
|
/*$ordersArray = $this->orders; |
|
|
|
foreach ($ordersArray as $order) { |
|
|
|
$order->init($this->tax_calculation_method); |
|
|
|
$fieldNameVat = $order->getFieldNameAmount($typeTotal, 'vat'); |
|
|
@@ -171,6 +181,23 @@ class Document extends ActiveRecordCommon |
|
|
|
} |
|
|
|
$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; |