Skip to main content

Invoices — Id Edit

What it is

A deliberately small form for amending an invoice: its number, its dates, who it is billed to, and its lines. It saves header and lines together in one transaction, guarded against someone else having saved in the meantime.

Who can open it

Any signed-in staff account that is active. Two gates, both in proxy.ts: account status, then the finance.invoices feature grant while FEATURE_GRANULAR_RBAC is on, with the owner bypassing.

Before you start

About A2Z-F226, which the inventory used to mark BROKEN — "strips hsn_code, impa_code, tax cols, po_item_id on every save". That was true and has been fixed: migration 20260727200000_save_invoice_atomic_full_columns.sql widened the re-insert to carry every persisted column — gst_rate, hsn_code, line_total, po_item_id and sourced_from_dc_item_ids. (The impa_code in that note was never applicable: invoice_items has no such column.) Two caveats worth knowing anyway:

  • line_total is recalculated on save, as quantity × unit price, and never taken from the screen. Tax is held separately in the line's GST rate. So a line total that had been set by hand to something other than qty × price will be replaced.
  • ⚠️ A real save through this screen has still not been confirmed in production. The fix is proven against the database, not by a live save. If you are the first to use it, check the invoice's lines afterwards — and if the lines vanish, stop and report it rather than re-entering them.

This screen edits fewer fields than the invoice has. Only description, quantity and unit price are editable per line. Unit, GST rate and HSN code are preserved but not shown, so they cannot be corrected here. A line you add gets unit pcs, GST 0 and no HSN code — an unclassified line shows up as missing in the GSTR-1 HSN summary, which is the intended behaviour, but it does mean new lines need their classification set elsewhere.

Every control on the page

Top bar: ← Back to Invoices, the heading Edit Invoice, and Update Invoice to save.

A banner appears at the very top when someone else has this invoice open.

Header fields:

FieldNotes
Invoice #Free text.
DateThe invoice date.
Due DateDrives the overdue calculation on the list.
Bill ToOnly shown when the customer has alternate billing addresses on file. Choose The client's own address or one of them; the default one is marked.

🔒 Bill To is frozen once the invoice has been finalised. The control is disabled and says why: "Frozen at finalize — the invoice and its e-invoice already carry this party. Correct it with a credit note and a new invoice." Only that customer's own addresses are ever offered; the database refuses an invoice billed to a different customer's address.

Notes and payment terms are not editable here even though they are stored on the invoice. They are carried through the save unchanged.

Items tableDescription, Qty, Price (labelled with the invoice's currency), and to remove a row. + Add Row underneath. With no lines it reads "No items yet — use '+ Add Row' to enter one."

When an invoice has no lines of its own but came from a quotation, the quotation's lines are loaded in. Saving then writes them onto the invoice for the first time.

What it writes

ActionWhat it writes
Update InvoiceCalls save_invoice_atomic — the header and all lines in a single transaction, with the version you loaded as a guard. The existing lines are deleted and re-inserted from what is on screen.
Rows with an empty description are dropped, so a blank row you added never reaches the invoice or its tax totals.
Bill To is only sent when this invoice actually has a choice — not on a frozen invoice and not on one whose customer has no alternate addresses — so the stored value is left alone in those cases.

On success you are returned to the invoice list.

When it goes wrong

"Save failed. Please refresh and try again." Someone else saved this invoice after you opened it. Copy your changes, refresh, and re-apply them — the guard refuses rather than overwriting.

The Bill To dropdown is greyed out. The invoice is finalised. Correct it with a credit note and a new invoice, as the note under the control says.

There is no Bill To dropdown at all. The customer has no alternate billing addresses. Add them on the customer record first.

A line's unit or GST is wrong and there is no column for it. This screen does not expose them. They are preserved, not editable here.

A line total does not match what you typed. It is recalculated as quantity × unit price on every save.

Lines disappeared after saving. Stop and report it. That is the failure mode the widened re-insert was meant to end, and it has not yet been exercised live.