fix: separate invoices from work orders + bottom page padding - #45
Merged
Merged
Conversation
|
🔥 Firebase Hosting preview: https://open-ten99--pr-45-q4m0ayj7.web.app |
2 tasks
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.
Domain rule (authoritative)
A
WorkItemthat has been sent out is an invoice, not a work order:invoiceSentDateis set, ORinvoiceStatus∈ {sent,paid,overdue}.WorkItemthat has not been sent out is a work order.No Firestore migration, no new collection. Reversible behavior change only.
invoiceSentDate/invoiceStatuswrite logic is unchanged. Quotes untouched.Fix 1 — Single-sourced membership
Shared predicate:
web/src/lib/workItem.tsisInvoice(item)=Boolean(invoiceSentDate) || invoiceStatus ∈ {sent,paid,overdue}isWorkOrder(item)=!isInvoice(item)web/src/lib/workItem.test.ts(7 tests).Views changed to use the shared predicate:
web/src/routes/contractor/WorkItems.tsx— Work Items list now excludes invoices (isWorkOrderat the top of the filter chain). Removed the now-nonsensical invoice-status sub-filter (state, URL paraminvoice, chip UI, options/labels, clear-all, active-count) since a work-orders list can't have sent/paid/overdue items.web/src/routes/contractor/Dashboard.tsx—pendingwidget (draft/inReview) andpipelineStagescounts now filter withisWorkOrder. Finance/invoice widgets (revenue, invoice counts) left unchanged.web/src/lib/finance.ts—getInvoicesByStatusandgetInvoiceStatusCountsnow derive membership from the sharedisInvoice(previously returned all billable non-archived items, which incorrectly included never-sent drafts). This single-sources the Invoices route (/dashboard/invoicesand/dashboard/finance/invoices— sameInvoicescomponent) so it shows ONLY invoices.web/src/lib/finance.test.ts— updatedgetInvoiceStatusCountstest to the corrected contract (never-sent billable items are work orders, excluded; a draft-status item that was sent still counts as a draft invoice).Not changed:
WorkItemDetailroute remains reachable for both (PR #44's section separation kept. GlobalSearch still finds everything (it's search, not a list). Invoice creation (NewInvoiceModal) reads directly and is unaffected.Fix 2 — Bottom-of-page padding
shared scroll container: → . Desktop content was flush against the viewport bottom ( zeroed it out). Mobile (clears bottom nav + safe area) and all top/side spacing unchanged. Fixed once in the shared layout, not per-page.
Test plan
RUN v4.1.6 /Users/devinwilson/Projects/open-ten99
❯ functions/lib/utils/categorize.test.js (0 test)
❯ functions/lib/utils/matching.test.js (0 test)
❯ functions/lib/utils/crypto.test.js (0 test)
❯ .claude/worktrees/agent-add3d974479af5b9c/web/src/lib/tests/invoiceBranding.test.ts (0 test)
Test Files 4 failed | 16 passed (20)
Tests 195 passed (195)
Start at 16:02:16
Duration 2.11s (transform 2.83s, setup 0ms, import 3.15s, tests 503ms, environment 2ms) → 66/66 pass (incl. 7 new predicate tests + updated finance test)
🤖 Generated with Claude Code
EOF
)