blend_spreadsheet_loan_generator 0.1.41 → 0.1.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1357474c60cfb9e4c2856a80890d3d009fc78a66d38848e1b280ba3e1326dbd1
4
- data.tar.gz: 6c7c524d35b0877d3d8a446142fc7c3e7bb5291af9fa9c07fc8343334e7dba6f
3
+ metadata.gz: b00db62c718e38412c067656409ac37d1fdcf8c9b4d5a9c9699ca192e3607b14
4
+ data.tar.gz: 364c5ef55c018309ee0492ca1608c069259bccb7ea2d71d483a2ed03dc0c4a6c
5
5
  SHA512:
6
- metadata.gz: 774098b91a0e32d71bfa251adf70f888e5a2447172da89fe6f8310d2e6dc460910c3c9e60cf05589e41fd03a95ad466b3ee1fc3a1f2c2e98d3713ef49a96736e
7
- data.tar.gz: 269d14778cc7c31d65a900e6542cc2a0dfe101d07aa2670b11bf8ed22b9556cf13d97df81b2d64a3f615d7c03d5b50a52baf56927b7904c6b04d72c5e46bf009
6
+ metadata.gz: 7852e9e3f19fdadd753878ac77ffa2a26175890f7b85ea338e260158580b6482637b1d03ed4af6c3528ae1928a1511218500aa3de8eaaf3bd3ab7e8b16def27b
7
+ data.tar.gz: 596d3dc61d9f379e89b4ac08dcc59e245a3192efc530df68f43818a354d2273eb5f5bca277b7a7167484fadf0b0cf99cf2efca283ce4540cf30b2962039d3c3d
@@ -87,13 +87,20 @@ module BlendSpreadsheetLoanGenerator
87
87
  end
88
88
  end
89
89
 
90
+ def custom_early_repayment
91
+ %w[
92
+ period_calculated_fees
93
+ capitalized_fees_end
94
+ ]
95
+ end
96
+
90
97
  def apply_formulas(worksheet:, early_repayment: true)
91
98
  columns.each.with_index do |title, column|
92
99
  worksheet[1, column + 1] = title
93
100
  end
94
101
  loan.duration.times do |line|
95
102
  columns.each.with_index do |title, column|
96
- if early_repayment && title == 'period_calculated_fees'
103
+ if early_repayment && title.in?(custom_early_repayment)
97
104
  worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2, early_repayment: true)
98
105
  else
99
106
  worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2)
@@ -168,6 +168,10 @@ module BlendSpreadsheetLoanGenerator
168
168
  worksheet[2, columns.index('period_reimbursed_guaranteed_fees') + 1] =
169
169
  excel_float(guaranteed_fees_paid)
170
170
 
171
+ worksheet[2, columns.index('period_calculated_fees') + 1] =
172
+ excel_float(0.0)
173
+
174
+
171
175
  apply_formats(worksheet: worksheet)
172
176
 
173
177
  worksheet.save
@@ -207,11 +207,12 @@ module BlendSpreadsheetLoanGenerator
207
207
  "=ARRONDI(#{capitalized_fees_end(line - 1)}; 2)"
208
208
  end
209
209
 
210
- def capitalized_fees_end_formula(line:)
210
+ def capitalized_fees_end_formula(line:, early_repayment: false)
211
211
  term = line - 1
212
212
  if term <= loan.deferred_and_capitalized
213
- with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index(line)}"
214
- without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index(line)}"
213
+ index = early_repayment ? index(line - 1) : index(line)
214
+ with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
215
+ without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index}"
215
216
  "=ARRONDI(#{with_fees} - #{without_fees}; 2)"
216
217
  else
217
218
  "=ARRONDI(#{capitalized_fees_start(line)} - #{period_reimbursed_capitalized_fees(line)}; 2)"
@@ -1,7 +1,7 @@
1
1
  require 'dry/cli'
2
2
 
3
3
  module BlendSpreadsheetLoanGenerator
4
- VERSION = '0.1.41'.freeze
4
+ VERSION = '0.1.42'.freeze
5
5
 
6
6
  class Version < Dry::CLI::Command
7
7
  desc 'Print version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blend_spreadsheet_loan_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.41
4
+ version: 0.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - MZiserman