blend_spreadsheet_loan_generator 0.1.15 → 0.1.20

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: 41bd051665f94b48954cb0d2067a075a9740eb8da3e72b672be25a724ffdeee2
4
- data.tar.gz: 17a1bbd4686e4a92a7da7720de63f71a5387455563e1853b1bce25508556187b
3
+ metadata.gz: e577c4867c3181945bf7cb960443c26aca398c1b2650cc41b23eecb2ba07740f
4
+ data.tar.gz: 7751b3676cd92659f849d265a1be7cc4b49ae251533b2b8a8aeb30198a82aac9
5
5
  SHA512:
6
- metadata.gz: '08a55ddabdf7e9b46f56a66cb6c9a2aafd02144a3776ad6ad575f90e922636c08a08448037941e16996ac5794cd51dc046e250a5c147dfa1e352f858fef78817'
7
- data.tar.gz: 2ae1b8b409995fef289f60148cbdd73d44a9402664d5b894f2fc83f556bee1055f0bcd1eff56f085773b095cc173f09ca9529425517f6060b1b1f2d974b543fd
6
+ metadata.gz: 10a1b186823531afe0ecdd159228b7ca9da495d9792c3f1900f611c560795642351475c68deb7f8b4ab9f262da9ef9ec086157cce1749d037f0c7702fca7cd85
7
+ data.tar.gz: c41aa92c96c91fc17f89dcc5b1772351705a995809365e06263019fbfc077f82a10b8d7406f26bad97d3503cc82ce4101b0c1afc04a5330be7b555e892ded191
data/exe/bslg CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/blend_spreadsheet_loan_generator'
4
-
5
4
  Dry::CLI.new(BlendSpreadsheetLoanGenerator).call
@@ -3,7 +3,6 @@ module BlendSpreadsheetLoanGenerator
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
-
7
6
  def columns
8
7
  %w[
9
8
  index
@@ -33,6 +32,7 @@ module BlendSpreadsheetLoanGenerator
33
32
  capitalized_fees_end
34
33
  period_reimbursed_capitalized_fees
35
34
  period_fees_rate
35
+ period_reimbursed_guaranteed_interests
36
36
  ]
37
37
  end
38
38
 
@@ -53,6 +53,7 @@ module BlendSpreadsheetLoanGenerator
53
53
  capitalized_fees_start
54
54
  capitalized_fees_end
55
55
  period_reimbursed_capitalized_fees
56
+ period_reimbursed_guaranteed_interests
56
57
  ]
57
58
  end
58
59
 
@@ -12,6 +12,8 @@ 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
16
+ option :ratio, type: :float
15
17
  option :duration, type: :integer, desc: 'duration'
16
18
  option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
17
19
  option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
@@ -43,6 +45,14 @@ module BlendSpreadsheetLoanGenerator
43
45
  values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
44
46
 
45
47
  last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i }
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
+ )
46
56
 
47
57
  total_to_be_paid = (
48
58
  values[last_paid_line + 1][:remaining_capital_start] +
@@ -59,15 +69,17 @@ module BlendSpreadsheetLoanGenerator
59
69
  end
60
70
  )
61
71
 
62
- starting_capitalized_interests = 0.0
63
- starting_capitalized_fees = 0.0
64
-
65
72
  due_on = values[last_paid_line + 1][:due_on] + 1.month
66
73
 
67
74
  capital_paid = amount_paid.to_f - (
68
75
  values[last_paid_line + 1][:capitalized_interests_start] +
69
76
  values[last_paid_line + 1][:capitalized_fees_start]
70
77
  )
78
+ ratio = options.fetch(:ratio, (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start]))
79
+ guaranteed_interests_paid = (
80
+ ratio * total_guaranteed_interests
81
+ )
82
+ capital_paid -= guaranteed_interests_paid
71
83
 
72
84
  @loan = Loan.new(
73
85
  amount: values[last_paid_line][:remaining_capital_end],
@@ -80,8 +92,8 @@ module BlendSpreadsheetLoanGenerator
80
92
  deferred: options.fetch(:deferred),
81
93
  type: options.fetch(:type),
82
94
  interests_type: options.fetch(:interests_type),
83
- starting_capitalized_interests: starting_capitalized_interests,
84
- starting_capitalized_fees: starting_capitalized_fees
95
+ starting_capitalized_interests: 0.0,
96
+ starting_capitalized_fees: 0.0
85
97
  )
86
98
 
87
99
  spreadsheet = session.create_spreadsheet(loan.name)
@@ -125,6 +137,9 @@ module BlendSpreadsheetLoanGenerator
125
137
  worksheet[2, columns.index('period_reimbursed_capitalized_fees') + 1] =
126
138
  excel_float(values[last_paid_line + 1][:capitalized_fees_start])
127
139
 
140
+ worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
141
+ excel_float(guaranteed_interests_paid)
142
+
128
143
  apply_formats(worksheet: worksheet)
129
144
 
130
145
  worksheet.save
@@ -164,6 +179,7 @@ module BlendSpreadsheetLoanGenerator
164
179
  h[:capitalized_fees_end] = h[:capitalized_fees_end].to_f
165
180
  h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
166
181
  h[:period_fees_rate] = h[:period_fees_rate].to_f
182
+ h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
167
183
 
168
184
  h
169
185
  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
@@ -1,7 +1,7 @@
1
1
  require 'dry/cli'
2
2
 
3
3
  module BlendSpreadsheetLoanGenerator
4
- VERSION = '0.1.15'.freeze
4
+ VERSION = '0.1.20'.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.15
4
+ version: 0.1.20
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-06 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport