blend_spreadsheet_loan_generator 0.1.99 → 0.1.103

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: 565ddfb9ab9868bd0bc47ca82c3322b7a8a6fa2a5d1a519782bc3f985fa8e668
4
- data.tar.gz: 1877ad34ba609c03c59f2fabc81d9d91940df5e1194a3455d52d697bbb8d7c83
3
+ metadata.gz: a53645750943fd847c6d787a9bbc73f23982daa5793ecb37f92100167d905b9e
4
+ data.tar.gz: 895e30e96a23336012ca31e8f772f354efb8feb0670d612fa2ca068b5979444b
5
5
  SHA512:
6
- metadata.gz: 6db635662441108f44574b6b6f9eec16fe94e7394b324ab83213051b84e693391effb880db74e259c46fef54b7b74802adbcee34f95e648d23a20f37a0561f8a
7
- data.tar.gz: f79d314308aac20dd01f22e5a03f1eb6a47aa1dc87542c4b93ae903d3a5e2c1dad3183acf59c0b6826e0f4dbc4d3559909c3d7222d6373c96fc55793f55871cb
6
+ metadata.gz: bf34f63e6d2bcfe7c983f4a191fa12de929dc56cf859f54f3676a0a981b3a7d735e9499b89d3599094ff7294f0a7fd07ddc523ec32343b9c4dd08fef4b72f644
7
+ data.tar.gz: 741777ca11694b3330609ce0aefd11df91234af988091d23605b75a895387466f3a5bb48bae43acdd4da2648e30193a142962871570402a59e63f635221a066c
@@ -100,7 +100,7 @@ module BlendSpreadsheetLoanGenerator
100
100
  end
101
101
  loan.duration.times do |line|
102
102
  columns.each.with_index do |title, column|
103
- if first_term_skip && title.in?(custom_early_repayment)
103
+ if first_term_skip && title.in?(first_term_skip_columns)
104
104
  worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2, first_term_skip: true)
105
105
  else
106
106
  worksheet[line + 2, column + 1] = @formula.send("#{title}_formula", line: line + 2)
@@ -170,22 +170,20 @@ 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
173
174
  if loan.bullet_term?(term)
174
- index = (
175
- if first_term_skip
176
- index(line - 1)
177
- else
178
- index(line)
179
- end
180
- )
175
+ index = first_term_skip ? index(line - 1) : index(line)
176
+
181
177
  with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
182
178
  without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index}"
183
179
  current = "#{with_fees} - #{without_fees}"
184
180
 
185
181
  "=#{current} - #{capitalized_fees_start(line)}"
186
182
  elsif loan.deferred_and_capitalized > 0 && term > loan.deferred_and_capitalized
187
- with_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)} + #{period_fees_rate(line)})^#{loan.deferred_and_capitalized} * (#{period_rate(line)} + #{period_fees_rate(line)})"
188
- without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{loan.deferred_and_capitalized} * #{period_rate(line)}"
183
+ index = first_term_skip ? loan.deferred_and_capitalized : loan.deferred_and_capitalized - 1
184
+
185
+ with_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)} + #{period_fees_rate(line)})^#{index} * (#{period_rate(line)} + #{period_fees_rate(line)})"
186
+ without_fees = "#{remaining_capital_start(line)} * (1 + #{period_rate(line)})^#{index} * #{period_rate(line)}"
189
187
 
190
188
  "=#{with_fees} - #{without_fees}"
191
189
  else
@@ -209,6 +207,7 @@ module BlendSpreadsheetLoanGenerator
209
207
 
210
208
  def capitalized_fees_end_formula(line:, first_term_skip: false)
211
209
  term = line - 1
210
+ return excel_float(0.0) if first_term_skip
212
211
  if term <= loan.deferred_and_capitalized
213
212
  index = first_term_skip ? index(line - 1) : index(line)
214
213
  with_fees = "#{remaining_capital_start(line)} * (1 + #{period_fees_rate(line)} + #{period_rate(line)})^#{index}"
@@ -72,9 +72,9 @@ module BlendSpreadsheetLoanGenerator
72
72
  spreadsheet = session.create_spreadsheet(loan.name)
73
73
  worksheet = spreadsheet.add_worksheet(loan.type, loan.duration + 2, columns.count + 1, index: 0)
74
74
 
75
- @formula = Formula.new(loan: loan, first_term_skip: true)
75
+ @formula = Formula.new(loan: loan)
76
76
 
77
- apply_formulas(worksheet: worksheet)
77
+ apply_formulas(worksheet: worksheet, first_term_skip: true)
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.99'.freeze
4
+ VERSION = '0.1.103'.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.99
4
+ version: 0.1.103
5
5
  platform: ruby
6
6
  authors:
7
7
  - MZiserman