loan_creator 0.12.0 → 0.12.1

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: 9a85f9d61c45df0f972e329a33a1beedbedc1e0090d481613e93ad90d66dea98
4
- data.tar.gz: 7dab891b9a5d3acefb8d6cd43eef0bdb5cfe511631f5674ae655046cda11ca25
3
+ metadata.gz: 2e7d8a7b39adf42e2c93e977c82ecf6c53f5695716cc5ef291a6b5a0963e0dd5
4
+ data.tar.gz: a4ed3fcf50360222a3795846d0d1ec3367126b851e6381a8ffbfc98ba972a709
5
5
  SHA512:
6
- metadata.gz: f92cd167e57a06b93169011fe8c178e7e3f434dc4c99c4a9458fb29501dd643d6011da2b8af7adfd94dd7412e7e0cd9566f281c5ff3331815daa2aa39bc27d58
7
- data.tar.gz: c21997ee861f81b7ad4a28b334f2f1d4258e2df54eb01865de79e0b30dae5abba1d4a6771055564a6e349d16ad07ea82e6aac57a3f35ef70fee07c9ba8f94f6a
6
+ metadata.gz: e6e6465cc26a14667894139cc4f57e1bab128ebd77a01559d2b04d1ba77b3aecc9c5ec457fe5ba7a1c1cea4ac9f7021fa6f26d16646f6241167ade85b9251d98
7
+ data.tar.gz: 144466496ce6a6b8895fca5657cf07db090e0ca8834b04ac84631a0dbfe71e89d8dfce2d8697358f905486edae636b1014cc049597c267fa0ec829088966d406
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ v0.12.1
2
+ -------------------------
3
+ #### Bugfix
4
+ - `Bullet` and `Uncapitalized Bullet` now manage roundings as other loan types
5
+
1
6
  v0.12.0
2
7
  -------------------------
3
8
  - improve argument error management and allow amount equal to zero.
@@ -33,16 +33,19 @@ module LoanCreator
33
33
  end
34
34
 
35
35
  def compute_capitalized_interests(timetable)
36
- if multi_part_interests_calculation && term_dates? && (timetable_term_dates[timetable.current_index] + 1.year) < @due_on
37
- multi_part_interests(
38
- timetable_term_dates[timetable.current_index],
39
- @due_on,
40
- annual_interests_rate,
41
- amount_to_capitalize
42
- )
43
- else
44
- compute_period_generated_interests(periodic_interests_rate(timetable_term_dates[timetable.current_index], @due_on))
45
- end
36
+ periodic_theoric_interests =
37
+ if multi_part_interests_calculation && term_dates? && (timetable_term_dates[timetable.current_index] + 1.year) < @due_on
38
+ multi_part_interests(
39
+ timetable_term_dates[timetable.current_index],
40
+ @due_on,
41
+ annual_interests_rate,
42
+ amount_to_capitalize
43
+ )
44
+ else
45
+ compute_period_generated_interests(periodic_interests_rate(timetable_term_dates[timetable.current_index], @due_on))
46
+ end
47
+
48
+ apply_interests_roundings(periodic_theoric_interests)
46
49
  end
47
50
 
48
51
  def compute_term(timetable)
@@ -295,5 +295,22 @@ module LoanCreator
295
295
  def amount_to_capitalize
296
296
  @crd_beginning_of_period + @due_interests_beginning_of_period
297
297
  end
298
+
299
+ def apply_interests_roundings(periodic_theoric_interests)
300
+ @period_theoric_interests = periodic_theoric_interests
301
+ @delta_interests = @period_theoric_interests - @period_theoric_interests.round(2)
302
+ @accrued_delta_interests += @delta_interests
303
+ @amount_to_add = bigd(
304
+ if @accrued_delta_interests >= bigd('0.01')
305
+ '0.01'
306
+ elsif @accrued_delta_interests <= bigd('-0.01')
307
+ '-0.01'
308
+ else
309
+ '0'
310
+ end
311
+ )
312
+ @accrued_delta_interests -= @amount_to_add
313
+ @period_theoric_interests.round(2) + @amount_to_add
314
+ end
298
315
  end
299
316
  end
@@ -28,7 +28,7 @@ module LoanCreator
28
28
  @crd_beginning_of_period = @crd_end_of_period
29
29
  @due_interests_beginning_of_period = @due_interests_end_of_period
30
30
 
31
- @period_theoric_interests = (
31
+ period_theoric_interests =
32
32
  # if period is more than a year
33
33
  if multi_part_interests_calculation && term_dates? && (timetable_term_dates[timetable.current_index] + 1.year) < @due_on
34
34
  multi_part_interests(
@@ -40,21 +40,8 @@ module LoanCreator
40
40
  else
41
41
  period_theoric_interests(periodic_interests_rate(timetable_term_dates[timetable.current_index], @due_on))
42
42
  end
43
- )
44
43
 
45
- @delta_interests = @period_theoric_interests - @period_theoric_interests.round(2)
46
- @accrued_delta_interests += @delta_interests
47
- @amount_to_add = bigd(
48
- if @accrued_delta_interests >= bigd('0.01')
49
- '0.01'
50
- elsif @accrued_delta_interests <= bigd('-0.01')
51
- '-0.01'
52
- else
53
- '0'
54
- end
55
- )
56
- @accrued_delta_interests -= @amount_to_add
57
- @period_interests = @period_theoric_interests.round(2) + @amount_to_add
44
+ @period_interests = apply_interests_roundings(period_theoric_interests)
58
45
  @period_capital = period_capital
59
46
  @total_paid_capital_end_of_period += @period_capital
60
47
  @total_paid_interests_end_of_period += @period_interests
@@ -27,20 +27,8 @@ module LoanCreator
27
27
  computed_periodic_interests_rate = periodic_interests_rate(timetable_term_dates[timetable.current_index], @due_on)
28
28
 
29
29
  @crd_beginning_of_period = @crd_end_of_period
30
- @period_theoric_interests = period_theoric_interests(@index, computed_periodic_interests_rate)
31
- @delta_interests = @period_theoric_interests - @period_theoric_interests.round(2)
32
- @accrued_delta_interests += @delta_interests
33
- @amount_to_add = bigd(
34
- if @accrued_delta_interests >= bigd('0.01')
35
- '0.01'
36
- elsif @accrued_delta_interests <= bigd('-0.01')
37
- '-0.01'
38
- else
39
- '0'
40
- end
41
- )
42
- @accrued_delta_interests -= @amount_to_add
43
- @period_interests = @period_theoric_interests.round(2) + @amount_to_add
30
+
31
+ @period_interests = apply_interests_roundings(period_theoric_interests(@index, computed_periodic_interests_rate))
44
32
  @period_capital = period_capital(@index, computed_periodic_interests_rate)
45
33
  @total_paid_capital_end_of_period += @period_capital
46
34
  @total_paid_interests_end_of_period += @period_interests
@@ -34,7 +34,8 @@ module LoanCreator
34
34
 
35
35
  def compute_interests(due_date, timetable)
36
36
  computed_periodic_interests_rate = periodic_interests_rate(timetable_term_dates[timetable.current_index], due_date)
37
- amount.mult(bigd(computed_periodic_interests_rate), BIG_DECIMAL_DIGITS)
37
+
38
+ apply_interests_roundings(amount.mult(bigd(computed_periodic_interests_rate), BIG_DECIMAL_DIGITS))
38
39
  end
39
40
 
40
41
  def compute_term(timetable)
@@ -1,3 +1,3 @@
1
1
  module LoanCreator
2
- VERSION = '0.12.0'.freeze
2
+ VERSION = '0.12.1'.freeze
3
3
  end
data/loan_creator.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'pry', '~> 0.13.1'
28
28
  spec.add_development_dependency 'table_print', '~> 1.5'
29
29
 
30
+
30
31
  spec.add_runtime_dependency 'bigdecimal'
31
32
  spec.add_runtime_dependency 'activesupport'
32
33
  end
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.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thibaulth
@@ -9,10 +9,10 @@ authors:
9
9
  - younes.serraj
10
10
  - Antoine Becquet
11
11
  - Jerome Drevet
12
- autorequire:
12
+ autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2022-07-12 00:00:00.000000000 Z
15
+ date: 2022-08-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -140,7 +140,7 @@ dependencies:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
- description:
143
+ description:
144
144
  email:
145
145
  - thibault@capsens.eu
146
146
  - nicolas.besnard@capsens.eu
@@ -188,7 +188,7 @@ homepage: https://github.com/CapSens/loan-creator
188
188
  licenses:
189
189
  - MIT
190
190
  metadata: {}
191
- post_install_message:
191
+ post_install_message:
192
192
  rdoc_options: []
193
193
  require_paths:
194
194
  - lib
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  requirements: []
206
206
  rubygems_version: 3.1.2
207
- signing_key:
207
+ signing_key:
208
208
  specification_version: 4
209
209
  summary: Create and update timetables from input data
210
210
  test_files: []