Class: MudratProjector::PercentageTransactionEntry
- Inherits:
-
TransactionEntry
- Object
- TransactionEntry
- MudratProjector::PercentageTransactionEntry
- Defined in:
- lib/mudrat_projector/transaction_entry.rb
Instance Attribute Summary collapse
-
#other_account_id ⇒ Object
readonly
Returns the value of attribute other_account_id.
Attributes inherited from TransactionEntry
Instance Method Summary collapse
- #calculate_amount(chart_of_accounts) ⇒ Object
-
#initialize(params = {}) ⇒ PercentageTransactionEntry
constructor
A new instance of PercentageTransactionEntry.
- #inspect ⇒ Object
- #serialize ⇒ Object
Methods inherited from TransactionEntry
#*, #calculate, #credit?, #debit?, #validate!
Methods included from TransactionEntry::Factory
Constructor Details
#initialize(params = {}) ⇒ PercentageTransactionEntry
Returns a new instance of PercentageTransactionEntry.
109 110 111 112 |
# File 'lib/mudrat_projector/transaction_entry.rb', line 109 def initialize params = {} @other_account_id = params.fetch :other_account_id super params end |
Instance Attribute Details
#other_account_id ⇒ Object (readonly)
Returns the value of attribute other_account_id.
107 108 109 |
# File 'lib/mudrat_projector/transaction_entry.rb', line 107 def other_account_id @other_account_id end |
Instance Method Details
#calculate_amount(chart_of_accounts) ⇒ Object
114 115 116 |
# File 'lib/mudrat_projector/transaction_entry.rb', line 114 def calculate_amount chart_of_accounts @amount = scalar * chart_of_accounts.fetch(other_account_id).balance end |
#inspect ⇒ Object
118 119 120 |
# File 'lib/mudrat_projector/transaction_entry.rb', line 118 def inspect "#<#{self.class}: percent=#{fmt(scalar * 100)}%, account_id=#{account_id.inspect} type=#{@credit_or_debit.inspect}, other_account_id=#{other_account_id.inspect}>" end |
#serialize ⇒ Object
122 123 124 |
# File 'lib/mudrat_projector/transaction_entry.rb', line 122 def serialize super.tap do |hash| hash[:other_account_id] = other_account_id; end end |