How to associate different commercial document in a single entry?
Closed this issue · 2 comments
Is it possible to associate different commercial document in a single entry.
Example. a single entry can include
- a deposit to a savings account
- payment to loan
Not directly, but you can create an indirect model called for example EntryContext
with as many has_many
as you need, and then assign that as a commercial document to your entries.
the remedy i did was to create an account for each then associate it to the entry.
example:
liability_account = an account for savings account
receivable_account = an account for loan
cash_account = cash account of teller
entry = build(:entry)
entry.debit_amounts.build(amount: 1_000, account: cash_account)
entry.credit_amounts.build(amount: 300, account: liability_account)
entry.credit_amounts.build(amount: 700, account: receivable_account)
entry.save!