blend_spreadsheet_loan_generator 0.1.23 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/bslg +1 -0
- data/lib/blend_spreadsheet_loan_generator/concerns/spreadsheet_concern.rb +2 -0
- data/lib/blend_spreadsheet_loan_generator/early_repay.rb +37 -23
- data/lib/blend_spreadsheet_loan_generator/formula.rb +4 -0
- data/lib/blend_spreadsheet_loan_generator/generate.rb +0 -9
- 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: b500ee01fce00eb5d3a71404f720ae470dd141bf187bef1634f3ad57588ba9f5
|
4
|
+
data.tar.gz: 46b53438bd6c349e3c5b52fc6fe333c081c1fd24bf5c098b28c4437abadb0ae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2ff7ffde2072fda5f29fb4fcaf61f6e3bccb663855c3527bba5d6f416d2949b2bc6a45bf92be0cc548f0976406dc115e54d225b01716b0072f8092a936b125e
|
7
|
+
data.tar.gz: 673dd3c59ce84d779cced52348043ce32e216faa5dc54bc332a8653206618f63ef5348b3a36b342e63ecfb26b3e795d99946c569c609314771300f0e47e00a66
|
data/exe/bslg
CHANGED
@@ -33,6 +33,7 @@ module BlendSpreadsheetLoanGenerator
|
|
33
33
|
period_reimbursed_capitalized_fees
|
34
34
|
period_fees_rate
|
35
35
|
period_reimbursed_guaranteed_interests
|
36
|
+
period_reimbursed_guaranteed_fees
|
36
37
|
]
|
37
38
|
end
|
38
39
|
|
@@ -54,6 +55,7 @@ module BlendSpreadsheetLoanGenerator
|
|
54
55
|
capitalized_fees_end
|
55
56
|
period_reimbursed_capitalized_fees
|
56
57
|
period_reimbursed_guaranteed_interests
|
58
|
+
period_reimbursed_guaranteed_fees
|
57
59
|
]
|
58
60
|
end
|
59
61
|
|
@@ -44,15 +44,16 @@ module BlendSpreadsheetLoanGenerator
|
|
44
44
|
values = f.to_a
|
45
45
|
values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
|
46
46
|
|
47
|
-
last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i }
|
47
|
+
last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i } || -1
|
48
48
|
guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms, -1).to_i } || nil
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
|
50
|
+
if guaranteed_line.present? && guaranteed_line >= (last_paid_line + 2)
|
51
|
+
total_guaranteed_interests = values[(last_paid_line + 2)..guaranteed_line].sum { |value| value[:period_calculated_interests] }
|
52
|
+
total_guaranteed_fees = values[(last_paid_line + 2)..guaranteed_line].sum { |value| value[:period_calculated_fees] }
|
53
|
+
else
|
54
|
+
total_guaranteed_interests = 0
|
55
|
+
total_guaranteed_fees = 0
|
56
|
+
end
|
56
57
|
|
57
58
|
total_to_be_paid = (
|
58
59
|
values[last_paid_line + 1][:remaining_capital_start] +
|
@@ -65,7 +66,14 @@ module BlendSpreadsheetLoanGenerator
|
|
65
66
|
if total_to_be_paid == amount_paid
|
66
67
|
1
|
67
68
|
else
|
68
|
-
options.fetch(
|
69
|
+
options.fetch(
|
70
|
+
:duration,
|
71
|
+
if last_paid_line == -1
|
72
|
+
values.last[:index]
|
73
|
+
else
|
74
|
+
values.last[:index] - values[last_paid_line][:index]
|
75
|
+
end
|
76
|
+
)
|
69
77
|
end
|
70
78
|
)
|
71
79
|
|
@@ -73,22 +81,25 @@ module BlendSpreadsheetLoanGenerator
|
|
73
81
|
|
74
82
|
capital_paid = amount_paid.to_f - (
|
75
83
|
values[last_paid_line + 1][:capitalized_interests_start] +
|
76
|
-
values[last_paid_line + 1][:capitalized_fees_start]
|
77
|
-
|
78
|
-
actual_capital_paid = (
|
79
|
-
capital_paid -
|
80
|
-
values[last_paid_line + 1][:period_calculated_interests] -
|
84
|
+
values[last_paid_line + 1][:capitalized_fees_start] +
|
85
|
+
values[last_paid_line + 1][:period_calculated_interests] +
|
81
86
|
values[last_paid_line + 1][:period_calculated_fees]
|
82
87
|
)
|
83
88
|
|
84
|
-
ratio = options.fetch(:ratio, (
|
85
|
-
guaranteed_interests_paid =
|
86
|
-
|
89
|
+
ratio = options.fetch(:ratio, (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
|
90
|
+
guaranteed_interests_paid = ratio * total_guaranteed_interests
|
91
|
+
guaranteed_fees_paid = ratio * total_guaranteed_fees
|
92
|
+
|
93
|
+
amount = (
|
94
|
+
if last_paid_line == -1
|
95
|
+
values[0][:remaining_capital_start]
|
96
|
+
else
|
97
|
+
values[last_paid_line][:remaining_capital_end]
|
98
|
+
end
|
87
99
|
)
|
88
|
-
capital_paid -= guaranteed_interests_paid
|
89
100
|
|
90
101
|
@loan = Loan.new(
|
91
|
-
amount:
|
102
|
+
amount: amount,
|
92
103
|
duration: duration,
|
93
104
|
rate: rate,
|
94
105
|
fees_rate: options.fetch(:fees_rate),
|
@@ -110,10 +121,10 @@ module BlendSpreadsheetLoanGenerator
|
|
110
121
|
apply_formulas(worksheet: worksheet)
|
111
122
|
|
112
123
|
worksheet[2, columns.index('remaining_capital_start') + 1] =
|
113
|
-
excel_float(values[last_paid_line][:
|
124
|
+
excel_float(values[last_paid_line + 1][:remaining_capital_start])
|
114
125
|
|
115
126
|
worksheet[2, columns.index('remaining_capital_end') + 1] =
|
116
|
-
"=#{excel_float(values[last_paid_line][:
|
127
|
+
"=#{excel_float(values[last_paid_line + 1][:remaining_capital_start])} - #{period_capital(2)}"
|
117
128
|
|
118
129
|
worksheet[2, columns.index('period_interests') + 1] =
|
119
130
|
"=ARRONDI(#{period_theoric_interests(2)}; 2)"
|
@@ -124,8 +135,7 @@ module BlendSpreadsheetLoanGenerator
|
|
124
135
|
worksheet[2, columns.index('period_fees') + 1] =
|
125
136
|
"=#{excel_float(values[last_paid_line + 1][:period_calculated_fees])}"
|
126
137
|
|
127
|
-
worksheet[2, columns.index('period_capital') + 1] =
|
128
|
-
"=#{excel_float(capital_paid)} - #{period_interests(2)} - #{period_fees(2)}"
|
138
|
+
worksheet[2, columns.index('period_capital') + 1] = "=#{excel_float(capital_paid)}"
|
129
139
|
|
130
140
|
worksheet[2, columns.index('capitalized_interests_start') + 1] =
|
131
141
|
excel_float(values[last_paid_line + 1][:capitalized_interests_start])
|
@@ -146,6 +156,9 @@ module BlendSpreadsheetLoanGenerator
|
|
146
156
|
worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
|
147
157
|
excel_float(guaranteed_interests_paid)
|
148
158
|
|
159
|
+
worksheet[2, columns.index('period_reimbursed_guaranteed_fees') + 1] =
|
160
|
+
excel_float(guaranteed_fees_paid)
|
161
|
+
|
149
162
|
apply_formats(worksheet: worksheet)
|
150
163
|
|
151
164
|
worksheet.save
|
@@ -186,6 +199,7 @@ module BlendSpreadsheetLoanGenerator
|
|
186
199
|
h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
|
187
200
|
h[:period_fees_rate] = h[:period_fees_rate].to_f
|
188
201
|
h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
|
202
|
+
h[:period_reimbursed_guaranteed_fees] = h[:period_reimbursed_guaranteed_fees].to_f
|
189
203
|
|
190
204
|
h
|
191
205
|
end
|
@@ -24,12 +24,6 @@ module BlendSpreadsheetLoanGenerator
|
|
24
24
|
|
25
25
|
def call(amount:, duration:, rate:, **options)
|
26
26
|
begin
|
27
|
-
# session = GoogleDrive::Session.from_service_account_key(
|
28
|
-
# File.join(
|
29
|
-
# ENV['SPREADSHEET_LOAN_GENERATOR_DIR'],
|
30
|
-
# 'loan-spreadsheet-generator-6c27a42bdda7.json'
|
31
|
-
# )
|
32
|
-
# )
|
33
27
|
session = GoogleDrive::Session.from_config(
|
34
28
|
File.join(ENV['SPREADSHEET_LOAN_GENERATOR_DIR'], 'config.json')
|
35
29
|
)
|
@@ -71,9 +65,6 @@ module BlendSpreadsheetLoanGenerator
|
|
71
65
|
generate_csv(worksheet: worksheet, target_path: options.fetch(:target_path))
|
72
66
|
|
73
67
|
puts worksheet.human_url
|
74
|
-
rescue => e
|
75
|
-
require 'pry'
|
76
|
-
binding.pry
|
77
68
|
end
|
78
69
|
end
|
79
70
|
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.27
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|