blend_spreadsheet_loan_generator 0.1.16 → 0.1.21

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: bbb638c6b9da3b44d76b3c6bdcd25ff0c72c859e1f972e5f032b58e202bbb411
4
- data.tar.gz: b104a0c811a1cc485a9914831db47e613af2a7f873aeffa0cb5dfc45859ba8b7
3
+ metadata.gz: 2f28ea47a7ea85e82f8bb7e6235025a727c4ed68e48ca775b8504a55e0ae104c
4
+ data.tar.gz: 933c6ad4f65149b569d0ac66e695b1896e6cd80d7e4b259cbd95920af99d811a
5
5
  SHA512:
6
- metadata.gz: af51b53a9b4073e41d898ee41d8ca6725b04ce50c16300d00f25a0867af0c3ce874290343ac66d3edb5e2096d7210b287b91b77640ce2cd1304557125146dc08
7
- data.tar.gz: 22b8948a0826f7f184672a3a0741514f17a7f133f61c46f7699f73dcd78b27dccf31b0cd24cd531a946b6addc404b6e1ee4b72d24cd555cf2d00bcac6ab17238
6
+ metadata.gz: acf4406ebca9f8ec7bee91d47d8ab9f187b7e5da5253d64ddf58d2e66f451c1f54522ae43eaee1a9002f490101c7b4323bf0591ad0765d49befffdd4134e1c6b
7
+ data.tar.gz: 39c9ce533a34f54a95ee4147759fddfb5ebcc0c985c0b32b9ea0cdbe75865752aba7c4add64c0a60c51f7acae4585342c73a08a1c165c2eb8ed0b0852d116f37
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
 
@@ -13,6 +13,7 @@ module BlendSpreadsheetLoanGenerator
13
13
  argument :rate, type: :float, required: true, desc: 'year rate post restructuration'
14
14
 
15
15
  option :guaranteed_terms, type: :integer, default: 0
16
+ option :ratio, type: :float
16
17
  option :duration, type: :integer, desc: 'duration'
17
18
  option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
18
19
  option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
@@ -44,10 +45,10 @@ module BlendSpreadsheetLoanGenerator
44
45
  values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
45
46
 
46
47
  last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i }
47
- guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms, nil) } || nil
48
+ guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms, -1).to_i } || nil
48
49
  total_guaranteed_interests = (
49
50
  if guaranteed_line.present? && guaranteed_line > last_paid_line
50
- values[last_paid_line..guaranteed_line].sum(:period_calculated_interests)
51
+ values[(last_paid_line + 1)..guaranteed_line].sum { |value| value[:period_calculated_interests] }
51
52
  else
52
53
  0
53
54
  end
@@ -74,9 +75,9 @@ module BlendSpreadsheetLoanGenerator
74
75
  values[last_paid_line + 1][:capitalized_interests_start] +
75
76
  values[last_paid_line + 1][:capitalized_fees_start]
76
77
  )
78
+ ratio = options.fetch(:ratio, (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
77
79
  guaranteed_interests_paid = (
78
- (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start]) *
79
- total_guaranteed_interests
80
+ ratio * total_guaranteed_interests
80
81
  )
81
82
  capital_paid -= guaranteed_interests_paid
82
83
 
@@ -109,7 +110,7 @@ module BlendSpreadsheetLoanGenerator
109
110
  "=#{excel_float(values[last_paid_line][:remaining_capital_end])} - #{period_capital(2)}"
110
111
 
111
112
  worksheet[2, columns.index('period_interests') + 1] =
112
- "=ARRONDI(#{period_theoric_interests(2)} + #{guaranteed_interests_paid}; 2)"
113
+ "=ARRONDI(#{period_theoric_interests(2)}; 2)"
113
114
 
114
115
  worksheet[2, columns.index('period_theoric_interests') + 1] =
115
116
  "=#{excel_float(values[last_paid_line + 1][:period_calculated_interests])}"
@@ -136,6 +137,9 @@ module BlendSpreadsheetLoanGenerator
136
137
  worksheet[2, columns.index('period_reimbursed_capitalized_fees') + 1] =
137
138
  excel_float(values[last_paid_line + 1][:capitalized_fees_start])
138
139
 
140
+ worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
141
+ excel_float(guaranteed_interests_paid)
142
+
139
143
  apply_formats(worksheet: worksheet)
140
144
 
141
145
  worksheet.save
@@ -175,6 +179,7 @@ module BlendSpreadsheetLoanGenerator
175
179
  h[:capitalized_fees_end] = h[:capitalized_fees_end].to_f
176
180
  h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
177
181
  h[:period_fees_rate] = h[:period_fees_rate].to_f
182
+ h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
178
183
 
179
184
  h
180
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.16'.freeze
4
+ VERSION = '0.1.21'.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.16
4
+ version: 0.1.21
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-09 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