From 32216b062f274c677de0cbed39619adf843fa359 Mon Sep 17 00:00:00 2001 From: Tykea Ly Date: Tue, 26 Nov 2024 11:16:37 +0700 Subject: [PATCH] close #2088 avoid carrying voided invoice forward --- app/controllers/spree/billing/payments_controller.rb | 2 ++ .../spree_cm_commissioner/subscriptions_order_creator.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/spree/billing/payments_controller.rb b/app/controllers/spree/billing/payments_controller.rb index d0b213cb3..55170e19f 100644 --- a/app/controllers/spree/billing/payments_controller.rb +++ b/app/controllers/spree/billing/payments_controller.rb @@ -61,6 +61,8 @@ def update flash[:success] = Spree.t(:payment_updated) + return if params[:e] == 'void_transaction' + return unless @order.outstanding_balance.positive? @payment = @order.payments.build(amount: @order.outstanding_balance, payment_method: @order.collect_backend_payment_methods.first) diff --git a/app/interactors/spree_cm_commissioner/subscriptions_order_creator.rb b/app/interactors/spree_cm_commissioner/subscriptions_order_creator.rb index 9c6f41d64..bbb778a4b 100644 --- a/app/interactors/spree_cm_commissioner/subscriptions_order_creator.rb +++ b/app/interactors/spree_cm_commissioner/subscriptions_order_creator.rb @@ -52,6 +52,7 @@ def create_order(active_subscriptions) def add_penalty_to_order return if context.last_order.blank? + return if context.last_order.payment_state == 'failed' penalty_rate_amount = context.last_order.outstanding_balance * customer.vendor.penalty_rate.to_f / 100 Spree::Adjustment.create!(