Module: LedgerAccountable::LedgerOwner
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ledger_accountable/ledger_owner.rb
Overview
LedgerAccountable::LedgerOwner is intended to be included in models which act as the owner of a ledger.
Instance Method Summary collapse
- #balance ⇒ Object
-
#credit_total ⇒ Object
The absolute value of the sum of the LedgerOwner’s credit entries.
-
#debit_total ⇒ Object
The absolute value of the sum of the LedgerOwner’s debit entries.
Instance Method Details
#balance ⇒ Object
15 16 17 |
# File 'lib/ledger_accountable/ledger_owner.rb', line 15 def balance ledger_entries.sum(:amount_cents) end |
#credit_total ⇒ Object
The absolute value of the sum of the LedgerOwner’s credit entries. This can be used to determine the total amount credited to the ledger - for example, its total revenue.
22 23 24 |
# File 'lib/ledger_accountable/ledger_owner.rb', line 22 def credit_total ledger_entries.credits.sum(:amount_cents).abs end |
#debit_total ⇒ Object
The absolute value of the sum of the LedgerOwner’s debit entries. This can be used to determine the total amount owed to the ledger - for example, the aggregate value of the items sold.
29 30 31 |
# File 'lib/ledger_accountable/ledger_owner.rb', line 29 def debit_total ledger_entries.debits.sum(:amount_cents).abs end |