blend_spreadsheet_loan_generator 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bbb638c6b9da3b44d76b3c6bdcd25ff0c72c859e1f972e5f032b58e202bbb411
|
|
4
|
+
data.tar.gz: b104a0c811a1cc485a9914831db47e613af2a7f873aeffa0cb5dfc45859ba8b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af51b53a9b4073e41d898ee41d8ca6725b04ce50c16300d00f25a0867af0c3ce874290343ac66d3edb5e2096d7210b287b91b77640ce2cd1304557125146dc08
|
|
7
|
+
data.tar.gz: 22b8948a0826f7f184672a3a0741514f17a7f133f61c46f7699f73dcd78b27dccf31b0cd24cd531a946b6addc404b6e1ee4b72d24cd555cf2d00bcac6ab17238
|
|
@@ -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, nil) } || nil
|
|
48
|
+
total_guaranteed_interests = (
|
|
49
|
+
if guaranteed_line.present? && guaranteed_line > last_paid_line
|
|
50
|
+
values[last_paid_line..guaranteed_line].sum(: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] +
|
|
@@ -59,15 +68,17 @@ module BlendSpreadsheetLoanGenerator
|
|
|
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:
|
|
84
|
-
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)
|
|
@@ -98,7 +109,7 @@ module BlendSpreadsheetLoanGenerator
|
|
|
98
109
|
"=#{excel_float(values[last_paid_line][:remaining_capital_end])} - #{period_capital(2)}"
|
|
99
110
|
|
|
100
111
|
worksheet[2, columns.index('period_interests') + 1] =
|
|
101
|
-
"=ARRONDI(#{period_theoric_interests(2)}; 2)"
|
|
112
|
+
"=ARRONDI(#{period_theoric_interests(2)} + #{guaranteed_interests_paid}; 2)"
|
|
102
113
|
|
|
103
114
|
worksheet[2, columns.index('period_theoric_interests') + 1] =
|
|
104
115
|
"=#{excel_float(values[last_paid_line + 1][:period_calculated_interests])}"
|
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.16
|
|
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-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|