blend_spreadsheet_loan_generator 0.1.9 → 0.1.14

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: 66fa3389501501c3ba4841e8a860c6eee985125d428753fb7bae2b6434fd2527
4
- data.tar.gz: bce7e8497a6b967039b3a6b52d1292ce3e5d0e27e0710e6912116529187d4f71
3
+ metadata.gz: d479d818a0375938fac8af2b76798236b0acbdd1074613da808dded2b788af5a
4
+ data.tar.gz: 54d0a3866d06817a3170b878d6b1bd074300334c81ce9c185c463d06682228a4
5
5
  SHA512:
6
- metadata.gz: 38b9b0ab76e606d58df75ceedcef4220bf965372d645ced7f9c5fba35342c690f6a2bd52a0a87cff3696e7ba9156c601735236b3ae54926d6dc6b9af58cb58d7
7
- data.tar.gz: ba20c6e30bf6c7eaa3e3c776da4b3f9b0a1a60721e6c207aaec96e71bddfeea8937e88bcd81a34752764dc6b6643980bcc5ea10ffb4b087bd38bc1313e43c90d
6
+ metadata.gz: e29bcf2a06bb55675c1b9e5cc90457d23a60b23a7670908ac0361bc8be56cb4f7e4cbd762909f6d51d7092a06734f54a723db2da1a95396700090bb6a6af2572
7
+ data.tar.gz: 400f763cb728b85c541429b36d892f328d1fa19ef003b78ff06aa0ad0dbb60bc56b6f2bf59c951a5b00b2a9af2e479cb3bdb14802634c86c81afa6709ac8bcc0
@@ -27,3 +27,24 @@ module BlendSpreadsheetLoanGenerator
27
27
  end
28
28
  end
29
29
  end
30
+
31
+
32
+ def generate_csv(data:, name:)
33
+ CSV.open(name, 'wb') do |csv|
34
+ data.each do |datum|
35
+ row = []
36
+ datum.each.with_index do |value, index|
37
+ row << (
38
+ if index == 0
39
+ value.to_i
40
+ elsif index == 1
41
+ Date.parse(value).strftime('%m/%d/%Y')
42
+ else
43
+ value.gsub(',', '.').to_f
44
+ end
45
+ )
46
+ end
47
+ csv << row
48
+ end
49
+ end
50
+ end
@@ -3,6 +3,7 @@ module BlendSpreadsheetLoanGenerator
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
+
6
7
  def columns
7
8
  %w[
8
9
  index
@@ -12,6 +12,7 @@ module BlendSpreadsheetLoanGenerator
12
12
  argument :from_path, type: :string, required: true, desc: 'csv to restructure'
13
13
  argument :rate, type: :float, required: true, desc: 'year rate post restructuration'
14
14
 
15
+ option :duration, type: :integer, desc: 'duration'
15
16
  option :period_duration, type: :integer, default: 1, desc: 'duration of a period in months'
16
17
  option :due_on, type: :date, default: Date.today, desc: 'date of the pay day of the first period DD/MM/YYYY'
17
18
  option :deferred_and_capitalized, type: :integer, default: 0, desc: 'periods with no capital or interests paid'
@@ -94,16 +95,16 @@ module BlendSpreadsheetLoanGenerator
94
95
  excel_float(values[last_paid_line][:remaining_capital_end])
95
96
 
96
97
  worksheet[2, columns.index('remaining_capital_end') + 1] =
97
- "=#{excel_float(values[last_paid_line][:remaining_capital_end] - capital_paid)} - #{period_interests(2)} - #{period_fees(2)}"
98
+ "=#{excel_float(values[last_paid_line][:remaining_capital_end])} - #{period_capital(2)}"
98
99
 
99
100
  worksheet[2, columns.index('period_interests') + 1] =
100
101
  "=ARRONDI(#{period_theoric_interests(2)}; 2)"
101
102
 
102
103
  worksheet[2, columns.index('period_theoric_interests') + 1] =
103
- "=#{excel_float(values[last_paid_line + 1][:period_interests])} + #{period_calculated_interests(2)}"
104
+ "=#{excel_float(values[last_paid_line + 1][:period_calculated_interests])}"
104
105
 
105
106
  worksheet[2, columns.index('period_fees') + 1] =
106
- "=#{excel_float(values[last_paid_line + 1][:period_fees])} + #{period_calculated_fees(2)}"
107
+ "=#{excel_float(values[last_paid_line + 1][:period_calculated_fees])}"
107
108
 
108
109
  worksheet[2, columns.index('period_capital') + 1] =
109
110
  "=#{excel_float(capital_paid)} - #{period_interests(2)} - #{period_fees(2)}"
@@ -11,8 +11,7 @@ module BlendSpreadsheetLoanGenerator
11
11
  "=#{excel_float(loan.rate)} * ((#{period_leap_days(line)} / 366) + (#{period_non_leap_days(line)} / 365))"
12
12
  end
13
13
 
14
-
15
- def period_fees_rate_formula(*)
14
+ def period_fees_rate_formula(line:)
16
15
  "=#{excel_float(loan.fees_rate)} * ((#{period_leap_days(line)} / 366) + (#{period_non_leap_days(line)} / 365))"
17
16
  end
18
17
  end
@@ -1,7 +1,7 @@
1
1
  require 'dry/cli'
2
2
 
3
3
  module BlendSpreadsheetLoanGenerator
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.14'.freeze
5
5
 
6
6
  class Version < Dry::CLI::Command
7
7
  desc 'Print version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blend_spreadsheet_loan_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - MZiserman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-19 00:00:00.000000000 Z
11
+ date: 2021-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport