Add option to ignore financial transaction when calculating the balance

This commit is contained in:
Patrick Gansterer 2021-02-08 02:40:19 +01:00
parent a30d0d4453
commit 7d5155bef6
6 changed files with 68 additions and 16 deletions

View file

@ -103,7 +103,11 @@ class Ordergroup < Group
end
def update_balance!
update_attribute :account_balance, financial_transactions.sum('amount')
new_account_balance = financial_transactions
.joins(financial_transaction_type: [:financial_transaction_class])
.where({ financial_transaction_classes: { ignore_for_account_balance: false} })
.sum(:amount)
update_attribute :account_balance, new_account_balance
end
def avg_jobs_per_euro