88use Mollie \Api \Types \OrderLineType ;
99use Psr \Log \LoggerInterface ;
1010use Shopware \Core \Checkout \Cart \LineItem \LineItem ;
11- use Shopware \Core \Checkout \Cart \Price \Struct \CalculatedPrice ;
1211use Shopware \Core \Checkout \Cart \Price \Struct \CartPrice ;
1312use Shopware \Core \Checkout \Cart \Tax \Struct \CalculatedTax ;
1413use Shopware \Core \Checkout \Cart \Tax \Struct \CalculatedTaxCollection ;
15- use Shopware \Core \Checkout \Cart \Tax \TaxCalculator ;
1614use Shopware \Core \Checkout \Order \Aggregate \OrderLineItem \OrderLineItemEntity ;
1715use Shopware \Core \Checkout \Order \OrderEntity ;
1816use Shopware \Core \Checkout \Promotion \Cart \PromotionProcessor ;
1917use Shopware \Core \Framework \Context ;
20- use Shopware \Core \Framework \DataAbstractionLayer \EntityRepository ;
2118use Shopware \Core \Framework \DataAbstractionLayer \EntityRepositoryInterface ;
2219use Shopware \Core \Framework \DataAbstractionLayer \Search \Criteria ;
2320use Shopware \Core \Framework \DataAbstractionLayer \Search \Filter \EqualsFilter ;
@@ -146,19 +143,7 @@ public function getOrderLinesArray(OrderEntity $order): array
146143 $ sku = $ item ->getProduct ()->getProductNumber ();
147144 }
148145
149- try {
150- $ molliePreparedApiPrices = $ this ->calculateLineItemPriceData ($ item , $ order ->getTaxStatus (), $ currencyCode );
151- } catch (MissingPriceLineItemException $ e ) {
152- $ this ->logger ->critical (
153- sprintf (
154- 'The order could not be prepared for mollie api. The LineItem with id (%s), sku (%s) has no prices ' ,
155- $ item ->getId (),
156- (string )$ sku
157- )
158- );
159-
160- throw $ e ;
161- }
146+ $ molliePreparedApiPrices = $ this ->calculateLineItemPriceData ($ item , $ order ->getTaxStatus (), $ currencyCode );
162147
163148 // Get the image
164149 $ imageUrl = null ;
@@ -298,6 +283,11 @@ public function calculateLineItemPriceData(OrderLineItemEntity $item, string $or
298283 $ vatRate = $ itemTax ->getTaxRate ();
299284 }
300285
286+ // Remove VAT if the order is tax free
287+ if ($ orderTaxType === CartPrice::TAX_STATE_FREE ) {
288+ $ vatRate = 0.0 ;
289+ }
290+
301291 $ unitPrice = $ price ->getUnitPrice ();
302292 $ lineItemTotalPrice = $ item ->getTotalPrice ();
303293
@@ -312,10 +302,6 @@ public function calculateLineItemPriceData(OrderLineItemEntity $item, string $or
312302
313303 $ unitPrice = round ($ unitPrice , self ::MOLLIE_PRICE_PRECISION );
314304
315- // Remove VAT if the order is tax free
316- if ($ orderTaxType === CartPrice::TAX_STATE_FREE ) {
317- $ vatRate = 0.0 ;
318- }
319305
320306 $ roundedLineItemTotalPrice = round ($ lineItemTotalPrice , self ::MOLLIE_PRICE_PRECISION );
321307 $ roundedVatRate = round ($ vatRate , self ::MOLLIE_PRICE_PRECISION );
0 commit comments