loan_creator 0.11.0 → 0.12.0
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/loan_creator/common.rb +37 -15
- data/lib/loan_creator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a85f9d61c45df0f972e329a33a1beedbedc1e0090d481613e93ad90d66dea98
|
|
4
|
+
data.tar.gz: 7dab891b9a5d3acefb8d6cd43eef0bdb5cfe511631f5674ae655046cda11ca25
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f92cd167e57a06b93169011fe8c178e7e3f434dc4c99c4a9458fb29501dd643d6011da2b8af7adfd94dd7412e7e0cd9566f281c5ff3331815daa2aa39bc27d58
|
|
7
|
+
data.tar.gz: c21997ee861f81b7ad4a28b334f2f1d4258e2df54eb01865de79e0b30dae5abba1d4a6771055564a6e349d16ad07ea82e6aac57a3f35ef70fee07c9ba8f94f6a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
v0.12.0
|
|
2
|
+
-------------------------
|
|
3
|
+
- improve argument error management and allow amount equal to zero.
|
|
4
|
+
|
|
5
|
+
v0.11.0
|
|
6
|
+
-------------------------
|
|
7
|
+
- add `multi_part_interests_calculation` option.
|
|
8
|
+
|
|
9
|
+
v0.10.0
|
|
10
|
+
-------------------------
|
|
11
|
+
- fix `term_dates` options, notably with `starts_on`.
|
|
12
|
+
|
|
1
13
|
v0.9.1
|
|
2
14
|
-------------------------
|
|
3
15
|
- add spec importer `scripts/convert_export_to_spec.rb {csv_url}`
|
data/lib/loan_creator/common.rb
CHANGED
|
@@ -107,20 +107,34 @@ module LoanCreator
|
|
|
107
107
|
OPTIONAL_ATTRIBUTES.each { |k, v| instance_variable_set(:"@#{k}", @options.fetch(k, v)) }
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def validate(
|
|
111
|
-
raise unless block.call
|
|
112
|
-
rescue => e
|
|
113
|
-
raise ArgumentError.new([key, e.message].join(': '))
|
|
110
|
+
def validate(message, &block)
|
|
111
|
+
raise ArgumentError.new(message) unless block.call
|
|
114
112
|
end
|
|
115
113
|
|
|
116
114
|
def validate_attributes
|
|
117
|
-
validate(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
validate(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
validate("amount #{@amount} must be positive") do
|
|
116
|
+
@amount.is_a?(BigDecimal) && @amount >= 0
|
|
117
|
+
end
|
|
118
|
+
validate("annual_interests_rate #{@annual_interests_rate} must be positive") do
|
|
119
|
+
@annual_interests_rate.is_a?(BigDecimal) && @annual_interests_rate >= 0
|
|
120
|
+
end
|
|
121
|
+
validate("starts_on #{@starts_on} must be a date but is a #{@starts_on.class}") do
|
|
122
|
+
@starts_on.is_a?(Date)
|
|
123
|
+
end
|
|
124
|
+
validate("duration_in_periods #{@duration_in_periods} must be positive") do
|
|
125
|
+
@duration_in_periods.is_a?(Integer) && @duration_in_periods > 0
|
|
126
|
+
end
|
|
127
|
+
validate("deferred_in_periods #{@deferred_in_periods} must be positive and less than duration_in_periods #{@duration_in_periods}") do
|
|
128
|
+
@deferred_in_periods.is_a?(Integer) && @deferred_in_periods >= 0 && @deferred_in_periods < duration_in_periods
|
|
129
|
+
end
|
|
130
|
+
if term_dates?
|
|
131
|
+
validate_term_dates
|
|
132
|
+
else
|
|
133
|
+
validate("period #{@period} must be in #{PERIODS_IN_MONTHS}") do
|
|
134
|
+
PERIODS_IN_MONTHS.keys.include?(@period)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
124
138
|
end
|
|
125
139
|
|
|
126
140
|
def validate_term_dates
|
|
@@ -135,10 +149,18 @@ module LoanCreator
|
|
|
135
149
|
def validate_initial_values
|
|
136
150
|
return if initial_values.blank?
|
|
137
151
|
|
|
138
|
-
validate(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
validate(
|
|
152
|
+
validate("total_paid_capital_end_of_period #{@total_paid_capital_end_of_period} must be positive") do
|
|
153
|
+
@total_paid_capital_end_of_period.is_a?(BigDecimal) && @total_paid_capital_end_of_period >= 0
|
|
154
|
+
end
|
|
155
|
+
validate("total_paid_interests_end_of_period #{@total_paid_interests_end_of_period} must be positive") do
|
|
156
|
+
@total_paid_interests_end_of_period.is_a?(BigDecimal) && @total_paid_interests_end_of_period >= 0
|
|
157
|
+
end
|
|
158
|
+
validate("accrued_delta_interests must be a BigDecimal but is a #{@accrued_delta_interests.class}") do
|
|
159
|
+
@accrued_delta_interests.is_a?(BigDecimal)
|
|
160
|
+
end
|
|
161
|
+
validate("starting_index #{@starting_index} must be positive") do
|
|
162
|
+
@starting_index.is_a?(Integer) && @starting_index >= 0
|
|
163
|
+
end
|
|
142
164
|
end
|
|
143
165
|
|
|
144
166
|
def set_initial_values
|
data/lib/loan_creator/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: loan_creator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thibaulth
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: exe
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date:
|
|
15
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: bundler
|