From 271064bf9c2a138032f3b7c376e9937f974eed97 Mon Sep 17 00:00:00 2001 From: mandan2 <61560082+mandan2@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:23:35 +0300 Subject: [PATCH] PIPRES-261: Separate carrier for recurring orders improvements (#821) * PIPRES-261: shipping option module setting (#814) * PIPRES-261: Shipping option module setting * csfixer * install and uninstall subscription configuration * improved faq page * PIPRES-333: Missing registered interface (#816) * PIPRES-261: Get carrier price to create subscription (#817) * PIPRES-261: Get carrier price to create subscription * updated subscription faq * renamed some services and added additional conditions for carrier retrieve * addedd back to exception codes * PIPRES-261: Set carrier for recurring order (#818) * PIPRES-261: Get carrier price to create subscription * renamed some services and added additional conditions for carrier retrieve * PIPRES-261: Set carrier for recurring order * PIPRES-261: Subscription order detail view refactoring (#819) * PIPRES-261: Get carrier price to create subscription * renamed some services and added additional conditions for carrier retrieve * addedd back to exception codes * PIPRES-261: Subscription order detail view refactoring * phpstan * PIPRES-261: Minor improvements (#820) * PIPRES-261: Get carrier price to create subscription * renamed some services and added additional conditions for carrier retrieve * PIPRES-261: Minor improvements * PIPRES-261: Create fresh specific price (#822) * PIPRES-261: Restrict BO subscription list for all shops (#823) * PIPRES-261: Restrict BO subscription list for all shops * fixed redundant error mesage --- subscription/Presenter/OrderPresenter.php | 35 --------- .../Presenter/RecurringOrderLazyArray.php | 40 ---------- .../Presenter/OrderPresenterTest.php | 75 ------------------- 3 files changed, 150 deletions(-) delete mode 100644 subscription/Presenter/OrderPresenter.php delete mode 100644 subscription/Presenter/RecurringOrderLazyArray.php delete mode 100644 tests/Integration/Subscription/Presenter/OrderPresenterTest.php diff --git a/subscription/Presenter/OrderPresenter.php b/subscription/Presenter/OrderPresenter.php deleted file mode 100644 index c907b7e7c..000000000 --- a/subscription/Presenter/OrderPresenter.php +++ /dev/null @@ -1,35 +0,0 @@ -getCartProducts(); - - foreach ($orderProducts as $orderProduct) { - if ((int) $orderProduct['id_product_attribute'] !== $recurringOrderProductAttributeId) { - $order->total_paid_tax_excl -= (float) $orderProduct['total_price_tax_excl']; - - continue; - } - - $order->total_products = (float) $orderProduct['total_price_tax_excl']; - $order->total_products_wt = (float) $orderProduct['total_price_tax_incl']; - $order->total_paid_tax_incl = $recurringOrderTotalTaxIncl; - $order->total_paid = $recurringOrderTotalTaxIncl; - - break; - } - - $orderLazyArray = new RecurringOrderLazyArray($order); - - $orderLazyArray->setRecurringOrderProductAttributeId($recurringOrderProductAttributeId); - - return $orderLazyArray; - } -} diff --git a/subscription/Presenter/RecurringOrderLazyArray.php b/subscription/Presenter/RecurringOrderLazyArray.php deleted file mode 100644 index 7d91bf59f..000000000 --- a/subscription/Presenter/RecurringOrderLazyArray.php +++ /dev/null @@ -1,40 +0,0 @@ -recurringOrderProductAttributeId = $recurringOrderProductAttributeId; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getProducts(): array - { - $subscriptionProduct = []; - - $orderProducts = parent::getProducts(); - - foreach ($orderProducts as $orderProduct) { - if ((int) $orderProduct['id_product_attribute'] !== $this->recurringOrderProductAttributeId) { - continue; - } - - $subscriptionProduct[] = $orderProduct; - - break; - } - - return $subscriptionProduct; - } -} diff --git a/tests/Integration/Subscription/Presenter/OrderPresenterTest.php b/tests/Integration/Subscription/Presenter/OrderPresenterTest.php deleted file mode 100644 index 1b3ad9a7a..000000000 --- a/tests/Integration/Subscription/Presenter/OrderPresenterTest.php +++ /dev/null @@ -1,75 +0,0 @@ - 1, - 'id_product_attribute' => 1, - 'total_price_tax_excl' => 10.00, - 'product_price' => 10.00, - 'total_price' => 10.00, - 'total_price_tax_incl' => 12.10, - 'product_price_wt' => 12.10, - 'total_wt' => 12.10, - 'product_name' => 'test-product-1', - 'product_quantity' => 1, - 'product_id' => 1, - 'id_customization' => 1, - ], - [ - 'product_attribute_id' => 2, - 'id_product_attribute' => 2, - 'total_price_tax_excl' => 100.00, - 'product_price' => 100.00, - 'total_price' => 100.00, - 'total_price_tax_incl' => 121.00, - 'product_price_wt' => 121.00, - 'total_wt' => 121.00, - 'product_name' => 'test-product-2', - 'product_quantity' => 2, - 'product_id' => 2, - 'id_customization' => 1, - ], - [ - 'product_attribute_id' => 3, - 'id_product_attribute' => 3, - 'total_price_tax_excl' => 1000.00, - 'product_price' => 1000.00, - 'total_price' => 1000.00, - 'total_price_tax_incl' => 1210.00, - 'product_price_wt' => 1210.00, - 'total_wt' => 1210.00, - 'product_name' => 'test-product-3', - 'product_quantity' => 3, - 'product_id' => 3, - 'id_customization' => 1, - ], - ]; - - $order = $this->createMock(\Order::class); - $order->total_paid_tax_excl = 1500; - $order->id_currency = 1; - $order->method('getCartProducts')->willReturn($products); - $order->method('getProducts')->willReturn($products); - - /** @var OrderPresenter $orderPresenter */ - $orderPresenter = $this->getService(OrderPresenter::class); - - $result = $orderPresenter->present( - $order, - 3, - 1300 - ); - - $this->assertCount(1, $result->getProducts()); - $this->assertEquals(3, $result->getProducts()[0]['id_product_attribute']); - } -}