blend_spreadsheet_loan_generator 0.1.10 → 0.1.15

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: 0370ac23d6c5d52915479f0b67229876dadd94dd008e9a75dc89133ab8ec1458
4
- data.tar.gz: b247e70b8ed42ded0f38a4d3a08167bd22dd0919d78800c25b9a31e24cc32664
3
+ metadata.gz: 41bd051665f94b48954cb0d2067a075a9740eb8da3e72b672be25a724ffdeee2
4
+ data.tar.gz: 17a1bbd4686e4a92a7da7720de63f71a5387455563e1853b1bce25508556187b
5
5
  SHA512:
6
- metadata.gz: 399755f2967363b2d2cfb30258188e8b7099dc3d45c4fb402203f1ddb86e7d933ca377fcd81cedeba296aa76e2b9871b835d6f422989a46f8fbf4168ff381b17
7
- data.tar.gz: 2630e0aa3ce6fb41e4c7fcbc18340105001a9a9744aa8f0e645455c5e8ba3237362ca653b544458d0310adb136fcfc8db37d776fd0e48f97ad6883a114455908
6
+ metadata.gz: '08a55ddabdf7e9b46f56a66cb6c9a2aafd02144a3776ad6ad575f90e922636c08a08448037941e16996ac5794cd51dc046e250a5c147dfa1e352f858fef78817'
7
+ data.tar.gz: 2ae1b8b409995fef289f60148cbdd73d44a9402664d5b894f2fc83f556bee1055f0bcd1eff56f085773b095cc173f09ca9529425517f6060b1b1f2d974b543fd
@@ -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'
@@ -54,7 +55,7 @@ module BlendSpreadsheetLoanGenerator
54
55
  if total_to_be_paid == amount_paid
55
56
  1
56
57
  else
57
- values.last[:index] - values[last_paid_line][:index]
58
+ options.fetch(:duration, values.last[:index] - values[last_paid_line][:index])
58
59
  end
59
60
  )
60
61
 
@@ -94,7 +95,7 @@ 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)"
@@ -103,7 +104,7 @@ module BlendSpreadsheetLoanGenerator
103
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.10'
4
+ VERSION = '0.1.15'.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.10
4
+ version: 0.1.15
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-20 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