Skip to content

Commit

Permalink
fix: nullable order tax status
Browse files Browse the repository at this point in the history
  • Loading branch information
cyl3x committed Feb 7, 2025
1 parent 57f18ac commit 1e62e31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/OrdersApi/Builder/AbstractOrderBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ protected function createPurchaseUnitFromOrder(
): PurchaseUnit {
$items = $this->submitCart($salesChannelContext) ? $this->itemListProvider->getItemList($salesChannelContext->getCurrency(), $order) : null;

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

return $this->purchaseUnitProvider->createPurchaseUnit(
$orderTransaction->getAmount(),
$order->getShippingCosts(),
null,
$items,
$salesChannelContext,
$order->getTaxStatus() !== CartPrice::TAX_STATE_GROSS, /* @phpstan-ignore-line */
$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; /* @phpstan-ignore-line */
$isNet = $taxStatus !== CartPrice::TAX_STATE_GROSS; /* @phpstan-ignore-line */
$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 @@ -52,13 +52,15 @@ public function createFinalPurchaseUnitPatch(
$itemList = null;
}

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

$purchaseUnit = $this->purchaseUnitProvider->createPurchaseUnit(
$orderTransaction->getAmount(),
$order->getShippingCosts(),
$customer,
$itemList,
$salesChannelContext,
$order->getTaxStatus() !== CartPrice::TAX_STATE_GROSS, /* @phpstan-ignore-line */
$taxStatus !== CartPrice::TAX_STATE_GROSS,
$order,
$orderTransaction
);
Expand Down

0 comments on commit 1e62e31

Please sign in to comment.