loan_creator 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/loan_creator/borrower_timetable.rb +1 -1
- data/lib/loan_creator/common.rb +4 -4
- data/lib/loan_creator/timetable.rb +6 -6
- data/lib/loan_creator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b6daa216ea6263c492b90400a5885c6da2cf11
|
4
|
+
data.tar.gz: 5f583406fd970409e5e0c5c471006600a3f019dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2304c39a20bcc147c29f816be628f9cca6979763acb99287c49b526cf0ddb9120856ddec0f8e4ba3b16f431629e7749552a00997c3afeafd8f43e01a4a2cd9
|
7
|
+
data.tar.gz: a03687f04b2a9718c84027aae35b30d0d37e7a11a189d7e64a05b9d9c5f8251c1987e7e80c49250e91f0e3ef73712c842a674975be960aac286f124836677832
|
data/lib/loan_creator/common.rb
CHANGED
@@ -13,7 +13,7 @@ module LoanCreator
|
|
13
13
|
:period,
|
14
14
|
:amount,
|
15
15
|
:annual_interests_rate,
|
16
|
-
:
|
16
|
+
:starts_on,
|
17
17
|
:duration_in_periods
|
18
18
|
].freeze
|
19
19
|
|
@@ -65,7 +65,7 @@ module LoanCreator
|
|
65
65
|
@options[:period] = @options[:period].to_sym
|
66
66
|
@options[:amount] = bigd(@options[:amount])
|
67
67
|
@options[:annual_interests_rate] = bigd(@options[:annual_interests_rate])
|
68
|
-
@options[:
|
68
|
+
@options[:starts_on] = @options[:starts_on].strftime('%Y-%m-%d') if Date === @options[:starts_on]
|
69
69
|
end
|
70
70
|
|
71
71
|
def set_attributes
|
@@ -83,7 +83,7 @@ module LoanCreator
|
|
83
83
|
validate(:period) { |v| PERIODS_IN_MONTHS.keys.include?(v) }
|
84
84
|
validate(:amount) { |v| v.is_a?(BigDecimal) && v > 0 }
|
85
85
|
validate(:annual_interests_rate) { |v| v.is_a?(BigDecimal) && v >= 0 }
|
86
|
-
validate(:
|
86
|
+
validate(:starts_on) { |v| !!Date.parse(v) }
|
87
87
|
validate(:duration_in_periods) { |v| v.is_a?(Integer) && v > 0 }
|
88
88
|
validate(:deferred_in_periods) { |v| v.is_a?(Integer) && v >= 0 && v < duration_in_periods }
|
89
89
|
end
|
@@ -119,7 +119,7 @@ module LoanCreator
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def new_timetable
|
122
|
-
LoanCreator::Timetable.new(
|
122
|
+
LoanCreator::Timetable.new(starts_on: starts_on, period: period)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
@@ -9,11 +9,11 @@ module LoanCreator
|
|
9
9
|
year: { years: 1 }
|
10
10
|
}
|
11
11
|
|
12
|
-
attr_reader :terms, :
|
12
|
+
attr_reader :terms, :starts_on, :period
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(starts_on:, period:)
|
15
15
|
@terms = []
|
16
|
-
@
|
16
|
+
@starts_on = (Date === starts_on ? starts_on : Date.parse(starts_on))
|
17
17
|
raise ArgumentError.new(:period) unless PERIODS.keys.include?(period)
|
18
18
|
@period = period
|
19
19
|
end
|
@@ -28,7 +28,7 @@ module LoanCreator
|
|
28
28
|
|
29
29
|
def reset_indexes_and_due_on_dates
|
30
30
|
@autoincrement_index = 0
|
31
|
-
@autoincrement_date = @
|
31
|
+
@autoincrement_date = @starts_on
|
32
32
|
@terms.each do |term|
|
33
33
|
term[:index] = autoincrement_index
|
34
34
|
term[:due_on] = autoincrement_date
|
@@ -51,9 +51,9 @@ module LoanCreator
|
|
51
51
|
@autoincrement_index += 1
|
52
52
|
end
|
53
53
|
|
54
|
-
# First term due_on date of timetable term is the
|
54
|
+
# First term due_on date of timetable term is the starts_on given date
|
55
55
|
def autoincrement_date
|
56
|
-
@autoincrement_date ||= @
|
56
|
+
@autoincrement_date ||= @starts_on
|
57
57
|
date = @autoincrement_date
|
58
58
|
@autoincrement_date = @autoincrement_date.advance(PERIODS.fetch(@period))
|
59
59
|
date
|
data/lib/loan_creator/version.rb
CHANGED