mortgage_calc 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Version.yml +1 -1
- data/lib/mortgage_calc/mortgage_util.rb +5 -5
- data/mortgage_calc.gemspec +1 -1
- data/spec/mortgage_calc/mortgage_util_spec.rb +8 -2
- metadata +1 -1
data/Version.yml
CHANGED
@@ -22,8 +22,10 @@ module MortgageCalc
|
|
22
22
|
@monthly_payment_with_fees ||= calculate_monthly_payment(self.loan_amount + total_fees, monthly_interest_rate, self.period)
|
23
23
|
end
|
24
24
|
|
25
|
-
def total_fees
|
26
|
-
|
25
|
+
def total_fees(negative_allowed = false)
|
26
|
+
#fees may not be negative (borrower is not paid)
|
27
|
+
total_fees = calculate_total_fees
|
28
|
+
!negative_allowed && total_fees < 0 ? 0 : total_fees
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
@@ -36,9 +38,7 @@ module MortgageCalc
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def calculate_total_fees
|
39
|
-
|
40
|
-
#fees may not be negative (borrower is not paid)
|
41
|
-
total < 0 ? 0 : total
|
41
|
+
self.fees + (self.loan_amount * points/100)
|
42
42
|
end
|
43
43
|
|
44
44
|
# solves APR
|
data/mortgage_calc.gemspec
CHANGED
@@ -40,8 +40,14 @@ module MortgageCalc
|
|
40
40
|
@mortgage_util = MortgageUtil.new(100000, 6.0, 360, 1200, -11.25)
|
41
41
|
@mortgage_util.total_fees.should be 0
|
42
42
|
end
|
43
|
-
it "calculate total fees should return
|
44
|
-
@mortgage_util.send(:calculate_total_fees).should
|
43
|
+
it "calculate total fees should return actual total fees is less than 0" do
|
44
|
+
@mortgage_util.send(:calculate_total_fees).should eql -10050.0
|
45
|
+
end
|
46
|
+
it "total fees should return 0 if total fees is less than 0" do
|
47
|
+
@mortgage_util.total_fees(false).should eql 0
|
48
|
+
end
|
49
|
+
it "total fees should return actual fees if negative parameter is true" do
|
50
|
+
@mortgage_util.total_fees(true).should eql -10050.0
|
45
51
|
end
|
46
52
|
it "should not return APR less than interest rate" do
|
47
53
|
@mortgage_util.apr.should be_close 6.0, 0.00000001
|