fix(loans): Pending EMI counts installments due as of this month - #37
Merged
Conversation
The column was showing the whole remaining term (12 for a freshly converted loan). It now counts unpaid installments due on or before the current month's end (IST) — carry-over from earlier months plus this month's — so it answers "how many EMIs does this member owe right now". Month-end rather than today's date is the cut-off, so an installment due on the 10th counts from the 1st instead of reading 0 for the first nine days of every month. - New endOfMonth() helper in lib/due.ts, with tests. - Both list pages derive todayIso once (it was computed twice) and pass the month-end cut-off to the count query. - Counts above 1 render amber with a tooltip, so a member falling behind is visible at a glance. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #36.
Problem
The Pending EMI column was counting every unpaid installment on the schedule — i.e. the remaining term. A loan converted at the cutover with a 12-month term read
12, which says nothing about what the member owes now.Change
It now counts unpaid installments (
scheduled+partially_paid+overdue) withdue_date <= last day of the current month (IST). That's carry-over from earlier months plus this month's installment. For the five converted loans today (06-08-2026, next EMI 10-08-2026) it reads1instead of12.Why month-end and not today's date: with a
due_date <= todaycut-off the column would read0for every loan for the first nine days of each month, since installments fall due on the 10th. Month-end makes "1" mean "one EMI to pay this month".src/lib/due.ts— newendOfMonth(iso)helper + 5 tests (leap year, 30/31-day months, idempotence at month end).todayIsoonce — it was being computed twice per render — and pass the month-end cut-off to the count query.Verification
npm run build✅tsc --noEmit✅npm run lint✅ (only the pre-existing_prevwarning inpending-interest-panel.tsx)npm test✅ 249 passed / 23 files (up from 244 — the 5 newendOfMonthcases)🤖 Generated with Claude Code