blend_spreadsheet_loan_generator 0.1.41 → 0.1.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blend_spreadsheet_loan_generator/concerns/spreadsheet_concern.rb +9 -2
- data/lib/blend_spreadsheet_loan_generator/early_repay.rb +4 -0
- data/lib/blend_spreadsheet_loan_generator/formula.rb +10 -9
- data/lib/blend_spreadsheet_loan_generator/loan.rb +1 -1
- data/lib/blend_spreadsheet_loan_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca84a8a3514638dbbdf412c9c3847f2e5ec299c6a057fe31bf64bed84214d5b
|
4
|
+
data.tar.gz: bbcea0582d8d49b4deeb03fd18e7485d2c721c74c63625fc0b7b5319d5ff870f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1040a0c2b2c5e7a2fbfc4bbb2b277ffa136ce4b57b849a1e96a5f7710aa84125940c779be295ae1cee150427d9c5d4c56b301497d3afcd2cedf079f73177e537
|
7
|
+
data.tar.gz: 4736c7b12ec0202759f72a953f81da8001c317d6183dfb8846ed0b3695c56a6a55bb58566e7ebdfd1bc85ff1965ee0c9c2bd141bf6dc9e6e6e86e236a13b3aa5
|
@@ -87,13 +87,20 @@ module BlendSpreadsheetLoanGenerator
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
90
|
+
def custom_early_repayment
|
91
|
+
%w[
|
92
|
+
period_calculated_fees
|
93
|
+
capitalized_fees_end
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
def apply_formulas(worksheet:, early_repayment: false)
|
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
|
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
|
@@ -170,12 +170,7 @@ module BlendSpreadsheetLoanGenerator
|
|
170
170
|
|
171
171
|
def period_calculated_fees_formula(line:, early_repayment: false)
|
172
172
|
term = line - 1
|
173
|
-
if loan.
|
174
|
-
with_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)} + #{period_fees_rate(line)})^#{loan.deferred_and_capitalized} * (#{period_rate(line)} + #{period_fees_rate(line)})"
|
175
|
-
without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{loan.deferred_and_capitalized} * #{period_rate(line)}"
|
176
|
-
|
177
|
-
"=#{with_fees} - #{without_fees}"
|
178
|
-
elsif loan.bullet_term?(term)
|
173
|
+
if loan.bullet_term?(term)
|
179
174
|
index = (
|
180
175
|
if early_repayment
|
181
176
|
index(line - 1)
|
@@ -188,6 +183,11 @@ module BlendSpreadsheetLoanGenerator
|
|
188
183
|
current = "#{with_fees} - #{without_fees}"
|
189
184
|
|
190
185
|
"=#{current} - #{capitalized_fees_start(line)}"
|
186
|
+
elsif loan.deferred_and_capitalized > 0 && term > loan.deferred_and_capitalized
|
187
|
+
with_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)} + #{period_fees_rate(line)})^#{loan.deferred_and_capitalized} * (#{period_rate(line)} + #{period_fees_rate(line)})"
|
188
|
+
without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{loan.deferred_and_capitalized} * #{period_rate(line)}"
|
189
|
+
|
190
|
+
"=#{with_fees} - #{without_fees}"
|
191
191
|
else
|
192
192
|
amount_to_capitalize = [
|
193
193
|
'(',
|
@@ -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
|
-
|
214
|
-
|
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)"
|