blend_spreadsheet_loan_generator 0.1.15 → 0.1.20
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 +21 -5
- 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: e577c4867c3181945bf7cb960443c26aca398c1b2650cc41b23eecb2ba07740f
|
4
|
+
data.tar.gz: 7751b3676cd92659f849d265a1be7cc4b49ae251533b2b8a8aeb30198a82aac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10a1b186823531afe0ecdd159228b7ca9da495d9792c3f1900f611c560795642351475c68deb7f8b4ab9f262da9ef9ec086157cce1749d037f0c7702fca7cd85
|
7
|
+
data.tar.gz: c41aa92c96c91fc17f89dcc5b1772351705a995809365e06263019fbfc077f82a10b8d7406f26bad97d3503cc82ce4101b0c1afc04a5330be7b555e892ded191
|
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
|
|
@@ -12,6 +12,8 @@ module BlendSpreadsheetLoanGenerator
|
|
12
12
|
argument :from_path, type: :string, required: true, desc: 'csv to restructure'
|
13
13
|
argument :rate, type: :float, required: true, desc: 'year rate post restructuration'
|
14
14
|
|
15
|
+
option :guaranteed_terms, type: :integer, default: 0
|
16
|
+
option :ratio, type: :float
|
15
17
|
option :duration, type: :integer, desc: 'duration'
|
16
18
|
option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
|
17
19
|
option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
|
@@ -43,6 +45,14 @@ module BlendSpreadsheetLoanGenerator
|
|
43
45
|
values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
|
44
46
|
|
45
47
|
last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i }
|
48
|
+
guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms, -1).to_i } || nil
|
49
|
+
total_guaranteed_interests = (
|
50
|
+
if guaranteed_line.present? && guaranteed_line > last_paid_line
|
51
|
+
values[(last_paid_line + 1)..guaranteed_line].sum { |value| value[:period_calculated_interests] }
|
52
|
+
else
|
53
|
+
0
|
54
|
+
end
|
55
|
+
)
|
46
56
|
|
47
57
|
total_to_be_paid = (
|
48
58
|
values[last_paid_line + 1][:remaining_capital_start] +
|
@@ -59,15 +69,17 @@ module BlendSpreadsheetLoanGenerator
|
|
59
69
|
end
|
60
70
|
)
|
61
71
|
|
62
|
-
starting_capitalized_interests = 0.0
|
63
|
-
starting_capitalized_fees = 0.0
|
64
|
-
|
65
72
|
due_on = values[last_paid_line + 1][:due_on] + 1.month
|
66
73
|
|
67
74
|
capital_paid = amount_paid.to_f - (
|
68
75
|
values[last_paid_line + 1][:capitalized_interests_start] +
|
69
76
|
values[last_paid_line + 1][:capitalized_fees_start]
|
70
77
|
)
|
78
|
+
ratio = options.fetch(:ratio, (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start]))
|
79
|
+
guaranteed_interests_paid = (
|
80
|
+
ratio * total_guaranteed_interests
|
81
|
+
)
|
82
|
+
capital_paid -= guaranteed_interests_paid
|
71
83
|
|
72
84
|
@loan = Loan.new(
|
73
85
|
amount: values[last_paid_line][:remaining_capital_end],
|
@@ -80,8 +92,8 @@ module BlendSpreadsheetLoanGenerator
|
|
80
92
|
deferred: options.fetch(:deferred),
|
81
93
|
type: options.fetch(:type),
|
82
94
|
interests_type: options.fetch(:interests_type),
|
83
|
-
starting_capitalized_interests:
|
84
|
-
starting_capitalized_fees:
|
95
|
+
starting_capitalized_interests: 0.0,
|
96
|
+
starting_capitalized_fees: 0.0
|
85
97
|
)
|
86
98
|
|
87
99
|
spreadsheet = session.create_spreadsheet(loan.name)
|
@@ -125,6 +137,9 @@ module BlendSpreadsheetLoanGenerator
|
|
125
137
|
worksheet[2, columns.index('period_reimbursed_capitalized_fees') + 1] =
|
126
138
|
excel_float(values[last_paid_line + 1][:capitalized_fees_start])
|
127
139
|
|
140
|
+
worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
|
141
|
+
excel_float(guaranteed_interests_paid)
|
142
|
+
|
128
143
|
apply_formats(worksheet: worksheet)
|
129
144
|
|
130
145
|
worksheet.save
|
@@ -164,6 +179,7 @@ module BlendSpreadsheetLoanGenerator
|
|
164
179
|
h[:capitalized_fees_end] = h[:capitalized_fees_end].to_f
|
165
180
|
h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
|
166
181
|
h[:period_fees_rate] = h[:period_fees_rate].to_f
|
182
|
+
h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
|
167
183
|
|
168
184
|
h
|
169
185
|
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.20
|
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
|