Class: SpreadsheetLoanGenerator::Standard
- Inherits:
-
Object
- Object
- SpreadsheetLoanGenerator::Standard
- Includes:
- SpreadsheetConcern
- Defined in:
- lib/spreadsheet_loan_generator/standard.rb
Instance Attribute Summary collapse
-
#loan ⇒ Object
Returns the value of attribute loan.
Instance Method Summary collapse
-
#initialize(loan:) ⇒ Standard
constructor
A new instance of Standard.
- #period_calculated_capital_formula(line:) ⇒ Object
- #period_calculated_interests_formula(line:) ⇒ Object
- #standard_params(line:) ⇒ Object
Constructor Details
#initialize(loan:) ⇒ Standard
Returns a new instance of Standard.
7 8 9 |
# File 'lib/spreadsheet_loan_generator/standard.rb', line 7 def initialize(loan:) @loan = loan end |
Instance Attribute Details
#loan ⇒ Object
Returns the value of attribute loan.
5 6 7 |
# File 'lib/spreadsheet_loan_generator/standard.rb', line 5 def loan @loan end |
Instance Method Details
#period_calculated_capital_formula(line:) ⇒ Object
23 24 25 |
# File 'lib/spreadsheet_loan_generator/standard.rb', line 23 def period_calculated_capital_formula(line:) "=-PPMT(#{standard_params(line: line)})" end |
#period_calculated_interests_formula(line:) ⇒ Object
27 28 29 |
# File 'lib/spreadsheet_loan_generator/standard.rb', line 27 def period_calculated_interests_formula(line:) "=-IPMT(#{standard_params(line: line)})" end |
#standard_params(line:) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spreadsheet_loan_generator/standard.rb', line 11 def standard_params(line:) amount = if loan.deferred_and_capitalized.zero? excel_float(loan.amount) else "#{capitalized_interests_end(loan.deferred_and_capitalized + 1)} + #{excel_float(loan.amount)}" end term_cell = "#{index(line)} - #{loan.total_deferred_duration}" "#{period_rate(line)};#{term_cell};#{loan.non_deferred_duration};#{amount}" end |