Skip to content

Commit f2de9e1

Browse files
committed
refinance saving
1 parent 897adee commit f2de9e1

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

server/src/main/scala/services/MortgageApiImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object MortgageApiImpl {
1616
}
1717

1818
def refinancePenalty(mortgage: Mortgage, newApr: Double): Double = {
19-
println(s"refinance($mortgage, $newApr)")
20-
0
19+
def totalInterest(m: Mortgage) = payments(m).map(_.interest).sum
20+
totalInterest(mortgage) - totalInterest(mortgage.copy(apr = newApr))
2121
}
2222
}

shared/src/main/scala/api/Mortgage.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ object Mortgage {
99
// TODO: Validator here
1010

1111
object API {
12-
val payments = new RPC[Mortgage, Seq[Payment]]("/mortgage/payments")
13-
val refinancePenalty = new RPC[(Mortgage, Double), Double]("/mortgage/refinance")
12+
val payments = new RPC[Mortgage, Seq[Payment]]("/mortgage/payments")
13+
val refinancePenalty = new RPC[(Mortgage, Double), Double]("/mortgage/refinance")
1414
}
1515
}
1616

web/src/main/scala/views/MortgageCalculator.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,12 @@ object MortgageCalculator extends framework.Page("mortgage_calculator") {
6565
).render)
6666
}
6767
}
68+
69+
70+
/*
71+
* Mon, Aug 28: FE (ScalaJs Tour) + FE Dependency management
72+
* Tue, Aug 29: RPC
73+
* Wed, Aug 30: BE: Server
74+
* Thu, Sep 1: BE: Shared
75+
* Fri, Sep 2: ScalaCSS + Tooling
76+
*/

0 commit comments

Comments
 (0)