1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

Fix a bug: invoice of reservation show payment by debit card when user pay with wallet

This commit is contained in:
Peng DU 2016-11-24 14:09:34 +01:00
parent 42f1213af7
commit 63a3bcf19a
3 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,7 @@
# Changelog Fab Manager
- Fix a bug: invoice of reservation show payment by debit card when user pay with wallet
## v2.4.3 2016 November 21
- Export user's invoicing status in members' excel export

View File

@ -0,0 +1,3 @@
# Raised when debit wallet fail
class DebitWalletError < StandardError
end

View File

@ -406,8 +406,14 @@ class Reservation < ActiveRecord::Base
if @wallet_amount_debit.present? and @wallet_amount_debit != 0
amount = @wallet_amount_debit / 100.0
wallet_transaction = WalletService.new(user: user, wallet: user.wallet).debit(amount, self)
if !user.invoicing_disabled? and wallet_transaction
self.invoice.update_columns(wallet_amount: @wallet_amount_debit, wallet_transaction_id: wallet_transaction.id)
# wallet debit success
if wallet_transaction
# payment by online or (payment by local and invoice isnt disabled)
if stp_invoice_id or !user.invoicing_disabled?
self.invoice.update_columns(wallet_amount: @wallet_amount_debit, wallet_transaction_id: wallet_transaction.id)
end
else
raise DebitWalletError
end
end
end