Skip to content

Commit

Permalink
added Vat to frontend API for product, transport and payment
Browse files Browse the repository at this point in the history
- also updated Convertim implementation
  • Loading branch information
TomasLudvik committed Nov 14, 2024
1 parent b5fd223 commit 093595e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Model/Order/ConvertimOrderDataToOrderDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade;
use Shopsys\FrameworkBundle\Model\Pricing\Price;
use Shopsys\FrameworkBundle\Model\Product\Exception\ProductNotFoundException;
use Shopsys\FrameworkBundle\Model\Product\Product;
use Shopsys\FrameworkBundle\Model\Store\Exception\StoreByUuidNotFoundException;
use Shopsys\FrameworkBundle\Model\Store\StoreFacade;
use Shopsys\FrameworkBundle\Model\Transport\TransportFacade;
Expand Down Expand Up @@ -184,7 +183,7 @@ protected function mapConvertimPaymentDataToOrderItem(
$paymentOrderItemData->totalPriceWithoutVat = Money::create($convertimOrderPaymentData->getPriceWithoutVat());
$paymentOrderItemData->unitPriceWithVat = Money::create($convertimOrderPaymentData->getPriceWithVat());
$paymentOrderItemData->unitPriceWithoutVat = Money::create($convertimOrderPaymentData->getPriceWithoutVat());
$paymentOrderItemData->vatPercent = $payment->getVatForDomain($this->domain->getId())->getPercent();
$paymentOrderItemData->vatPercent = (string)($convertimOrderPaymentData->getVatRate() ?? 0);
$paymentOrderItemData->usePriceCalculation = false;

$orderData->addItem($paymentOrderItemData);
Expand Down Expand Up @@ -226,7 +225,7 @@ protected function mapConvertimTransportDataToOrderItem(
$transportOrderItemData->totalPriceWithoutVat = Money::create($convertimOrderTransportData->getPriceWithoutVat());
$transportOrderItemData->unitPriceWithVat = Money::create($convertimOrderTransportData->getPriceWithVat());
$transportOrderItemData->unitPriceWithoutVat = Money::create($convertimOrderTransportData->getPriceWithoutVat());
$transportOrderItemData->vatPercent = $transport->getVatForDomain($this->domain->getId())->getPercent();
$transportOrderItemData->vatPercent = (string)($convertimOrderTransportData->getVatRate() ?? 0);
$transportOrderItemData->usePriceCalculation = false;

$orderData->addItem($transportOrderItemData);
Expand Down Expand Up @@ -268,12 +267,12 @@ protected function mapProducts(ConvertimOrderData $convertimOrderData, OrderData
$orderItemData->quantity = $convertimOrderItemData->getQuantity();
$orderItemData->unitPriceWithVat = Money::create($convertimOrderItemData->getPriceWithVat());
$orderItemData->unitPriceWithoutVat = Money::create($convertimOrderItemData->getPriceWithoutVat());
$orderItemData->vatPercent = $product->getVatForDomain($this->domain->getId())->getPercent();
$orderItemData->vatPercent = (string)($convertimOrderItemData->getVatRate() ?? 0);
$orderItemData->usePriceCalculation = false;

$orderData->addItem($orderItemData);
$orderData->addTotalPrice(new Price($orderItemData->totalPriceWithoutVat, $orderItemData->totalPriceWithVat), OrderItemTypeEnum::TYPE_PRODUCT);
$this->mapDiscounts($convertimOrderItemData, $product, $orderItemData, $orderData);
$this->mapDiscounts($convertimOrderItemData, $orderItemData, $orderData);
}
}

Expand All @@ -292,13 +291,11 @@ protected function mapPromoCodes(ConvertimOrderData $convertimOrderData, OrderDa

/**
* @param \Convertim\Order\ConvertimOrderItemData $convertimOrderItemData
* @param \Shopsys\FrameworkBundle\Model\Product\Product $product
* @param \Shopsys\FrameworkBundle\Model\Order\Item\OrderItemData $orderItemData
* @param \Shopsys\FrameworkBundle\Model\Order\OrderData $orderData
*/
protected function mapDiscounts(
ConvertimOrderItemData $convertimOrderItemData,
Product $product,
OrderItemData $orderItemData,
OrderData $orderData,
): void {
Expand Down

0 comments on commit 093595e

Please sign in to comment.