Skip to content

feat(backend): add pending invoice stats helper (#278) - #344

Open
Iker2522 wants to merge 1 commit into
Quittance-Labs:mainfrom
Iker2522:feat/issue-278-stats-pending-filter
Open

feat(backend): add pending invoice stats helper (#278)#344
Iker2522 wants to merge 1 commit into
Quittance-Labs:mainfrom
Iker2522:feat/issue-278-stats-pending-filter

Conversation

@Iker2522

Copy link
Copy Markdown

Closes #278

Implements isPendingInvoice(invoice) in a dedicated, conservative utility so dashboard stats classify pending invoices consistently across both storage backends.

Changes

  • backend/src/utils/stats-pending-filter.ts (new) — pure helper: only the exact literal status 'PENDING' counts as pending. Missing/null invoice, missing/empty/unknown status, and non-exact-case matches all correctly return false.
  • backend/tests/stats-pending-filter.test.ts (new) — fixture-backed unit tests covering PENDING, PAID, EXPIRED, CANCELLED, unknown status, empty string, missing status, null status, case mismatch, whitespace, and missing invoice (null/undefined).
  • backend/tests/fixtures/stats-pending-filter.fixture.ts (new) — named test cases for the above.
  • backend/src/storage/invoice-stats.ts — wired isPendingInvoice into calculateInvoiceStats, replacing the inline status === 'PENDING' check (minimal diff: 2 lines).

Verification

  • PR touches exactly the 4 paths listed in the issue
  • npx tsc --noEmit passes
  • Full backend suite: 177/177 tests passing (30 suites), including 15 new tests for this helper
  • English-only strings and comments.

Implement isPendingInvoice(invoice) in a dedicated utility so dashboard
stats classify pending invoices consistently across storage backends.

- backend/src/utils/stats-pending-filter.ts (new): pure, conservative
  classifier — only the exact literal status 'PENDING' counts as
  pending; null/undefined invoice, missing/empty/unknown status, and
  non-exact-case matches all return false.
- backend/tests/stats-pending-filter.test.ts (new): fixture-backed
  unit tests covering PENDING, PAID, EXPIRED, CANCELLED, unknown,
  empty, missing-status, null-status, case-mismatch, whitespace,
  and missing-invoice (null/undefined) cases, plus direct
  StoredInvoice-shaped edge cases.
- backend/tests/fixtures/stats-pending-filter.fixture.ts (new): named
  test cases for the above.
- backend/src/storage/invoice-stats.ts: wire isPendingInvoice into
  calculateInvoiceStats, replacing the inline status === 'PENDING'
  check (minimal diff).

Closes Quittance-Labs#278
@Iker2522

Copy link
Copy Markdown
Author

Submitting my own implementation as the officially assigned contributor for this issue (assigned via GrantFox).

  • backend/src/utils/stats-pending-filter.ts — isPendingInvoice(invoice), conservative: only the exact literal 'PENDING' counts as pending; null/undefined invoice, missing/empty/unknown status, and case mismatches all return false.
  • backend/tests/stats-pending-filter.test.ts + backend/tests/fixtures/stats-pending-filter.fixture.ts — 15 fixture-backed tests covering all four known statuses plus edge cases (missing/null/empty status, case sensitivity, whitespace, missing invoice).
  • backend/src/storage/invoice-stats.ts — wired with a minimal 2-line diff.

Touches exactly the 4 paths listed in the issue. Full backend suite passes: 177/177 tests, 30 suites.

I know there are other PRs open for this issue (#307, #343) from before the GrantFox assignment went through — happy to defer to whichever the maintainers prefer, just wanted my implementation available for review as well.

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.

feat(backend): add pending invoice stats helper

1 participant