Class: MudratProjector::PercentageTransactionEntry

Inherits:
TransactionEntry show all
Defined in:
lib/mudrat_projector/transaction_entry.rb

Instance Attribute Summary collapse

Attributes inherited from TransactionEntry

#account_id, #amount

Instance Method Summary collapse

Methods inherited from TransactionEntry

#*, #calculate, #credit?, #debit?, #validate!

Methods included from TransactionEntry::Factory

#new, #new_credit, #new_debit

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 = {}
   = params.fetch :other_account_id
  super params
end

Instance Attribute Details

#other_account_idObject (readonly)

Returns the value of attribute other_account_id.



107
108
109
# File 'lib/mudrat_projector/transaction_entry.rb', line 107

def 
  
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().balance
end

#inspectObject



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

#serializeObject



122
123
124
# File 'lib/mudrat_projector/transaction_entry.rb', line 122

def serialize
  super.tap do |hash| hash[:other_account_id] = ; end
end