mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
[bug] when paying reservation with wallet, the invoice footprint is not correctly updated
This commit is contained in:
parent
f1d35512fa
commit
936495e596
@ -1,5 +1,7 @@
|
||||
# Changelog Fab Manager
|
||||
|
||||
- Fix a bug: when paying a reservation with wallet, the invoice footprint is not correctly updated
|
||||
|
||||
## v3.1.0 2019 April 8
|
||||
|
||||
- Asynchronously generate accounting archives
|
||||
|
5
app/exceptions/invalid_footprint_error.rb
Normal file
5
app/exceptions/invalid_footprint_error.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Raised when a chained footprint is detected as wrong (invoices, invoice_items, history_values)
|
||||
class InvalidFootprintError < StandardError
|
||||
end
|
@ -230,6 +230,15 @@ class Invoice < ActiveRecord::Base
|
||||
invoice_items.map(&:check_footprint).all? && footprint == compute_footprint
|
||||
end
|
||||
|
||||
def set_wallet_transaction(amount, transaction_id)
|
||||
if check_footprint
|
||||
update_columns(wallet_amount: amount, wallet_transaction_id: transaction_id)
|
||||
chain_record
|
||||
else
|
||||
raise InvalidFootprintError
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_and_send_invoice
|
||||
|
@ -486,7 +486,7 @@ class Reservation < ActiveRecord::Base
|
||||
# wallet debit success
|
||||
raise DebitWalletError unless wallet_transaction
|
||||
|
||||
invoice.update_columns(wallet_amount: @wallet_amount_debit, wallet_transaction_id: wallet_transaction.id)
|
||||
invoice.set_wallet_transaction(@wallet_amount_debit, wallet_transaction.id)
|
||||
end
|
||||
|
||||
# this function only use for compute total of reservation before save
|
||||
|
8
config/spring.rb
Normal file
8
config/spring.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Spring.after_fork do
|
||||
if ENV['DEBUGGER_STORED_RUBYLIB']
|
||||
starter = ENV['BUNDLER_ORIG_RUBYOPT'][2..-1]
|
||||
load(starter + '.rb')
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user