blend_spreadsheet_loan_generator 0.1.25 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 169f284925fdd8ff961eecf431c8fd62625cf9b5cc1006cf2c0d1fe2ff3d290d
4
- data.tar.gz: af871dff6102cbb857cd7fbc65f75265b597cee10689adc820c1b7060cf72dbe
3
+ metadata.gz: c2feb14eec33c86a032e711df82ad3b93bf8fd5b3f97c3746a5a24bef7814398
4
+ data.tar.gz: e526d50983256ede22d4d54d3e5f0486c36ca88509d254d57b8ad77f5e86a8a4
5
5
  SHA512:
6
- metadata.gz: 483fbcafe2c4f763f2b1a53108d4d80f344471a730de69e2a938370ae5159581925f93b1efa33e29530afbc74897a0aaf4251a9885c46ac2f7926478a15c51cc
7
- data.tar.gz: da813c5b56325a72db5023b2fad4be50008bb112c2198ac491a99d7d17c57131245eb2bc48750aef5c19addd9b2825a27e34a7e639a59ac125844c63e4aa4e11
6
+ metadata.gz: 59c7cf8b548249e27dd0c945598ab2d9a8287c32372b370d6bbbec2f7ffaf960ed978e9fd6e747564541152659dc841f57410769c3fd2571721898f2b389163a
7
+ data.tar.gz: 3a83c45004a61448074532f5d7ee1d0541b54734657821d965ab8de33649b056108470d9ac26c1056c3f78d8dd1630ce3b3fad32e01b1795679e2ed492bddd2f
@@ -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
- 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
- )
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] +
@@ -84,12 +85,20 @@ module BlendSpreadsheetLoanGenerator
84
85
  values[last_paid_line + 1][:period_calculated_interests] +
85
86
  values[last_paid_line + 1][:period_calculated_fees]
86
87
  )
87
-
88
- ratio = options.fetch(:ratio, (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
89
- guaranteed_interests_paid = (
90
- ratio * total_guaranteed_interests
88
+ capital_paid_for_ratio = amount_paid.to_f - (
89
+ values[last_paid_line + 1][:capitalized_fees_start] +
90
+ values[last_paid_line + 1][:period_calculated_fees]
91
+ )
92
+ remaining_capital_for_ratio = (
93
+ values[last_paid_line + 1][:remaining_capital_start] +
94
+ values[last_paid_line + 1][:capitalized_interests_start] +
95
+ values[last_paid_line + 1][:period_calculated_interests]
91
96
  )
92
97
 
98
+ ratio = options.fetch(:ratio, capital_paid_for_ratio.to_f / remaining_capital_for_ratio).to_f
99
+ guaranteed_interests_paid = ratio * total_guaranteed_interests
100
+ guaranteed_fees_paid = ratio * total_guaranteed_fees
101
+
93
102
  amount = (
94
103
  if last_paid_line == -1
95
104
  values[0][:remaining_capital_start]
@@ -156,6 +165,9 @@ module BlendSpreadsheetLoanGenerator
156
165
  worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
157
166
  excel_float(guaranteed_interests_paid)
158
167
 
168
+ worksheet[2, columns.index('period_reimbursed_guaranteed_fees') + 1] =
169
+ excel_float(guaranteed_fees_paid)
170
+
159
171
  apply_formats(worksheet: worksheet)
160
172
 
161
173
  worksheet.save
@@ -196,6 +208,7 @@ module BlendSpreadsheetLoanGenerator
196
208
  h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
197
209
  h[:period_fees_rate] = h[:period_fees_rate].to_f
198
210
  h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
211
+ h[:period_reimbursed_guaranteed_fees] = h[:period_reimbursed_guaranteed_fees].to_f
199
212
 
200
213
  h
201
214
  end
@@ -213,5 +213,9 @@ module BlendSpreadsheetLoanGenerator
213
213
  def period_reimbursed_guaranteed_interests_formula(line:)
214
214
  excel_float(0.0)
215
215
  end
216
+
217
+ def period_reimbursed_guaranteed_fees_formula(line:)
218
+ excel_float(0.0)
219
+ end
216
220
  end
217
221
  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
@@ -1,7 +1,7 @@
1
1
  require 'dry/cli'
2
2
 
3
3
  module BlendSpreadsheetLoanGenerator
4
- VERSION = '0.1.25'.freeze
4
+ VERSION = '0.1.29'.freeze
5
5
 
6
6
  class Version < Dry::CLI::Command
7
7
  desc 'Print version'
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.25
4
+ version: 0.1.29
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-15 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport