feat(backend): add pending invoice stats helper (#278) - #344
Open
Iker2522 wants to merge 1 commit into
Open
Conversation
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
Author
|
Submitting my own implementation as the officially assigned contributor for this issue (assigned via GrantFox).
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. |
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.
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 returnfalse.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— wiredisPendingInvoiceintocalculateInvoiceStats, replacing the inlinestatus === 'PENDING'check (minimal diff: 2 lines).Verification
npx tsc --noEmitpasses