blend_spreadsheet_loan_generator 0.1.18 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/bslg +0 -1
- data/lib/blend_spreadsheet_loan_generator/concerns/spreadsheet_concern.rb +2 -1
- data/lib/blend_spreadsheet_loan_generator/early_repay.rb +15 -4
- data/lib/blend_spreadsheet_loan_generator/formula.rb +7 -1
- data/lib/blend_spreadsheet_loan_generator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97656de6803defd1af54366733c9f096f2a571fba89576b0a96ced269bfdebae
|
4
|
+
data.tar.gz: 9b0036e1d46ae2835d7d1add57af17e18b29107a9b29e1f8e00dde54d86fef48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ae85edc2da12b6d1689f33e7564486fad79968c51c5cbb8d3ffb998b2c563d544f5267dd3b3df5a869ac98bd28742d9ccd0e1908e0f8b186b0b7b04835edfc2
|
7
|
+
data.tar.gz: 5896188fffc2c776cf8f9a8ba847c35f4848830ac8f1a893bc59a216e24a5f11b994d1e41dd4304fa15c38e1513ecd543721e22ba93e19ece033ed8021221744
|
data/exe/bslg
CHANGED
@@ -3,7 +3,6 @@ module BlendSpreadsheetLoanGenerator
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
|
7
6
|
def columns
|
8
7
|
%w[
|
9
8
|
index
|
@@ -33,6 +32,7 @@ module BlendSpreadsheetLoanGenerator
|
|
33
32
|
capitalized_fees_end
|
34
33
|
period_reimbursed_capitalized_fees
|
35
34
|
period_fees_rate
|
35
|
+
period_reimbursed_guaranteed_interests
|
36
36
|
]
|
37
37
|
end
|
38
38
|
|
@@ -53,6 +53,7 @@ module BlendSpreadsheetLoanGenerator
|
|
53
53
|
capitalized_fees_start
|
54
54
|
capitalized_fees_end
|
55
55
|
period_reimbursed_capitalized_fees
|
56
|
+
period_reimbursed_guaranteed_interests
|
56
57
|
]
|
57
58
|
end
|
58
59
|
|
@@ -13,6 +13,7 @@ module BlendSpreadsheetLoanGenerator
|
|
13
13
|
argument :rate, type: :float, required: true, desc: 'year rate post restructuration'
|
14
14
|
|
15
15
|
option :guaranteed_terms, type: :integer, default: 0
|
16
|
+
option :ratio, type: :float
|
16
17
|
option :duration, type: :integer, desc: 'duration'
|
17
18
|
option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
|
18
19
|
option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
|
@@ -44,7 +45,7 @@ module BlendSpreadsheetLoanGenerator
|
|
44
45
|
values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
|
45
46
|
|
46
47
|
last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i }
|
47
|
-
guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms,
|
48
|
+
guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms, -1).to_i } || nil
|
48
49
|
total_guaranteed_interests = (
|
49
50
|
if guaranteed_line.present? && guaranteed_line > last_paid_line
|
50
51
|
values[(last_paid_line + 1)..guaranteed_line].sum { |value| value[:period_calculated_interests] }
|
@@ -74,9 +75,15 @@ module BlendSpreadsheetLoanGenerator
|
|
74
75
|
values[last_paid_line + 1][:capitalized_interests_start] +
|
75
76
|
values[last_paid_line + 1][:capitalized_fees_start]
|
76
77
|
)
|
78
|
+
actual_capital_paid = (
|
79
|
+
capital_paid -
|
80
|
+
values[last_paid_line + 1][:period_calculated_interests] -
|
81
|
+
values[last_paid_line + 1][:period_calculated_fees]
|
82
|
+
)
|
83
|
+
|
84
|
+
ratio = options.fetch(:ratio, (actual_capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
|
77
85
|
guaranteed_interests_paid = (
|
78
|
-
|
79
|
-
total_guaranteed_interests
|
86
|
+
ratio * total_guaranteed_interests
|
80
87
|
)
|
81
88
|
capital_paid -= guaranteed_interests_paid
|
82
89
|
|
@@ -109,7 +116,7 @@ module BlendSpreadsheetLoanGenerator
|
|
109
116
|
"=#{excel_float(values[last_paid_line][:remaining_capital_end])} - #{period_capital(2)}"
|
110
117
|
|
111
118
|
worksheet[2, columns.index('period_interests') + 1] =
|
112
|
-
"=ARRONDI(#{period_theoric_interests(2)}
|
119
|
+
"=ARRONDI(#{period_theoric_interests(2)}; 2)"
|
113
120
|
|
114
121
|
worksheet[2, columns.index('period_theoric_interests') + 1] =
|
115
122
|
"=#{excel_float(values[last_paid_line + 1][:period_calculated_interests])}"
|
@@ -136,6 +143,9 @@ module BlendSpreadsheetLoanGenerator
|
|
136
143
|
worksheet[2, columns.index('period_reimbursed_capitalized_fees') + 1] =
|
137
144
|
excel_float(values[last_paid_line + 1][:capitalized_fees_start])
|
138
145
|
|
146
|
+
worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
|
147
|
+
excel_float(guaranteed_interests_paid)
|
148
|
+
|
139
149
|
apply_formats(worksheet: worksheet)
|
140
150
|
|
141
151
|
worksheet.save
|
@@ -175,6 +185,7 @@ module BlendSpreadsheetLoanGenerator
|
|
175
185
|
h[:capitalized_fees_end] = h[:capitalized_fees_end].to_f
|
176
186
|
h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
|
177
187
|
h[:period_fees_rate] = h[:period_fees_rate].to_f
|
188
|
+
h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
|
178
189
|
|
179
190
|
h
|
180
191
|
end
|
@@ -42,7 +42,9 @@ module BlendSpreadsheetLoanGenerator
|
|
42
42
|
'+',
|
43
43
|
period_interests(line),
|
44
44
|
'+',
|
45
|
-
period_reimbursed_capitalized_interests(line)
|
45
|
+
period_reimbursed_capitalized_interests(line),
|
46
|
+
'+',
|
47
|
+
period_reimbursed_guaranteed_interests(line)
|
46
48
|
].join(' ')
|
47
49
|
"=ARRONDI(#{total}; 2)"
|
48
50
|
end
|
@@ -207,5 +209,9 @@ module BlendSpreadsheetLoanGenerator
|
|
207
209
|
def period_fees_rate_formula(line:)
|
208
210
|
@interests_formula.period_fees_rate_formula(line: line)
|
209
211
|
end
|
212
|
+
|
213
|
+
def period_reimbursed_guaranteed_interests_formula(line:)
|
214
|
+
excel_float(0.0)
|
215
|
+
end
|
210
216
|
end
|
211
217
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blend_spreadsheet_loan_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MZiserman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|