Skip to content

Commit

Permalink
Merge pull request #155 from vippsas/2.4.40-p1
Browse files Browse the repository at this point in the history
VIPPS-420: Receipt requests: Incorrect totals for rows and 400 errors…
  • Loading branch information
voleye authored Nov 25, 2022
2 parents 8ef8320 + 47976fb commit eddfffc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions Gateway/Request/SendReceipt/OrderLinesBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ public function build(array $buildSubject)
$totalAmount = $item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount();
$totalAmountExcludingTax = $totalAmount - $item->getTaxAmount();

$monitaryTotalAmount = (int)($totalAmount * 100);
$monitaryTotalAmountExcludingTax = (int)($totalAmountExcludingTax * 100);
$monitaryTaxAmount = $monitaryTotalAmount - $monitaryTotalAmountExcludingTax;

$orderLines[] = [
'name' => $item->getName(),
'id' => $item->getSku(),
'totalAmount' => (int)($totalAmount * 100),
'totalAmountExcludingTax' => (int)($totalAmountExcludingTax * 100),
'totalTaxAmount' => (int)($item->getTaxAmount() * 100),
'taxPercentage' => $totalAmount > 0
? (int)round($item->getTaxAmount() * 100 / $totalAmount)
'totalAmount' => $monitaryTotalAmount,
'totalAmountExcludingTax' => $monitaryTotalAmountExcludingTax,
'totalTaxAmount' => $monitaryTaxAmount,
'taxPercentage' => $monitaryTotalAmountExcludingTax > 0
? (int)round($monitaryTaxAmount * 100 / $monitaryTotalAmountExcludingTax)
: $item->getTaxPercent(),
'unitInfo' => [
'unitPrice' => (int)($item->getPrice() * 100),
Expand All @@ -91,14 +95,18 @@ public function build(array $buildSubject)
];
}

$monitaryShippingTotalAmount = (int)($order->getShippingInclTax() * 100);
$monitaryShippingTotalAmountExcludingTax = (int)($order->getShippingAmount() * 100);
$monitaryShippingTaxAmount = $monitaryShippingTotalAmount - $monitaryShippingTotalAmountExcludingTax;

$orderLines[] = [
'name' => $order->getShippingDescription(),
'id' => 'shipping',
'totalAmount' => (int)($order->getShippingInclTax() * 100),
'totalAmountExcludingTax' => (int)($order->getShippingAmount() * 100),
'totalTaxAmount' => (int)($order->getShippingTaxAmount() * 100),
'taxPercentage' => $order->getShippingInclTax() > 0
? (int)round($order->getShippingTaxAmount() * 100 / $order->getShippingInclTax())
'taxPercentage' => $monitaryShippingTotalAmountExcludingTax > 0
? (int)round($monitaryShippingTaxAmount * 100 / $monitaryShippingTotalAmountExcludingTax)
: 0,
'discount' => (int)($order->getShippingDiscountAmount() * 100),
'isReturn' => false,
Expand Down
2 changes: 1 addition & 1 deletion Model/Profiling/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function packArray($data)
{
$recursive = function ($data, $indent = '') use (&$recursive) {
$output = '{' . PHP_EOL;
foreach ($data as $key => $value) {
foreach ((array)$data as $key => $value) {
if (is_array($value)) {
$output .= $indent . ' ' . $key . ': ' . $recursive($value, $indent . ' ') . PHP_EOL;
} elseif (!is_object($value)) {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
~ IN THE SOFTWARE.
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vipps_Payment" setup_version="2.4.39">
<module name="Vipps_Payment" setup_version="2.4.40">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit eddfffc

Please sign in to comment.