From 2a34e41b6761a12d4e46d11dc87ee90281cf33bf Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Thu, 23 Dec 2021 18:27:32 +0530 Subject: [PATCH 1/2] In ps_orders table advance_paid_amount is wrong in every order advance payment for full cart is entered. --- classes/PaymentModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 90c769ef8..c451a8923 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -355,7 +355,7 @@ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_ // advance payment information $order->is_advance_payment = $this->context->cart->is_advance_payment; - $order->advance_paid_amount = $cart_total_paid; + $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); // Creating order $result = $order->add(); From 34aa95c60c618ab4989d0bd5b6d86a83572a4883 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Fri, 24 Dec 2021 12:09:05 +0530 Subject: [PATCH 2/2] changes in calculating advance_paid_amount in orders table --- classes/PaymentModule.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index c451a8923..1a5517fb4 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -355,7 +355,11 @@ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_ // advance payment information $order->is_advance_payment = $this->context->cart->is_advance_payment; - $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); + if ($order->is_advance_payment) { + $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); + } else { + $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); + } // Creating order $result = $order->add();