From 526cb5fa3a00ad83395ccf94004dc90670b3e6eb Mon Sep 17 00:00:00 2001 From: Robert Dyer Date: Thu, 21 May 2026 17:07:17 -0500 Subject: [PATCH] support simple daily interest --- README.md | 4 +++- apply-interest.js | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2dcb485..1eb1e95 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,9 @@ interest transaction on the 28th of the month, set the account note to By default, interest is calculated using the 30/360 method where interest is computed monthly using 30/360 (or 1/12) of the interest rate. If you need to compute interest using the ACTUAL/ACTUAL method, set `interest:actual` in the -note. If you need to compute interest daily, set `interest:daily`. +note. If you need to compute interest daily, set `interest:daily`. For most +student loans, you probably want simple dailiy interest +`interest:daily-simple`. You can optionally change the payee used for the interest transactions by setting `INTEREST_PAYEE_NAME` in the `.env` file. diff --git a/apply-interest.js b/apply-interest.js index 50442a8..f2c0482 100644 --- a/apply-interest.js +++ b/apply-interest.js @@ -49,6 +49,7 @@ function daysInYear(year) { let numPeriods = 1 switch (kind) { case 'daily': + case 'daily-simple': period = daysInYear(interestTransactionDate.getFullYear()); numPeriods = daysPassed; break; @@ -60,7 +61,12 @@ function daysInYear(year) { } const balance = await getAccountBalance(account, interestTransactionDate); - const compoundedInterest = Math.round(balance * (Math.pow(1 + interestRate / period, numPeriods) - 1)); + + let compoundedInterest; + if (kind == 'daily-simple') + compoundedInterest = Math.round(balance * (interestRate / 365) * numPeriods); + else + compoundedInterest = Math.round(balance * (Math.pow(1 + interestRate / period, numPeriods) - 1)); interestRate = showPercent(interestRate);