foreach ($rules as $rule) { $taxes[] =
$this->
calculateTaxFromGrossPrice($price,
$rule);
} return new CalculatedTaxCollection($taxes);
} public function calculateNetTaxes(float
$price, TaxRuleCollection
$rules): CalculatedTaxCollection
{ $taxes =
[];
foreach ($rules as $rule) { $taxes[] =
$this->
calculateTaxFromNetPrice($price,
$rule);
} return new CalculatedTaxCollection($taxes);
} public function calculateTaxFromNetPrice(float
$net, TaxRule
$rule): CalculatedTax
{ // calculate percentage value of net price
$net =
$net / 100 *
$rule->
getPercentage();
$calculatedTax =
$net *
($rule->
getTaxRate() / 100
);