From b1d17ea31c7afb8e1f39738e31a2eb820bb9ba24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kobierzy=C5=84ski?= Date: Tue, 7 Dec 2021 08:02:50 +0100 Subject: [PATCH 1/3] [IHB-718] int cast --- Model/Dibs/Items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Dibs/Items.php b/Model/Dibs/Items.php index 572604c9..3970f6ae 100644 --- a/Model/Dibs/Items.php +++ b/Model/Dibs/Items.php @@ -252,8 +252,8 @@ public function addItems($items) ->setName($itemName) ->setUnit("st") ->setQuantity(round($qty, 0)) - ->setTaxRate($vat) - ->setTaxAmount($this->getTotalTaxAmount($unitPrice * $qty, $vat, false)) // total tax amount + ->setTaxRate((int) $vat) + ->setTaxAmount((int) $this->getTotalTaxAmount($unitPrice * $qty, $vat, false)) // total tax amount ->setUnitPrice((int) $unitPriceExclTax) // excl. tax price per item ->setNetTotalAmount((int) ($unitPriceExclTax * $qty)) // excl. tax ->setGrossTotalAmount((int) ($unitPrice * $qty)); // incl. tax From 2306f8ba618e19ecc38bbff75f6d7fff215ead01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kobierzy=C5=84ski?= Date: Tue, 30 Nov 2021 13:01:14 +0100 Subject: [PATCH 2/3] [IHB-963] invalid body error - gross total amount wrong calculations fix --- Model/Dibs/Items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Dibs/Items.php b/Model/Dibs/Items.php index 3b01971a..e0eaa2e6 100644 --- a/Model/Dibs/Items.php +++ b/Model/Dibs/Items.php @@ -262,7 +262,7 @@ public function addItems($items) ->setTaxAmount((int) $this->getTotalTaxAmount($unitPrice * $qty, $vat, false)) // total tax amount ->setUnitPrice((int) $unitPriceExclTax) // excl. tax price per item ->setNetTotalAmount((int) ($unitPriceExclTax * $qty)) // excl. tax - ->setGrossTotalAmount((int) ($unitPrice * $qty)); // incl. tax + ->setGrossTotalAmount((int) ($this->addZeroes($item->getRowTotalInclTax()))); // incl. tax // add to array $this->_cart[$sku] = $orderItem; From d3dc01fcd04abee07062a4e4c445b4edd6858cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kobierzy=C5=84ski?= Date: Tue, 7 Dec 2021 08:24:11 +0100 Subject: [PATCH 3/3] [IHB-963] amounts casted to int --- Model/Dibs/Items.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Model/Dibs/Items.php b/Model/Dibs/Items.php index e0eaa2e6..19717611 100644 --- a/Model/Dibs/Items.php +++ b/Model/Dibs/Items.php @@ -335,7 +335,7 @@ public function addShipping($address) ->setName((string)__('Shipping Fee (%1)', $address->getShippingDescription())) ->setUnit("st") // TODO! We need to map these somehow! ->setQuantity(1) - ->setTaxRate($vat) + ->setTaxRate((int) $vat) ->setTaxAmount($this->addZeroes($taxAmount)) // total tax amount ->setUnitPrice($this->addZeroes($exclTax)) // excl. tax price per item ->setNetTotalAmount($this->addZeroes($exclTax)) // excl. tax @@ -434,13 +434,13 @@ public function generateInvoiceFeeItem($invoiceLabel, $invoiceFee, $vatIncluded) $feeItem ->setName($invoiceLabel) ->setReference(strtolower(str_replace(" ", "_", $invoiceLabel))) - ->setTaxRate($taxRate) + ->setTaxRate((int) $taxRate) ->setGrossTotalAmount($this->addZeroes($invoiceFeeInclTax)) // incl tax ->setNetTotalAmount($this->addZeroes($invoiceFeeExclTax)) // // excl. tax ->setUnit("st") ->setQuantity(1) ->setUnitPrice($this->addZeroes($invoiceFeeExclTax)) // // excl. tax - ->setTaxAmount($taxAmount); // tax amount + ->setTaxAmount((int) $taxAmount); // tax amount return $feeItem; } @@ -472,8 +472,8 @@ public function addDiscounts($couponCode) ->setName($couponCode ? (string)__('Discount (%1)', $couponCode) : (string)__('Discount')) ->setUnit("st") ->setQuantity(1) - ->setTaxRate($vat) - ->setTaxAmount($taxAmount) // total tax amount + ->setTaxRate((int) $vat) + ->setTaxAmount((int) $taxAmount) // total tax amount ->setUnitPrice(0) // excl. tax price per item ->setNetTotalAmount(-$amountExclTax) // excl. tax ->setGrossTotalAmount(-$amountInclTax); // incl. tax