Class: MudratProjector::PercentageTransactionEntry
Instance Attribute Summary collapse
#account_id, #amount
Instance Method Summary
collapse
#*, #calculate, #credit?, #debit?, #validate!
#new, #new_credit, #new_debit
Constructor Details
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
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
|