blend_spreadsheet_loan_generator 0.1.14 → 0.1.19
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 +3 -1
- data/lib/blend_spreadsheet_loan_generator/early_repay.rb +21 -6
- 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: 3a4482f5c0a0e93b8085f1bc9d064a15873d9da91d4a3c945febb087b9a233ff
|
4
|
+
data.tar.gz: a00f98340c0aa4109b950d59c132bbbeab5878992b474875db21078010762162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a7e731e49a56746d8a0b60e7a867efa6f10c65e59ad785fed1dd0529e3f1ca748582f1c6e54867b3c25cf54fb553d05f3b5d4a915194815960868c1c0fda226
|
7
|
+
data.tar.gz: 3337ca2d8d85a4eabb170869097eded13b92404f5ea402bb70ef6b943946479784f8e46d0fa868a58498f9b0c52184958671050d3a4944ce3a7099a7e1a2f1c3
|
data/exe/bslg
CHANGED
@@ -3,7 +3,7 @@ module BlendSpreadsheetLoanGenerator
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
|
6
|
+
|
7
7
|
def columns
|
8
8
|
%w[
|
9
9
|
index
|
@@ -33,6 +33,7 @@ module BlendSpreadsheetLoanGenerator
|
|
33
33
|
capitalized_fees_end
|
34
34
|
period_reimbursed_capitalized_fees
|
35
35
|
period_fees_rate
|
36
|
+
period_reimbursed_guaranteed_interests
|
36
37
|
]
|
37
38
|
end
|
38
39
|
|
@@ -53,6 +54,7 @@ module BlendSpreadsheetLoanGenerator
|
|
53
54
|
capitalized_fees_start
|
54
55
|
capitalized_fees_end
|
55
56
|
period_reimbursed_capitalized_fees
|
57
|
+
period_reimbursed_guaranteed_interests
|
56
58
|
]
|
57
59
|
end
|
58
60
|
|
@@ -12,6 +12,7 @@ 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
|
15
16
|
option :duration, type: :integer, desc: 'duration'
|
16
17
|
option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
|
17
18
|
option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
|
@@ -43,6 +44,14 @@ module BlendSpreadsheetLoanGenerator
|
|
43
44
|
values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
|
44
45
|
|
45
46
|
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, -1).to_i } || nil
|
48
|
+
total_guaranteed_interests = (
|
49
|
+
if guaranteed_line.present? && guaranteed_line > last_paid_line
|
50
|
+
values[(last_paid_line + 1)..guaranteed_line].sum { |value| value[:period_calculated_interests] }
|
51
|
+
else
|
52
|
+
0
|
53
|
+
end
|
54
|
+
)
|
46
55
|
|
47
56
|
total_to_be_paid = (
|
48
57
|
values[last_paid_line + 1][:remaining_capital_start] +
|
@@ -55,19 +64,21 @@ module BlendSpreadsheetLoanGenerator
|
|
55
64
|
if total_to_be_paid == amount_paid
|
56
65
|
1
|
57
66
|
else
|
58
|
-
values.last[:index] - values[last_paid_line][:index]
|
67
|
+
options.fetch(:duration, values.last[:index] - values[last_paid_line][:index])
|
59
68
|
end
|
60
69
|
)
|
61
70
|
|
62
|
-
starting_capitalized_interests = 0.0
|
63
|
-
starting_capitalized_fees = 0.0
|
64
|
-
|
65
71
|
due_on = values[last_paid_line + 1][:due_on] + 1.month
|
66
72
|
|
67
73
|
capital_paid = amount_paid.to_f - (
|
68
74
|
values[last_paid_line + 1][:capitalized_interests_start] +
|
69
75
|
values[last_paid_line + 1][:capitalized_fees_start]
|
70
76
|
)
|
77
|
+
guaranteed_interests_paid = (
|
78
|
+
(capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start]) *
|
79
|
+
total_guaranteed_interests
|
80
|
+
)
|
81
|
+
capital_paid -= guaranteed_interests_paid
|
71
82
|
|
72
83
|
@loan = Loan.new(
|
73
84
|
amount: values[last_paid_line][:remaining_capital_end],
|
@@ -80,8 +91,8 @@ module BlendSpreadsheetLoanGenerator
|
|
80
91
|
deferred: options.fetch(:deferred),
|
81
92
|
type: options.fetch(:type),
|
82
93
|
interests_type: options.fetch(:interests_type),
|
83
|
-
starting_capitalized_interests:
|
84
|
-
starting_capitalized_fees:
|
94
|
+
starting_capitalized_interests: 0.0,
|
95
|
+
starting_capitalized_fees: 0.0
|
85
96
|
)
|
86
97
|
|
87
98
|
spreadsheet = session.create_spreadsheet(loan.name)
|
@@ -125,6 +136,9 @@ module BlendSpreadsheetLoanGenerator
|
|
125
136
|
worksheet[2, columns.index('period_reimbursed_capitalized_fees') + 1] =
|
126
137
|
excel_float(values[last_paid_line + 1][:capitalized_fees_start])
|
127
138
|
|
139
|
+
worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
|
140
|
+
excel_float(guaranteed_interests_paid)
|
141
|
+
|
128
142
|
apply_formats(worksheet: worksheet)
|
129
143
|
|
130
144
|
worksheet.save
|
@@ -164,6 +178,7 @@ module BlendSpreadsheetLoanGenerator
|
|
164
178
|
h[:capitalized_fees_end] = h[:capitalized_fees_end].to_f
|
165
179
|
h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
|
166
180
|
h[:period_fees_rate] = h[:period_fees_rate].to_f
|
181
|
+
h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
|
167
182
|
|
168
183
|
h
|
169
184
|
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.19
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|