Class: BlendSpreadsheetLoanGenerator::Standard

Inherits:
Object
  • Object
show all
Includes:
SpreadsheetConcern
Defined in:
lib/blend_spreadsheet_loan_generator/standard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loan:) ⇒ Standard

Returns a new instance of Standard.



7
8
9
# File 'lib/blend_spreadsheet_loan_generator/standard.rb', line 7

def initialize(loan:)
  @loan = loan
end

Instance Attribute Details

#loanObject

Returns the value of attribute loan.



5
6
7
# File 'lib/blend_spreadsheet_loan_generator/standard.rb', line 5

def loan
  @loan
end

Instance Method Details

#period_calculated_capital_formula(line:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/blend_spreadsheet_loan_generator/standard.rb', line 11

def period_calculated_capital_formula(line:)
  amount =
    if loan.deferred_and_capitalized.zero?
      excel_float(loan.amount + loan.starting_capitalized_interests + loan.starting_capitalized_fees)
    else
      "#{capitalized_interests_end(loan.deferred_and_capitalized + 1)} + #{capitalized_fees_end(loan.deferred_and_capitalized + 1)} + #{excel_float(loan.amount)}"
    end
  term_cell = "#{index(line)} - #{loan.total_deferred_duration}"

  params = "#{period_rate(line)};#{term_cell};#{loan.non_deferred_duration};#{amount}"
  "=-PPMT(#{params})"
end