/** * Split tax amount amongst collection products * * @param IsotopeProductCollection $objCollection * @param \Model $objSource */ public function applySplittedTax(IsotopeProductCollection $objCollection, $objSource) { $this->tax_class = 0; $this->before_tax = true; $fltTotal = 0; if (!$objSource->isPercentage()) { $fltTotal = $objCollection->getTaxFreeSubtotal(); if ($fltTotal == 0) { return; } } foreach ($objCollection->getItems() as $objItem) { if ($objSource->isPercentage()) { $fltProductPrice = $objItem->getTotalPrice() / 100 * $objSource->getPercentage(); } else { $fltProductPrice = $this->total_price / 100 * (100 / $fltTotal * $objItem->getTaxFreeTotalPrice()); } $fltProductPrice = $fltProductPrice > 0 ? floor($fltProductPrice * 100) / 100 : ceil($fltProductPrice * 100) / 100; $this->setAmountForCollectionItem($fltProductPrice, $objItem); } }