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.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 7
4
+ :patch: 8
@@ -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
- @total_fees ||= calculate_total_fees
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
- total = self.fees + (self.loan_amount * points/100)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mortgage_calc}
5
- s.version = "0.1.7"
5
+ s.version = "0.1.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Perry Hertler"]
@@ -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 0 if total fees is less than 0" do
44
- @mortgage_util.send(:calculate_total_fees).should be 0
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortgage_calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perry Hertler