blend_spreadsheet_loan_generator 0.1.14 → 0.1.19

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: d479d818a0375938fac8af2b76798236b0acbdd1074613da808dded2b788af5a
4
- data.tar.gz: 54d0a3866d06817a3170b878d6b1bd074300334c81ce9c185c463d06682228a4
3
+ metadata.gz: 3a4482f5c0a0e93b8085f1bc9d064a15873d9da91d4a3c945febb087b9a233ff
4
+ data.tar.gz: a00f98340c0aa4109b950d59c132bbbeab5878992b474875db21078010762162
5
5
  SHA512:
6
- metadata.gz: e29bcf2a06bb55675c1b9e5cc90457d23a60b23a7670908ac0361bc8be56cb4f7e4cbd762909f6d51d7092a06734f54a723db2da1a95396700090bb6a6af2572
7
- data.tar.gz: 400f763cb728b85c541429b36d892f328d1fa19ef003b78ff06aa0ad0dbb60bc56b6f2bf59c951a5b00b2a9af2e479cb3bdb14802634c86c81afa6709ac8bcc0
6
+ metadata.gz: 3a7e731e49a56746d8a0b60e7a867efa6f10c65e59ad785fed1dd0529e3f1ca748582f1c6e54867b3c25cf54fb553d05f3b5d4a915194815960868c1c0fda226
7
+ data.tar.gz: 3337ca2d8d85a4eabb170869097eded13b92404f5ea402bb70ef6b943946479784f8e46d0fa868a58498f9b0c52184958671050d3a4944ce3a7099a7e1a2f1c3
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,7 @@ module BlendSpreadsheetLoanGenerator
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
-
6
+
7
7
  def columns
8
8
  %w[
9
9
  index
@@ -33,6 +33,7 @@ module BlendSpreadsheetLoanGenerator
33
33
  capitalized_fees_end
34
34
  period_reimbursed_capitalized_fees
35
35
  period_fees_rate
36
+ period_reimbursed_guaranteed_interests
36
37
  ]
37
38
  end
38
39
 
@@ -53,6 +54,7 @@ module BlendSpreadsheetLoanGenerator
53
54
  capitalized_fees_start
54
55
  capitalized_fees_end
55
56
  period_reimbursed_capitalized_fees
57
+ period_reimbursed_guaranteed_interests
56
58
  ]
57
59
  end
58
60
 
@@ -12,6 +12,7 @@ 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
15
16
  option :duration, type: :integer, desc: 'duration'
16
17
  option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
17
18
  option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
@@ -43,6 +44,14 @@ module BlendSpreadsheetLoanGenerator
43
44
  values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
44
45
 
45
46
  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, -1).to_i } || nil
48
+ total_guaranteed_interests = (
49
+ if guaranteed_line.present? && guaranteed_line > last_paid_line
50
+ values[(last_paid_line + 1)..guaranteed_line].sum { |value| value[:period_calculated_interests] }
51
+ else
52
+ 0
53
+ end
54
+ )
46
55
 
47
56
  total_to_be_paid = (
48
57
  values[last_paid_line + 1][:remaining_capital_start] +
@@ -55,19 +64,21 @@ module BlendSpreadsheetLoanGenerator
55
64
  if total_to_be_paid == amount_paid
56
65
  1
57
66
  else
58
- values.last[:index] - values[last_paid_line][:index]
67
+ options.fetch(:duration, values.last[:index] - values[last_paid_line][:index])
59
68
  end
60
69
  )
61
70
 
62
- starting_capitalized_interests = 0.0
63
- starting_capitalized_fees = 0.0
64
-
65
71
  due_on = values[last_paid_line + 1][:due_on] + 1.month
66
72
 
67
73
  capital_paid = amount_paid.to_f - (
68
74
  values[last_paid_line + 1][:capitalized_interests_start] +
69
75
  values[last_paid_line + 1][:capitalized_fees_start]
70
76
  )
77
+ guaranteed_interests_paid = (
78
+ (capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start]) *
79
+ total_guaranteed_interests
80
+ )
81
+ capital_paid -= guaranteed_interests_paid
71
82
 
72
83
  @loan = Loan.new(
73
84
  amount: values[last_paid_line][:remaining_capital_end],
@@ -80,8 +91,8 @@ module BlendSpreadsheetLoanGenerator
80
91
  deferred: options.fetch(:deferred),
81
92
  type: options.fetch(:type),
82
93
  interests_type: options.fetch(:interests_type),
83
- starting_capitalized_interests: starting_capitalized_interests,
84
- starting_capitalized_fees: starting_capitalized_fees
94
+ starting_capitalized_interests: 0.0,
95
+ starting_capitalized_fees: 0.0
85
96
  )
86
97
 
87
98
  spreadsheet = session.create_spreadsheet(loan.name)
@@ -125,6 +136,9 @@ module BlendSpreadsheetLoanGenerator
125
136
  worksheet[2, columns.index('period_reimbursed_capitalized_fees') + 1] =
126
137
  excel_float(values[last_paid_line + 1][:capitalized_fees_start])
127
138
 
139
+ worksheet[2, columns.index('period_reimbursed_guaranteed_interests') + 1] =
140
+ excel_float(guaranteed_interests_paid)
141
+
128
142
  apply_formats(worksheet: worksheet)
129
143
 
130
144
  worksheet.save
@@ -164,6 +178,7 @@ module BlendSpreadsheetLoanGenerator
164
178
  h[:capitalized_fees_end] = h[:capitalized_fees_end].to_f
165
179
  h[:period_reimbursed_capitalized_fees] = h[:period_reimbursed_capitalized_fees].to_f
166
180
  h[:period_fees_rate] = h[:period_fees_rate].to_f
181
+ h[:period_reimbursed_guaranteed_interests] = h[:period_reimbursed_guaranteed_interests].to_f
167
182
 
168
183
  h
169
184
  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.14'.freeze
4
+ VERSION = '0.1.19'.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.14
4
+ version: 0.1.19
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-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport