From d491384326fc08e8d332af92dbc0748c92c0fdc5 Mon Sep 17 00:00:00 2001 From: Peng Date: Tue, 13 Sep 2022 10:27:46 +0000 Subject: [PATCH] (bug) fix comput the wallet amount that dont apply coupon --- app/services/wallet_service.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/services/wallet_service.rb b/app/services/wallet_service.rb index 73f2b31ee..9966aa11a 100644 --- a/app/services/wallet_service.rb +++ b/app/services/wallet_service.rb @@ -75,17 +75,16 @@ class WalletService ## # Compute the amount decreased from the user's wallet, if applicable - # @param payment {Invoice|PaymentSchedule} + # @param payment {Invoice|PaymentSchedule|Order} # @param user {User} the customer - # @param coupon {Coupon|String} Coupon object or code ## - def self.wallet_amount_debit(payment, user, coupon = nil) + def self.wallet_amount_debit(payment, user) total = if payment.is_a? PaymentSchedule payment.payment_schedule_items.first.amount else payment.total end - total = CouponService.new.apply(total, coupon, user.id) if coupon + total = CouponService.new.apply(total, payment.coupon, user.id) if payment.coupon wallet_amount = (user.wallet.amount * 100).to_i