blend_spreadsheet_loan_generator 0.1.19 → 0.1.24
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0473a465aaf8c05516fd8ed8eeff3009996f4afe3c9dbc5578df88fb4985a03a
|
4
|
+
data.tar.gz: a73d70c1cbfd2d2241dd2bc875750358bf6893914739b0b5efaf65271e8800f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55e0989827c375bc5f13d58c7bef7d7bf0024126f838997b7a5c669e5a4bb378020c4dff1d616b78f6686f3b3050bbba7a5132fd18385cf0aaa668d1e8fd09a6
|
7
|
+
data.tar.gz: 76cbd06e23b5250740ad087e08f4f61f22c6ae828e2ea1dec23559a2d55ae4bfbd5e1f7d72f81f0efa823ca3de7dd7dd86c2ca3c864fb68e7a7d7e4ee41a6bf8
|
@@ -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'
|
@@ -43,7 +44,7 @@ module BlendSpreadsheetLoanGenerator
|
|
43
44
|
values = f.to_a
|
44
45
|
values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
|
45
46
|
|
46
|
-
last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i }
|
47
|
+
last_paid_line = values.index { |term| term[:index] == last_paid_term.to_i } || -1
|
47
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
|
@@ -64,7 +65,14 @@ module BlendSpreadsheetLoanGenerator
|
|
64
65
|
if total_to_be_paid == amount_paid
|
65
66
|
1
|
66
67
|
else
|
67
|
-
options.fetch(
|
68
|
+
options.fetch(
|
69
|
+
:duration,
|
70
|
+
if last_paid_line == -1
|
71
|
+
values.last[:index]
|
72
|
+
else
|
73
|
+
values.last[:index] - values[last_paid_line][:index]
|
74
|
+
end
|
75
|
+
)
|
68
76
|
end
|
69
77
|
)
|
70
78
|
|
@@ -74,14 +82,27 @@ module BlendSpreadsheetLoanGenerator
|
|
74
82
|
values[last_paid_line + 1][:capitalized_interests_start] +
|
75
83
|
values[last_paid_line + 1][:capitalized_fees_start]
|
76
84
|
)
|
85
|
+
actual_capital_paid = (
|
86
|
+
capital_paid -
|
87
|
+
values[last_paid_line + 1][:period_calculated_interests] -
|
88
|
+
values[last_paid_line + 1][:period_calculated_fees]
|
89
|
+
)
|
90
|
+
|
91
|
+
ratio = options.fetch(:ratio, (actual_capital_paid.to_f / values[last_paid_line + 1][:remaining_capital_start])).to_f
|
77
92
|
guaranteed_interests_paid = (
|
78
|
-
|
79
|
-
total_guaranteed_interests
|
93
|
+
ratio * total_guaranteed_interests
|
80
94
|
)
|
81
95
|
capital_paid -= guaranteed_interests_paid
|
82
96
|
|
97
|
+
amount = (
|
98
|
+
if last_paid_line == -1
|
99
|
+
values[0][:remaining_capital_end]
|
100
|
+
else
|
101
|
+
values[last_paid_line][:remaining_capital_end]
|
102
|
+
end
|
103
|
+
)
|
83
104
|
@loan = Loan.new(
|
84
|
-
amount:
|
105
|
+
amount: amount,
|
85
106
|
duration: duration,
|
86
107
|
rate: rate,
|
87
108
|
fees_rate: options.fetch(:fees_rate),
|
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.24
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|