blend_spreadsheet_loan_generator 0.1.23 → 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: 97656de6803defd1af54366733c9f096f2a571fba89576b0a96ced269bfdebae
4
- data.tar.gz: 9b0036e1d46ae2835d7d1add57af17e18b29107a9b29e1f8e00dde54d86fef48
3
+ metadata.gz: 0473a465aaf8c05516fd8ed8eeff3009996f4afe3c9dbc5578df88fb4985a03a
4
+ data.tar.gz: a73d70c1cbfd2d2241dd2bc875750358bf6893914739b0b5efaf65271e8800f1
5
5
  SHA512:
6
- metadata.gz: 5ae85edc2da12b6d1689f33e7564486fad79968c51c5cbb8d3ffb998b2c563d544f5267dd3b3df5a869ac98bd28742d9ccd0e1908e0f8b186b0b7b04835edfc2
7
- data.tar.gz: 5896188fffc2c776cf8f9a8ba847c35f4848830ac8f1a893bc59a216e24a5f11b994d1e41dd4304fa15c38e1513ecd543721e22ba93e19ece033ed8021221744
6
+ metadata.gz: 55e0989827c375bc5f13d58c7bef7d7bf0024126f838997b7a5c669e5a4bb378020c4dff1d616b78f6686f3b3050bbba7a5132fd18385cf0aaa668d1e8fd09a6
7
+ data.tar.gz: 76cbd06e23b5250740ad087e08f4f61f22c6ae828e2ea1dec23559a2d55ae4bfbd5e1f7d72f81f0efa823ca3de7dd7dd86c2ca3c864fb68e7a7d7e4ee41a6bf8
@@ -44,7 +44,7 @@ module BlendSpreadsheetLoanGenerator
44
44
  values = f.to_a
45
45
  values.map! { |r| set_types([columns, r].transpose.to_h.with_indifferent_access) }
46
46
 
47
- 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
48
48
  guaranteed_line = values.index { |term| term[:index] == options.fetch(:guaranteed_terms, -1).to_i } || nil
49
49
  total_guaranteed_interests = (
50
50
  if guaranteed_line.present? && guaranteed_line > last_paid_line
@@ -65,7 +65,14 @@ module BlendSpreadsheetLoanGenerator
65
65
  if total_to_be_paid == amount_paid
66
66
  1
67
67
  else
68
- options.fetch(:duration, values.last[:index] - values[last_paid_line][:index])
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
+ )
69
76
  end
70
77
  )
71
78
 
@@ -87,8 +94,15 @@ module BlendSpreadsheetLoanGenerator
87
94
  )
88
95
  capital_paid -= guaranteed_interests_paid
89
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
+ )
90
104
  @loan = Loan.new(
91
- amount: values[last_paid_line][:remaining_capital_end],
105
+ amount: amount,
92
106
  duration: duration,
93
107
  rate: rate,
94
108
  fees_rate: options.fetch(:fees_rate),
@@ -1,7 +1,7 @@
1
1
  require 'dry/cli'
2
2
 
3
3
  module BlendSpreadsheetLoanGenerator
4
- VERSION = '0.1.23'.freeze
4
+ VERSION = '0.1.24'.freeze
5
5
 
6
6
  class Version < Dry::CLI::Command
7
7
  desc 'Print version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blend_spreadsheet_loan_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - MZiserman