blend_spreadsheet_loan_generator 0.1.45 → 0.1.102
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 +4 -4
- data/lib/blend_spreadsheet_loan_generator/early_repay.rb +1 -1
- data/lib/blend_spreadsheet_loan_generator/formula.rb +9 -12
- data/lib/blend_spreadsheet_loan_generator/restructure.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: bfe713bbe1e4e57601559e592fc0a5fc621b5e72e151bb100ac341c6e29b8690
|
4
|
+
data.tar.gz: 409a0e1d8cc8a91926638577fb97d18794b25338c786547550f18dd849f525ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b4e6474624e79661081ab0ef187b8518d22e8ba79a3840aa30d4b7ef111db9442a367902621358b70f4cd37579516e526551a4b7603a6100e158c1097baf668
|
7
|
+
data.tar.gz: 3cb5ee2b57bf520c54ac42e35f43a33da737c1df2a6a2ea3714a2a34cb2e97a224d74f402dc797880f49773abd046885177fbd79af4be44505904703ac5f2358
|
@@ -87,21 +87,21 @@ module BlendSpreadsheetLoanGenerator
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
90
|
+
def first_term_skip_columns
|
91
91
|
%w[
|
92
92
|
period_calculated_fees
|
93
93
|
capitalized_fees_end
|
94
94
|
]
|
95
95
|
end
|
96
96
|
|
97
|
-
def apply_formulas(worksheet:,
|
97
|
+
def apply_formulas(worksheet:, first_term_skip: false)
|
98
98
|
columns.each.with_index do |title, column|
|
99
99
|
worksheet[1, column + 1] = title
|
100
100
|
end
|
101
101
|
loan.duration.times do |line|
|
102
102
|
columns.each.with_index do |title, column|
|
103
|
-
if
|
104
|
-
worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2,
|
103
|
+
if first_term_skip && title.in?(first_term_skip_columns)
|
104
|
+
worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2, first_term_skip: true)
|
105
105
|
else
|
106
106
|
worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2)
|
107
107
|
end
|
@@ -127,7 +127,7 @@ module BlendSpreadsheetLoanGenerator
|
|
127
127
|
|
128
128
|
@formula = Formula.new(loan: loan)
|
129
129
|
|
130
|
-
apply_formulas(worksheet: worksheet,
|
130
|
+
apply_formulas(worksheet: worksheet, first_term_skip: true)
|
131
131
|
|
132
132
|
worksheet[2, columns.index('remaining_capital_start') + 1] =
|
133
133
|
excel_float(values[last_paid_line + 1][:remaining_capital_start])
|
@@ -168,24 +168,21 @@ module BlendSpreadsheetLoanGenerator
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
def period_calculated_fees_formula(line:,
|
171
|
+
def period_calculated_fees_formula(line:, first_term_skip: false)
|
172
172
|
term = line - 1
|
173
173
|
if loan.bullet_term?(term)
|
174
|
-
index = (
|
175
|
-
|
176
|
-
index(line - 1)
|
177
|
-
else
|
178
|
-
index(line)
|
179
|
-
end
|
180
|
-
)
|
174
|
+
index = first_term_skip ? index(line - 1) : index(line)
|
175
|
+
|
181
176
|
with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
|
182
177
|
without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index}"
|
183
178
|
current = "#{with_fees} - #{without_fees}"
|
184
179
|
|
185
180
|
"=#{current} - #{capitalized_fees_start(line)}"
|
186
181
|
elsif loan.deferred_and_capitalized > 0 && term > loan.deferred_and_capitalized
|
187
|
-
|
188
|
-
|
182
|
+
index = first_term_skip ? loan.deferred_and_capitalized : loan.deferred_and_capitalized - 1
|
183
|
+
|
184
|
+
with_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)} + #{period_fees_rate(line)})^#{index} * (#{period_rate(line)} + #{period_fees_rate(line)})"
|
185
|
+
without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index} * #{period_rate(line)}"
|
189
186
|
|
190
187
|
"=#{with_fees} - #{without_fees}"
|
191
188
|
else
|
@@ -207,10 +204,10 @@ module BlendSpreadsheetLoanGenerator
|
|
207
204
|
"=ARRONDI(#{capitalized_fees_end(line - 1)}; 2)"
|
208
205
|
end
|
209
206
|
|
210
|
-
def capitalized_fees_end_formula(line:,
|
207
|
+
def capitalized_fees_end_formula(line:, first_term_skip: false)
|
211
208
|
term = line - 1
|
212
209
|
if term <= loan.deferred_and_capitalized
|
213
|
-
index =
|
210
|
+
index = first_term_skip ? index(line - 1) : index(line)
|
214
211
|
with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
|
215
212
|
without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index}"
|
216
213
|
"=ARRONDI(#{with_fees} - #{without_fees}; 2)"
|