moneyfunx 0.0.12 → 0.0.15
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.
- package/package.json +1 -1
- package/src/lib/payments.js +2 -2
package/package.json
CHANGED
package/src/lib/payments.js
CHANGED
|
@@ -53,7 +53,6 @@ export function amortizePayments (loan, payment, numPayments, startPeriod) {
|
|
|
53
53
|
return amortizationSchedule;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// TODO: What if this returns a list?
|
|
57
56
|
export function payLoans (loans, payment) {
|
|
58
57
|
let loanInterestTotals = {};
|
|
59
58
|
loans.map(
|
|
@@ -84,12 +83,12 @@ export function payLoans (loans, payment) {
|
|
|
84
83
|
firstLoan.principalRemaining(periodsElapsed)
|
|
85
84
|
);
|
|
86
85
|
loanInterestTotals[firstLoan.id].lifetimeInterest += firstLoanInterestPaid;
|
|
87
|
-
totalInterest += loanInterestTotals[firstLoan.id].lifetimeInterest;
|
|
88
86
|
loanInterestTotals[firstLoan.id].amortizationSchedule = [
|
|
89
87
|
...loanInterestTotals[firstLoan.id].amortizationSchedule,
|
|
90
88
|
...amortizePayments(firstLoan, firstLoanPayment, periodsToPay, periodsElapsed)
|
|
91
89
|
];
|
|
92
90
|
paidLoans += 1;
|
|
91
|
+
totalInterest += loanInterestTotals[firstLoan.id].lifetimeInterest;
|
|
93
92
|
loans.slice(paidLoans).map((loan) => {
|
|
94
93
|
loanInterestTotals[loan.id].lifetimeInterest += loan.interestPaid(
|
|
95
94
|
periodsToPay,
|
|
@@ -104,5 +103,6 @@ export function payLoans (loans, payment) {
|
|
|
104
103
|
periodsElapsed += periodsToPay;
|
|
105
104
|
}
|
|
106
105
|
loanInterestTotals["totalInterest"] = totalInterest;
|
|
106
|
+
loanInterestTotals["totalPayments"] = periodsElapsed;
|
|
107
107
|
return loanInterestTotals;
|
|
108
108
|
}
|