itemCalculator = $itemCalculator; $this->appliedTaxesDeterminer = $appliedTaxesDeterminer; } /** * {@inheritdoc} * * Protected method is part of override, $round required as part of override */ protected function calculateWithTaxNotInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true) { $itemTaxes = $this->itemCalculator->getVertexItemTaxes(); /** @var DataObject $itemTax */ $itemTax = $itemTaxes !== null ? $this->itemCalculator->calculateItemTax($item, $itemTaxes, $round) : $this->itemCalculator->getEmptyItemTax(); $percent = $itemTax->hasTaxPercent() ? $itemTax->getTaxPercent() : 0; $rowTax = $itemTax->hasTaxAmount() ? $itemTax->getTaxAmount() : 0; // Determine whether or not to round the price $basePrice = $round ? $this->calculationTool->round($item->getUnitPrice()) : $item->getUnitPrice(); $perItemTax = $rowTax / $quantity; $basePriceInclTax = $basePrice + ($round ? $this->calculationTool->round($perItemTax) : $perItemTax); $appliedTaxes = $this->appliedTaxesDeterminer->prepareAppliedTaxes($item, $itemTax); $rowTotal = $basePrice * $quantity; return $this->taxDetailsItemDataObjectFactory->create() ->setCode($item->getCode()) ->setType($item->getType()) ->setRowTax($rowTax) ->setPrice($basePrice) ->setPriceInclTax($basePriceInclTax) ->setRowTotal($rowTotal) ->setRowTotalInclTax($rowTotal + $rowTax) ->setDiscountTaxCompensationAmount(0) ->setAssociatedItemCode($item->getAssociatedItemCode()) ->setTaxPercent($percent) ->setAppliedTaxes($appliedTaxes); } }