Skip to content

Add Invoice flow docs and refresh billing concept and reference for 3.1 - #79

Open
gauritejusa wants to merge 3 commits into
mainfrom
docs/invoice-flows
Open

Add Invoice flow docs and refresh billing concept and reference for 3.1#79
gauritejusa wants to merge 3 commits into
mainfrom
docs/invoice-flows

Conversation

@gauritejusa

Copy link
Copy Markdown

What this does

Documents the Invoice resource in the billing and accounts area for version 3.1: ten new flow documents, plus corrections and additions to the existing concept and reference pages.

Everything here is grounded in the code — care/emr/models/invoice.py, care/emr/resources/invoice/, care/emr/api/viewsets/invoice.py, care/security/permissions/invoice.py on the backend, and src/pages/Facility/billing/invoice/, src/components/Billing/Invoice/, src/types/billing/invoice/ on the frontend. Display labels were resolved through public/locale/en.json rather than guessed.

New flow documents

Under versioned_docs/version-3.1/flows/billing/invoice/, ordered as a user meets them:

# Flow Covers
1 View invoices List, patient filter, number search, status and creator filters, QR scan
2 Create an invoice Selecting billable charge items on an account, optional issue date, payment terms and note
3 Edit invoice details Draft only: issue date, payment terms, note
4 Edit the items on an invoice Draft only: add, edit, discount and remove line items
5 Issue an invoice Finalise the draft and snapshot the line items
6 Print an invoice Single and combined multi-invoice print
7 Record a payment against an invoice Issued only: payment methods, cash change, validation
8 Mark an invoice as balanced Close out a settled invoice, unpaid amount moves to the account
9 Lock and unlock an invoice Privileged action that hides the totals
10 Cancel an invoice Mark as cancelled or entered in error, with the active-payments warning

Registered in versioned_sidebars/version-3.1-sidebars.json under a new Billing → Invoice category, with matching _category_.json files. Without the sidebar entry the pages build but stay invisible.

Corrections to existing pages

Concept page. The Locking section was wrong. It said an issued invoice can be locked to freeze it against edits. In fact a lock applies at any status, does not change the status, hides the money (net and gross are reported as zero to every reader), and requires can_manage_locked_invoice even to open the invoice. Also added the permitted status transitions and clarified that the permission needed to cancel depends on the free-cancel period.

Reference page. It claimed invoice numbers are auto-generated "for return invoices". They are generated on every create when the client does not supply one. Corrected, and added the API endpoints with all six custom actions, filtering and ordering, the permission matrix with system roles, the status transition rules, and the INVOICE_FREE_CANCEL_PERIOD_MINUTES setting.

A note on permissions in the UI

The invoice screens do no permission gating — InvoiceShow.tsx never calls usePermissions, so Lock, Unlock and Cancel are shown to every user and only the server refuses. The docs describe what the server permits and deliberately do not claim the interface hides anything. The only real interface conditions are status-based: Edit Details, Edit Items, Add Charge Item and Issue Invoice appear only for a draft; Mark as balanced and Record Payment only for an issued invoice; Create Invoice only when the account is active and billable.

Scope

Version 3.1 only, by explicit decision. Version 3.0 is untouched. Refund invoices are excluded: they are generated automatically when a supply delivery return order completes, and have no user-facing flow.

Validation

  • npm run build passes for both locales, generating build and build/ml. All ten pages render in each.
  • Corruption scan over versioned_docs is clean: no tool-call leakage, no {#anchor} heading ids.
  • All relative .mdx links across the twelve touched documents resolve to files on disk: 0 broken.

Code issues found while researching, not fixed here

  1. No permission gating in the invoice UI, as described above.
  2. Typo in a user-visible error: "A Refund Ivoice is required for negative values" in care/emr/resources/invoice/sync_items.py.
  3. attach_account_to_invoice has no frontend caller and looks like dead code.
  4. Two confusingly similar print routes: /billing/invoice/:invoiceId/print and /billing/invoices/:invoiceIds/print.

Add ten flow documents for the Invoice resource under flows/billing/invoice:
view, create, edit details, edit items, issue, print, record payment, mark as
balanced, lock and unlock, and cancel. Register them in the 3.1 sidebar with
Billing and Invoice categories.

Correct the concept page: a lock applies at any status rather than only after
issue, it hides the totals, and it needs Can Manage Locked Invoice even to
read. Document the free-cancel period that decides whether cancelling needs
Can Write Invoice or Can Destroy Invoice, and add the permitted status
transitions.

Extend the reference page with the API endpoints and custom actions, filtering
and ordering, the permission matrix with roles, the status transition rules,
and the INVOICE_FREE_CANCEL_PERIOD_MINUTES setting. Correct the claim that
invoice numbers are generated only for return invoices; they are generated on
every create when the client does not supply one.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by Docs Reviewer for #79 · opus50 · 104.5 AIC · ⌖ 15.8 AIC · ⊞ 11K

Comment thread versioned_docs/version-3.1/flows/billing/invoice/create-invoice.mdx Outdated
Reorders sections to What it represents -> Lifecycle -> Refunds -> Locking -> How it connects -> Permissions -> Related, and simplifies the Lifecycle section by replacing the status-transition table and duplicate cancel-permission paragraph with a single terse prose paragraph, matching the Encounter concept page's style.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploying coredocs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 32a9016
Status: ✅  Deploy successful!
Preview URL: https://632fbf9b.coredocs.pages.dev
Branch Preview URL: https://docs-invoice-flows.coredocs.pages.dev

View logs

On the account screen (facility:account:show scope), i creates an invoice
and c adds credit. The doc incorrectly said c; corrected to i, matching
care_fe/src/config/keyboardShortcuts.json.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by Docs Reviewer for #79 · opus50 · 154.9 AIC · ⌖ 17 AIC · ⊞ 11K

Comments that could not be inline-anchored

versioned_sidebars/version-3.1-sidebars.json:84

Mirroring (checklist 11). This whole change lands in version-3.1 only. The shared conventions require versioned_docs/version-3.0 and version-3.1 to stay byte-identical, so the ten new flows, both _category_.json files, and the edits to concepts/billing/invoice.mdx and references/billing/invoice.mdx must be mirrored to versioned_docs/version-3.0/..., and this sidebar block added to versioned_sidebars/version-3.0-sidebars.json too. Without the 3.0 copies the flows are invisibl…

versioned_docs/version-3.1/concepts/billing/invoice.mdx:40

Permissions in plain words (checklist 5). A concept must not carry a permission slug in prose: can_manage_locked_invoice should read "a role with the permission to manage locked invoices". The slug belongs in the reference doc. The same applies to the sentence in the Locking section as a whole.

versioned_docs/version-3.1/flows/billing/invoice/issue-invoice.mdx:69

Display labels, not raw values (checklist 4), and layer discipline (checklist 3). A flow is strictly user-facing, so a "Stored value" column exposing draft / entered_in_error is reference-doc content. Drop the stored-value column and keep only the display labels, or drop the table and link the reference instead. The same table is repeated in mark-invoice-as-balanced.mdx (line 77) and lock-and-unlock-invoice.mdx (line 77) — remove it there too.

versioned_docs/version-3.1/flows/billing/invoice/issue-invoice.mdx:86

Layer discipline (checklist 3). "Call the cancel invoice API to cancel the invoice" is a backend error string naming an API — a flow must not mention API endpoints. Rewrite as user-facing guidance: "You cannot cancel an invoice with a status change. Use the cancel action — see Cancel an invoice." The same string appears in cancel-invoice.mdx line 90.

versioned_docs/version-3.1/flows/billing/invoice/lock-and-unlock-invoice.mdx:64

Template conformance (checklist 8). The flow template's sections are Overview, Pre-requisites, Permissions, Steps, Expected Outcome, Related — in that order. ## Lock rules is an invented section between Expected Outcome and Related. Fold these rules into the relevant steps or into Expected Outcome. Same issue for ## Status rules in issue-invoice.mdx (line 65) and mark-invoice-as-balanced.mdx (line 71), and ## Validation messages in record-invoice-payment.mdx (line 79).

versioned_docs/version-3.1/flows/billing/invoice/record-invoice-payment.mdx:231

Unverified as written: "Only a record that is active and complete counts towards the totals" describes internal record state, which is reference-layer detail (checklist 3) and is not visible to the user in this flow. Either drop it here and cover it in references/billing/payment-reconciliation.mdx, or cite where in ohcnetwork/care this filter is applied.

versioned_docs/version-3.1/flows/billing/invoice/record-invoice-payment.mdx:96

(Re-anchoring my previous note to the right line.) "Care creates a payment reconciliation record. Only a record that is active and complete counts towards the totals" is internal record state — reference-layer content per checklist 3, and not something the user sees in this flow. Drop it here, or cite the place in ohcnetwork/care where the filter is applied.

versioned_docs/version-3.1/flows/billing/invoice/record-invoice-payment.mdx:17

The Permissions table lists only Can Read Invoice and Can Manage Locked Invoice, so a reader cannot tell what permission actually lets them record the payment — the note below defers to another reference. Name the payment reconciliation write permission here in its display form (per checklist 5 and the flow template), traced from the payment reconciliation viewset's authorize methods in ohcnetwork/care.

versioned_docs/version-3.1/flows/billing/invoice/view-invoices.mdx:2

Review summary (my consolidated review body was submitted empty; posting it here).

A substantial, well-researched addition. Every keyboard shortcut I checked (i, b, r, p, o, e, Enter, Esc) matches care_fe/src/config/keyboardShortcuts.json. The flow sidebar was correctly updated by hand, slugs are kebab-case verb phrases, H1s are sentence case, and I found no corruption markers, {#...} ids or bare braces.

Main findings, each raised inline: (1) the whole change lands in …

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