feat(showcase): computed (expression) amount on invoice line#1638
Merged
Conversation
…ency Give showcase_invoice_line.amount an `expression` (quantity × unit_price). It stays a stored currency column — the server only treats `type: 'formula'` as computed, so the client-sent value is persisted and the parent Invoice.total summary still rolls it up — but the new line-item grid reads the expression to render Amount read-only and recompute it live as quantity/unit_price change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Why
Backs the spreadsheet-style line-item grid (objectui): the invoice line's Amount should be computed (
quantity × unit_price), read-only, and recomputed live as you type — not hand-typed.What
showcase_invoice_line.amountgainsexpression: 'record.quantity * record.unit_price'. It stays a storedcurrencycolumn on purpose:type: 'formula'fields as computed/virtual. Acurrencyfield with anexpressionkeeps a real DB column, is accepted/persisted from the client, and is not overwritten on read — so the parentInvoice.totalsummary (which aggregates stored columns) keeps rolling it up unchanged.expressionfrom metadata to render Amount read-only and recompute it client-side, then persists the computed value in the atomic batch.Verification
amount.expression = { dialect: 'cel', source: 'record.quantity * record.unit_price' }andamount.type = currency(writable).🤖 Generated with Claude Code