blend_spreadsheet_loan_generator 0.1.26 → 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/lib/blend_spreadsheet_loan_generator/concerns/spreadsheet_concern.rb +2 -0
- data/lib/blend_spreadsheet_loan_generator/early_repay.rb +14 -10
- 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 +1 -1
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
|
@@ -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
|
|
@@ -46,13 +46,14 @@ module BlendSpreadsheetLoanGenerator
|
|
46
46
|
|
47
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] +
|
@@ -86,9 +87,8 @@ module BlendSpreadsheetLoanGenerator
|
|
86
87
|
)
|
87
88
|
|
88
89
|
ratio = options.fetch(:ratio, (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
|
89
|
-
guaranteed_interests_paid =
|
90
|
-
|
91
|
-
)
|
90
|
+
guaranteed_interests_paid = ratio * total_guaranteed_interests
|
91
|
+
guaranteed_fees_paid = ratio * total_guaranteed_fees
|
92
92
|
|
93
93
|
amount = (
|
94
94
|
if last_paid_line == -1
|
@@ -156,6 +156,9 @@ module BlendSpreadsheetLoanGenerator
|
|
156
156
|
worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
|
157
157
|
excel_float(guaranteed_interests_paid)
|
158
158
|
|
159
|
+
worksheet[2, columns.index('period_reimbursed_guaranteed_fees') + 1] =
|
160
|
+
excel_float(guaranteed_fees_paid)
|
161
|
+
|
159
162
|
apply_formats(worksheet: worksheet)
|
160
163
|
|
161
164
|
worksheet.save
|
@@ -196,6 +199,7 @@ module BlendSpreadsheetLoanGenerator
|
|
196
199
|
h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
|
197
200
|
h[:period_fees_rate] = h[:period_fees_rate].to_f
|
198
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
|
199
203
|
|
200
204
|
h
|
201
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
|