Browse Source

Merge branch 'dev'

prodstable
Guillaume Bourgeois 2 years ago
parent
commit
0d1605c239
2 changed files with 6 additions and 6 deletions
  1. +3
    -3
      common/helpers/Price.php
  2. +3
    -3
      common/models/Order.php

+ 3
- 3
common/helpers/Price.php View File

return $priceWithoutTax + $vat; return $priceWithoutTax + $vat;
} }


public static function getVat($priceTotalWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT)
public static function getVat($priceWithoutTax, $taxRate, $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT)
{ {
$vat = $priceTotalWithoutTax * $taxRate;
$vat = $priceWithoutTax * $taxRate;


if($taxCalculationMethod == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) { if($taxCalculationMethod == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS) {
$vat = self::round($vat); $vat = self::round($vat);
return number_format(( ($number * 100)) / 100, 2) ; return number_format(( ($number * 100)) / 100, 2) ;
} }


}
}

+ 3
- 3
common/models/Order.php View File

$productOrder->taxRate->value, $productOrder->taxRate->value,
$taxCalculationMethod $taxCalculationMethod
) * $productOrder->quantity; ) * $productOrder->quantity;
$this->addVat($typeTotal, $price * $productOrder->quantity, $productOrder->taxRate, $taxCalculationMethod);
$this->addVat($typeTotal, $price, $productOrder->quantity, $productOrder->taxRate, $taxCalculationMethod);
} }


public function addVat($typeTotal, $priceTotalWithoutTax, $taxRate, $taxCalculationMethod)
public function addVat($typeTotal, $priceWithoutTax, $quantity, $taxRate, $taxCalculationMethod)
{ {
$fieldName = $this->getFieldNameAmount($typeTotal, 'vat'); $fieldName = $this->getFieldNameAmount($typeTotal, 'vat');


$this->$fieldName[$taxRate->id] = 0; $this->$fieldName[$taxRate->id] = 0;
} }


$this->$fieldName[$taxRate->id] += Price::getVat($priceTotalWithoutTax, $taxRate->value, $taxCalculationMethod);
$this->$fieldName[$taxRate->id] += Price::getVat($priceWithoutTax, $taxRate->value, $taxCalculationMethod) * $quantity;
} }


public function getTotalVat($typeTotal = self::AMOUNT_TOTAL) public function getTotalVat($typeTotal = self::AMOUNT_TOTAL)

Loading…
Cancel
Save