Sha256: 01c074b77038ac4fe3afd22e789e2a56a815ca0468552babdadb4d719bcdad7d
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
module LoanCreator class Term ARGUMENTS = [ # Remaining due capital at the beginning of the term :crd_beginning_of_period, # Remaining due capital at the end of the term :crd_end_of_period, # Theoricaly due interests :period_theoric_interests, # Difference between theorical and real (rounded) due interests :delta_interests, # Accrued interests' delta :accrued_delta_interests, # Capitalized interests (Bullet only) :capitalized_interests, # Adjustment of -0.01, 0 or +0.01 cent depending on accrued_delta_interests :amount_to_add, # Interests to pay this term :period_interests, # Capital to pay this term :period_capital, # Total capital paid so far (including current term) :total_paid_capital_end_of_period, # Total interests paid so far (including current term) :total_paid_interests_end_of_period, # Amount to pay this term :period_amount_to_pay ].freeze OPTIONAL_ARGUMENTS = [ # Term number (starts at 1) # This value is to be set by Timetable :index, # Term date # This value is to be set by Timetable :due_on, ] ATTRIBUTES = (ARGUMENTS + OPTIONAL_ARGUMENTS).freeze attr_accessor *ATTRIBUTES def initialize(**options) ARGUMENTS.each { |k| instance_variable_set(:"@#{k}", options.fetch(k)) } OPTIONAL_ARGUMENTS.each { |k| instance_variable_set(:"@#{k}", options.fetch(k, nil)) } end def to_csv ATTRIBUTES.map { |k| instance_variable_get(:"@#{k}") }.join(',') end def to_s to_csv end def to_h ATTRIBUTES.each_with_object({}) { |k, h| h[k] = instance_variable_get(:"@#{k}") } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
loan_creator-0.6.3.1 | lib/loan_creator/term.rb |
loan_creator-0.6.2 | lib/loan_creator/term.rb |