An invoice form that shows its totals as you type
The form holds the client and dates, the lines and a note, with the base, the VAT per rate and the total to pay in a summary beside them that changes as you type. Choosing the client fills in its usual payment terms, and the due date is spelled out under the number of days. A draft has no number yet: an accountant gives it one when the invoice is issued.
By Bohuslav PoláčekChecked
What the screen shows
- Client and dates: the client picker with the company number, the address and the usual payment terms under it, New client below it, then the issue date and the payment terms in days with the due date spelled out under them.
- Lines: description, quantity, unit, unit price, VAT rate and the line's total without VAT, a button to remove the line, and Add line under the list.
- The summary: the base, the VAT per rate and the total to pay, in a card beside the fields from 1024px, changing as you type.
- The footer: Cancel and Save draft, sticky under the form. On a phone the summary moves under the fields and the total to pay sits beside the buttons, so the amount stays in view.
The rules behind the fields
One zod schema holds every rule and its message, and react-hook-form shows the errors after the first submit, then live as each one is fixed. A message says what to do ("Enter the quantity."), never "Invalid value". Required fields carry no asterisk and the one optional field, the note, is marked optional, because nearly everything here is required: Field takes requiredMark={false} and optional for exactly this case, and sets aria-required either way.
Choosing a client sets the payment terms, unless the person already typed their own. Leaving with unsaved changes asks first (Leave without saving?, with Leave and Stay) through the router's blocker and the kit's confirm, and a reload or a closed tab gets the browser's own question. A client who is not there yet is added in a dialog from the form and chosen at once.
Where the layout comes from
It is the kit's form archetype (Screen archetype="form", the form pattern). Given a summary, the frame widens to 960px and the summary becomes the side column. The fields, the summary and the footer are separate regions, so Save reaches the form element through its form attribute, and the only scroll is the Screen's.
The new invoice form is the form sample that e2e/screens.spec.ts opens at 1440 and 390, light and dark: the page itself never scrolls on a desktop, no scrolling region sits inside another, and axe finds nothing serious or critical.
What AI tools tend to get wrong here
A generated invoice form tends to put the total at the bottom of a long page, mark every field with a red asterisk, validate from the first keystroke and drop the lines when someone clicks away. It also tends to move the submit button into a sticky footer outside the form element, where it does nothing. Here the total stays in view on a desktop and on a phone, the messages wait for the first submit, the one optional field is the one marked, leaving asks first, and the button outside the form is tied to it with form.
The form's rules and their messages
| Field | Rule | Message |
|---|---|---|
| Client | Required | Choose a client. |
| Issue date | Required | Enter the issue date. |
| Due in (days) | A whole number from 0 to 120 | Enter the number of days. Enter a whole number. The payment terms cannot be negative. At most 120 days. |
| Note on the invoice | Optional, up to 500 characters | The note can have at most 500 characters. |
| Description | Required, up to 200 characters | Enter what is being invoiced. The description can have at most 200 characters. |
| Quantity | More than zero, up to 10,000 | Enter the quantity. Enter a quantity greater than zero. At most 10,000. |
| Unit | One of pcs, hrs, mo. and staff | Choose a unit. |
| Unit price | More than zero | Enter the price. Enter a price greater than zero. |
| VAT | One of the rates that exist | Choose a VAT rate. |
| Lines | At least one | Add at least one line. |
Questions
When do the error messages appear?
After the first press of Save, then live as each field is corrected. Each message says what to do, such as Enter the quantity.
Why do the required fields have no asterisk?
Nearly every field is required, so the form marks the exception instead: the note is marked optional. The kit's Field hides the asterisk with requiredMark set to false, shows the word with optional, and tells screen readers which fields are required either way.
What happens when I leave with unsaved changes?
The app asks first, Leave without saving?, with Leave and Stay. A reload or a closed tab gets the browser's own question.
Why does the draft have no number?
The number is given when an accountant issues the invoice, so a draft says No number yet in its header and in the crumbs.
How does the form work on a phone?
The summary moves under the fields and the total to pay sits in the sticky footer beside Cancel and Save draft, so the amount stays in view while you type.
Related
- An app for an accounting officeExample app
- The form screenPatterns
- A change order that shows its price before anyone approves itScreens
- A document inbox that catches a changed bank accountScreens
- A month close that knows what each step waits forScreens
- A packaging quote that works out its price as you typeScreens
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app