blend_spreadsheet_loan_generator 0.1.24 → 0.1.28
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 +25 -21
- 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: bf94149d6402855a08bf289dbbe244a061ff53b2b9c985ec6ad986990c80bc07
|
4
|
+
data.tar.gz: e4b12c44ab4f2cfaa75214532bcb172cc753be7e1e8971e68314e133b2ec5748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d029eec619738f060c7d202960b2ef0531fea597e6d4687658e5bf23f0f5bcd84482783b880b16b418103b3c20da5b7b5a78057809621dd29441d685c134dc1c
|
7
|
+
data.tar.gz: 7b92eadb27db35a729117b2b3b89d72217e4281d72606e78a8c44cd715c772da0a2d42a2a3783a5949dd329336b8ca59450696270f707b67b7be4bfdb2f6d8d1
|
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
|
|
@@ -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] +
|
@@ -80,27 +81,27 @@ module BlendSpreadsheetLoanGenerator
|
|
80
81
|
|
81
82
|
capital_paid = amount_paid.to_f - (
|
82
83
|
values[last_paid_line + 1][:capitalized_interests_start] +
|
83
|
-
values[last_paid_line + 1][:capitalized_fees_start]
|
84
|
+
values[last_paid_line + 1][:capitalized_fees_start] +
|
85
|
+
values[last_paid_line + 1][:period_calculated_interests] +
|
86
|
+
values[last_paid_line + 1][:period_calculated_fees]
|
84
87
|
)
|
85
|
-
|
86
|
-
|
87
|
-
values[last_paid_line + 1][:period_calculated_interests] -
|
88
|
+
capital_paid_for_ratio = amount_paid.to_f - (
|
89
|
+
values[last_paid_line + 1][:capitalized_fees_start] +
|
88
90
|
values[last_paid_line + 1][:period_calculated_fees]
|
89
91
|
)
|
90
92
|
|
91
|
-
ratio = options.fetch(:ratio, (
|
92
|
-
guaranteed_interests_paid =
|
93
|
-
|
94
|
-
)
|
95
|
-
capital_paid -= guaranteed_interests_paid
|
93
|
+
ratio = options.fetch(:ratio, (capital_paid_for_ratio.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
|
94
|
+
guaranteed_interests_paid = ratio * total_guaranteed_interests
|
95
|
+
guaranteed_fees_paid = ratio * total_guaranteed_fees
|
96
96
|
|
97
97
|
amount = (
|
98
98
|
if last_paid_line == -1
|
99
|
-
values[0][:
|
99
|
+
values[0][:remaining_capital_start]
|
100
100
|
else
|
101
101
|
values[last_paid_line][:remaining_capital_end]
|
102
102
|
end
|
103
103
|
)
|
104
|
+
|
104
105
|
@loan = Loan.new(
|
105
106
|
amount: amount,
|
106
107
|
duration: duration,
|
@@ -124,10 +125,10 @@ module BlendSpreadsheetLoanGenerator
|
|
124
125
|
apply_formulas(worksheet: worksheet)
|
125
126
|
|
126
127
|
worksheet[2, columns.index('remaining_capital_start') + 1] =
|
127
|
-
excel_float(values[last_paid_line][:
|
128
|
+
excel_float(values[last_paid_line + 1][:remaining_capital_start])
|
128
129
|
|
129
130
|
worksheet[2, columns.index('remaining_capital_end') + 1] =
|
130
|
-
"=#{excel_float(values[last_paid_line][:
|
131
|
+
"=#{excel_float(values[last_paid_line + 1][:remaining_capital_start])} - #{period_capital(2)}"
|
131
132
|
|
132
133
|
worksheet[2, columns.index('period_interests') + 1] =
|
133
134
|
"=ARRONDI(#{period_theoric_interests(2)}; 2)"
|
@@ -138,8 +139,7 @@ module BlendSpreadsheetLoanGenerator
|
|
138
139
|
worksheet[2, columns.index('period_fees') + 1] =
|
139
140
|
"=#{excel_float(values[last_paid_line + 1][:period_calculated_fees])}"
|
140
141
|
|
141
|
-
worksheet[2, columns.index('period_capital') + 1] =
|
142
|
-
"=#{excel_float(capital_paid)} - #{period_interests(2)} - #{period_fees(2)}"
|
142
|
+
worksheet[2, columns.index('period_capital') + 1] = "=#{excel_float(capital_paid)}"
|
143
143
|
|
144
144
|
worksheet[2, columns.index('capitalized_interests_start') + 1] =
|
145
145
|
excel_float(values[last_paid_line + 1][:capitalized_interests_start])
|
@@ -160,6 +160,9 @@ module BlendSpreadsheetLoanGenerator
|
|
160
160
|
worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
|
161
161
|
excel_float(guaranteed_interests_paid)
|
162
162
|
|
163
|
+
worksheet[2, columns.index('period_reimbursed_guaranteed_fees') + 1] =
|
164
|
+
excel_float(guaranteed_fees_paid)
|
165
|
+
|
163
166
|
apply_formats(worksheet: worksheet)
|
164
167
|
|
165
168
|
worksheet.save
|
@@ -200,6 +203,7 @@ module BlendSpreadsheetLoanGenerator
|
|
200
203
|
h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
|
201
204
|
h[:period_fees_rate] = h[:period_fees_rate].to_f
|
202
205
|
h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
|
206
|
+
h[:period_reimbursed_guaranteed_fees] = h[:period_reimbursed_guaranteed_fees].to_f
|
203
207
|
|
204
208
|
h
|
205
209
|
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.28
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|