Skip to content

fix(dashboard): payment_overdue matches the finance page - #1183

Merged
waritctd merged 1 commit into
developfrom
fix/dashboard-payable-matches-finance
Oct 28, 2026
Merged

waritctd merged 1 commit into
developfrom
fix/dashboard-payable-matches-finance

Conversation

@waritctd

Copy link
Copy Markdown
Owner

What

The CEO/sales-manager dashboard's payment_overdue count used its own SQL: pre-VAT quotation total_amount, ACCEPTED quotations only (a confirmed DEAL_DIRECT APPROVED quotation was ignored), no issued-remaining-invoice branch, and the stored ticket.due_date. Paid amounts include VAT, so the count disagreed with the finance page.

  • TicketRepository.paymentOverduePredicate(ticketIdRef) (new, public static) is the one overdue rule: derived due date (quotation terms + delivery, owner ruling 2026-09-30) before Bangkok today, not DEPOSIT_NOTICE_ISSUED, and VAT-inclusive payable (payableAmountSelect, incl. fix(sales): UI-walk P0s + SK-02/SK-07 (owner rulings 2026-10-28) #1182's answered-quotation + issued-documents branches) minus paid > 0.
  • The account list scope and DashboardRepository.tickets() both call it. The dashboard's own payable/paid laterals are deleted.
  • Ploy's decision 2026-10-28: dashboard overdue follows finance fully, so the stored due_date no longer counts.

Test coverage (written first; 5/6 red before the fix, at the dashboard assertion)

DashboardPaymentOverdueMatchesFinanceIntegrationTest: each case asserts the dashboard count AND the finance summary's overdue.

  • owner-direct ACCEPTED 100,000, paid 100,000 (pre-VAT) → overdue (1)
  • same, paid 107,000 → not overdue (0) (guard; green before too)
  • confirmed DEAL_DIRECT quotation still APPROVED (promotion event), unpaid → 1
  • issued remaining invoice: deposit 32,100.00 + invoice 74,900.01, paid 107,000.00 → 1 (payable follows the issued documents)
  • stored due_date in the past, no quotation terms → 0
  • unpaid deposit (DEPOSIT_NOTICE_ISSUED) long after delivery → 0

DashboardRepositoryIntegrationTest: the paymentOverdue == 1 fixture is revised to a deal that is overdue under the finance rule.

Not covered on purpose: scope variants (scope filter unchanged, covered elsewhere); EN-document VAT (covered in FinancePayableVatAndDueIntegrationTest).

Verification

  • Targeted run on develop e5c3efd: Dashboard* (8 classes), FinancePayableVatAndDue (26), TicketRepository (35), TicketScope (31) — 120 tests, 0 failures.
  • Opus review: no correctness findings; account-scope SQL behaviourally identical; red check confirmed by reverting the main sources.

Follow-up (pre-existing, not in this PR)

frontend/src/api/mockApi.js (~3835) still derives mock overdue from the stored dueDate and doesn't exclude unpaid deposits.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
demo-glr Ready Ready Preview Oct 28, 2026 6:52pm UTC

Request Review

…usive payable, derived due date)

The dashboard computed what a deal owes with its own SQL: pre-VAT quotation total, ACCEPTED only,
no issued-remaining-invoice branch, and the stored due_date. It now calls
TicketRepository.paymentOverduePredicate, the one rule the account list scope also uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@waritctd
waritctd force-pushed the fix/dashboard-payable-matches-finance branch from b66ab2e to 00dc1a9 Compare October 28, 2026 18:52
@waritctd
waritctd merged commit d8a28f6 into develop Oct 28, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview — 00dc1a96 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant