blend_spreadsheet_loan_generator 0.1.102 → 0.1.106

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: bfe713bbe1e4e57601559e592fc0a5fc621b5e72e151bb100ac341c6e29b8690
4
- data.tar.gz: 409a0e1d8cc8a91926638577fb97d18794b25338c786547550f18dd849f525ef
3
+ metadata.gz: 3decf3ef46d2a7636475a1364d97c98089a323fafaa671f2aaf0741b665887a5
4
+ data.tar.gz: 612c00e81f10f7da63d2c780596b5b1a3a9c5f110a8fd3e7633574fe5d779c23
5
5
  SHA512:
6
- metadata.gz: 1b4e6474624e79661081ab0ef187b8518d22e8ba79a3840aa30d4b7ef111db9442a367902621358b70f4cd37579516e526551a4b7603a6100e158c1097baf668
7
- data.tar.gz: 3cb5ee2b57bf520c54ac42e35f43a33da737c1df2a6a2ea3714a2a34cb2e97a224d74f402dc797880f49773abd046885177fbd79af4be44505904703ac5f2358
6
+ metadata.gz: a249a15ffc47d20f3aea1ff65b9fe7708de9e439c214e9855b3092cfd866c6e3bf0080a14ba40fd0379b74d5e29289f138f5526e8a8184030c115d631b32b5e7
7
+ data.tar.gz: 9a2dfca3ff564d50acbda00a914019dfe9d68bc63379aa00684ceabcf24d4f83df04c03770abc4a3bc8c579f6c531c74832a43d95f994982314515a9d6ac5f08
@@ -80,19 +80,15 @@ module BlendSpreadsheetLoanGenerator
80
80
  due_on = values[last_paid_line + 1][:due_on] + 1.month
81
81
 
82
82
  capital_paid = amount_paid.to_f - (
83
- values[last_paid_line + 1][:capitalized_interests_start] +
84
- values[last_paid_line + 1][:capitalized_fees_start] +
85
- values[last_paid_line + 1][:period_calculated_interests] +
86
- values[last_paid_line + 1][:period_calculated_fees]
83
+ values[last_paid_line + 1][:capitalized_interests_end] +
84
+ values[last_paid_line + 1][:capitalized_fees_end]
87
85
  )
88
86
  capital_paid_for_ratio = amount_paid.to_f - (
89
- values[last_paid_line + 1][:capitalized_fees_start] +
90
- values[last_paid_line + 1][:period_calculated_fees]
87
+ values[last_paid_line + 1][:capitalized_fees_end]
91
88
  )
92
89
  remaining_capital_for_ratio = (
93
- values[last_paid_line + 1][:remaining_capital_start] +
94
- values[last_paid_line + 1][:capitalized_interests_start] +
95
- values[last_paid_line + 1][:period_calculated_interests]
90
+ values[last_paid_line + 1][:remaining_capital_end] +
91
+ values[last_paid_line + 1][:capitalized_interests_end]
96
92
  )
97
93
 
98
94
  ratio = options.fetch(:ratio, capital_paid_for_ratio.to_f / remaining_capital_for_ratio).to_f
@@ -170,6 +170,7 @@ module BlendSpreadsheetLoanGenerator
170
170
 
171
171
  def period_calculated_fees_formula(line:, first_term_skip: false)
172
172
  term = line - 1
173
+ return excel_float(0.0) if first_term_skip && term == 1
173
174
  if loan.bullet_term?(term)
174
175
  index = first_term_skip ? index(line - 1) : index(line)
175
176
 
@@ -179,7 +180,7 @@ module BlendSpreadsheetLoanGenerator
179
180
 
180
181
  "=#{current} - #{capitalized_fees_start(line)}"
181
182
  elsif loan.deferred_and_capitalized > 0 && term > loan.deferred_and_capitalized
182
- index = first_term_skip ? loan.deferred_and_capitalized : loan.deferred_and_capitalized - 1
183
+ index = first_term_skip ? loan.deferred_and_capitalized - 1 : loan.deferred_and_capitalized
183
184
 
184
185
  with_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)} + #{period_fees_rate(line)})^#{index} * (#{period_rate(line)} + #{period_fees_rate(line)})"
185
186
  without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index} * #{period_rate(line)}"
@@ -206,6 +207,7 @@ module BlendSpreadsheetLoanGenerator
206
207
 
207
208
  def capitalized_fees_end_formula(line:, first_term_skip: false)
208
209
  term = line - 1
210
+ return excel_float(0.0) if first_term_skip && term == 1
209
211
  if term <= loan.deferred_and_capitalized
210
212
  index = first_term_skip ? index(line - 1) : index(line)
211
213
  with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
@@ -74,7 +74,7 @@ module BlendSpreadsheetLoanGenerator
74
74
 
75
75
  @formula = Formula.new(loan: loan)
76
76
 
77
- apply_formulas(worksheet: worksheet, first_term_skip: true)
77
+ apply_formulas(worksheet: worksheet)
78
78
  apply_formats(worksheet: worksheet)
79
79
 
80
80
  worksheet.save
@@ -1,7 +1,7 @@
1
1
  require 'dry/cli'
2
2
 
3
3
  module BlendSpreadsheetLoanGenerator
4
- VERSION = '0.1.102'.freeze
4
+ VERSION = '0.1.106'.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.102
4
+ version: 0.1.106
5
5
  platform: ruby
6
6
  authors:
7
7
  - MZiserman