Skip to content
Snippets Groups Projects
Commit df7eb002 authored by Jakub Piasecki's avatar Jakub Piasecki
Browse files

Issue #3478359 by zaporylie, borgenk: Tax on the order items is set incorrectly

parent 2aa704cb
No related branches found
No related tags found
1 merge request!5Issue #3478359 by zaporylie, borgenk: Tax on the order items is set incorrectly
Pipeline #299283 passed with warnings
......@@ -154,17 +154,20 @@ class CheckoutLandingPageRedirectForm extends BasePaymentOffsiteForm implements
$order_line->setId($item->getPurchasedEntityId());
$order_line->setProductUrl($item->getPurchasedEntity()->toUrl('canonical')->setAbsolute()->toString());
$order_line->setTotalAmount($this->minorUnitsConverter->toMinorUnits($item->getTotalPrice()));
$order_line->setTotalAmountExcludingTax($this->minorUnitsConverter->toMinorUnits($item->getAdjustedTotalPrice(['promotion'])));
// The fallback value when no tax adjustment is found.
$order_line->setTotalTaxAmount(0);
$order_line->setTaxRate(0);
// Only pass included tax adjustments (i.e "VAT"), non included tax
$order_line->setTotalAmountExcludingTax($this->minorUnitsConverter->toMinorUnits($item->getTotalPrice()));
// Only pass included tax adjustments (i.e "VAT"), non-included tax
// adjustments are passed separately (i.e "Sales tax").
$tax_adjustments = $item->getAdjustments(['tax']);
if ($tax_adjustments && $tax_adjustments[0]->isIncluded()) {
$tax_rate = $tax_adjustments[0]->getPercentage();
$order_line->setTaxRate((int) Calculator::multiply($tax_rate, '10000'));
$order_line->setTotalTaxAmount($this->minorUnitsConverter->toMinorUnits($tax_adjustments[0]->getAmount()));
$order_line->setTotalAmountExcludingTax($this->minorUnitsConverter->toMinorUnits($item->getTotalPrice()->subtract($tax_adjustments[0]->getAmount())));
}
$order_line->setUnitInfo((new UnitInfo())->setQuantity($item->getQuantity()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment