Skip to content

Commit

Permalink
fix: nullable order tax status (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyl3x authored Feb 17, 2025
1 parent 871e3c9 commit 92ef1ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/OrdersApi/Builder/AbstractOrderBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ protected function createPurchaseUnitFromOrder(
$currency = $order->getCurrency();
\assert($currency !== null);
$items = $this->submitCart($order->getSalesChannelId()) ? $this->itemListProvider->getItemList($currency, $order) : null;
$taxStatus = $order->getTaxStatus() ?? $order->getPrice()->getTaxStatus();

return $this->purchaseUnitProvider->createPurchaseUnit(
$orderTransaction->getAmount(),
Expand All @@ -116,7 +117,7 @@ protected function createPurchaseUnitFromOrder(
$items,
$currency,
$context,
$order->getTaxStatus() !== CartPrice::TAX_STATE_GROSS,
$taxStatus !== CartPrice::TAX_STATE_GROSS,
$order,
$orderTransaction
);
Expand Down
4 changes: 3 additions & 1 deletion src/OrdersApi/Builder/Util/ItemListProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ public function __construct(

public function getItemList(CurrencyEntity $currency, OrderEntity $order): ItemCollection
{
$taxStatus = $order->getTaxStatus() ?? $order->getPrice()->getTaxStatus();

$items = new ItemCollection();
$currencyCode = $currency->getIsoCode();
$isNet = $order->getTaxStatus() !== CartPrice::TAX_STATE_GROSS;
$isNet = $taxStatus !== CartPrice::TAX_STATE_GROSS;
$lineItems = $order->getNestedLineItems();
if ($lineItems === null) {
return new ItemCollection();
Expand Down
4 changes: 3 additions & 1 deletion src/OrdersApi/Patch/PurchaseUnitPatchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ public function createFinalPurchaseUnitPatch(
$itemList = null;
}

$taxStatus = $order->getTaxStatus() ?? $order->getPrice()->getTaxStatus();

$purchaseUnit = $this->purchaseUnitProvider->createPurchaseUnit(
$orderTransaction->getAmount(),
$order->getShippingCosts(),
$customer,
$itemList,
$currency,
$context,
$order->getTaxStatus() !== CartPrice::TAX_STATE_GROSS,
$taxStatus !== CartPrice::TAX_STATE_GROSS,
$order,
$orderTransaction
);
Expand Down

0 comments on commit 92ef1ef

Please sign in to comment.