blend_spreadsheet_loan_generator 0.1.45 → 0.1.99
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 +4 -4
- 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: 565ddfb9ab9868bd0bc47ca82c3322b7a8a6fa2a5d1a519782bc3f985fa8e668
|
4
|
+
data.tar.gz: 1877ad34ba609c03c59f2fabc81d9d91940df5e1194a3455d52d697bbb8d7c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6db635662441108f44574b6b6f9eec16fe94e7394b324ab83213051b84e693391effb880db74e259c46fef54b7b74802adbcee34f95e648d23a20f37a0561f8a
|
7
|
+
data.tar.gz: f79d314308aac20dd01f22e5a03f1eb6a47aa1dc87542c4b93ae903d3a5e2c1dad3183acf59c0b6826e0f4dbc4d3559909c3d7222d6373c96fc55793f55871cb
|
@@ -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?(custom_early_repayment)
|
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,11 +168,11 @@ 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
174
|
index = (
|
175
|
-
if
|
175
|
+
if first_term_skip
|
176
176
|
index(line - 1)
|
177
177
|
else
|
178
178
|
index(line)
|
@@ -207,10 +207,10 @@ 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:, first_term_skip: false)
|
211
211
|
term = line - 1
|
212
212
|
if term <= loan.deferred_and_capitalized
|
213
|
-
index =
|
213
|
+
index = first_term_skip ? index(line - 1) : index(line)
|
214
214
|
with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
|
215
215
|
without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index}"
|
216
216
|
"=ARRONDI(#{with_fees} - #{without_fees}; 2)"
|
@@ -72,7 +72,7 @@ module BlendSpreadsheetLoanGenerator
|
|
72
72
|
spreadsheet = session.create_spreadsheet(loan.name)
|
73
73
|
worksheet = spreadsheet.add_worksheet(loan.type, loan.duration + 2, columns.count + 1, index: 0)
|
74
74
|
|
75
|
-
@formula = Formula.new(loan: loan)
|
75
|
+
@formula = Formula.new(loan: loan, first_term_skip: true)
|
76
76
|
|
77
77
|
apply_formulas(worksheet: worksheet)
|
78
78
|
apply_formats(worksheet: worksheet)
|