formulas 0.1.1 → 0.1.1.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05cc76051c2d5ff9889d39b8448fe5b1b5fabdb60703b9b4c1afd9a58aa72a87
|
4
|
+
data.tar.gz: 01213c4a728219396108c266d8b4398d28829140957c4fb7e957ee401e20fd51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 948b740e1a3e8965ab9991fdcf448081dfe896ff71fbd2f4f7fda2a98c356f37d2c741ef14ca19330168d5d93d211383659f1551fe0cc50b7bac74e5d5fde8bd
|
7
|
+
data.tar.gz: 8bc92d9ea8b509ce304afaeabfdf4db5d443d4a0a542ca8e4ffb34f71652fdec9f79941a3028df5096647a93c57c6c7937e6ea5d953fae82bb4fb8fe3e5e673a
|
data/formulas.gemspec
CHANGED
data/lib/formulas/salary.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Formulas
|
4
4
|
# Calculate basic salary in frequency
|
5
|
-
# salary = Formulas::Salary.new(
|
5
|
+
# salary = Formulas::Salary.new(pay: 52_000, Salary::ANNUAL)
|
6
6
|
#
|
7
7
|
# salary.pay(:monthly)
|
8
8
|
#
|
@@ -15,19 +15,19 @@ module Formulas
|
|
15
15
|
include FrequencyConversions
|
16
16
|
attr_reader :frequency
|
17
17
|
|
18
|
-
def initialize(
|
18
|
+
def initialize(pay:, frequency:)
|
19
19
|
invalid_frequency unless FREQUENCIES.include?(frequency)
|
20
|
-
raise ArgumentError, 'Gross pay must be numeric' unless Numeric ===
|
20
|
+
raise ArgumentError, 'Gross pay must be numeric' unless Numeric === pay
|
21
21
|
|
22
|
-
@
|
22
|
+
@pay = pay
|
23
23
|
@frequency = frequency
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def pay(request_frequency: @frequency)
|
27
27
|
invalid_frequency unless FREQUENCIES.include?(frequency)
|
28
|
-
return @
|
28
|
+
return @pay if @frequency == request_frequency
|
29
29
|
|
30
|
-
|
30
|
+
convert_pay_to(request_frequency).round(2)
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -36,8 +36,8 @@ module Formulas
|
|
36
36
|
raise ArgumentError, "Invalid frequency, frequency are: #{FREQUENCIES.join(', ')}"
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
send("convert_#{@frequency}_to_#{request_frequency}", @
|
39
|
+
def convert_pay_to(request_frequency)
|
40
|
+
send("convert_#{@frequency}_to_#{request_frequency}", @pay)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -21,7 +21,7 @@ module Formulas
|
|
21
21
|
|
22
22
|
def repayment
|
23
23
|
selected_base = @repayment_threshold[@salary.frequency]
|
24
|
-
less_base_cost = @salary.
|
24
|
+
less_base_cost = @salary.pay - selected_base[0]
|
25
25
|
((FIX_RATE * less_base_cost * selected_base[1]) / 12).round(2)
|
26
26
|
end
|
27
27
|
end
|
@@ -24,7 +24,7 @@ module Formulas
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def calculate(request_frequency: Formulas::ANNUALLY)
|
27
|
-
result = @salary.
|
27
|
+
result = @salary.pay(request_frequency: request_frequency) * (@super.to_f / 100)
|
28
28
|
result.round(2)
|
29
29
|
end
|
30
30
|
end
|