@happyvertical/smrt-commerce 0.55.15 → 0.55.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/agents/invoice-calculations.md +28 -1
  2. package/agents/payment-allocations.md +19 -0
  3. package/dist/chunks/{calculations-DwBf83UE.js → calculations-Bz7RB3qK.js} +36 -2
  4. package/dist/chunks/calculations-Bz7RB3qK.js.map +1 -0
  5. package/dist/chunks/{units-BhVZswof.js → units-BpZ0_Dpk.js} +2 -2
  6. package/dist/chunks/{units-BhVZswof.js.map → units-BpZ0_Dpk.js.map} +1 -1
  7. package/dist/index.js +29 -8
  8. package/dist/index.js.map +1 -1
  9. package/dist/invoices.js +1 -1
  10. package/dist/manifest.json +1 -1
  11. package/dist/models/Invoice.d.ts +5 -3
  12. package/dist/models/Invoice.d.ts.map +1 -1
  13. package/dist/smrt-knowledge.json +5 -5
  14. package/dist/svelte/components/CustomerDetail.svelte +4 -1
  15. package/dist/svelte/components/CustomerDirectory.svelte +4 -1
  16. package/dist/svelte/components/CustomerForm.svelte +3 -0
  17. package/dist/svelte/components/InvoiceActions.svelte +4 -1
  18. package/dist/svelte/components/InvoiceAllocationFields.svelte +4 -1
  19. package/dist/svelte/components/InvoiceCard.svelte +12 -9
  20. package/dist/svelte/components/InvoiceEditor.svelte +7 -3
  21. package/dist/svelte/components/InvoiceEditor.svelte.d.ts.map +1 -1
  22. package/dist/svelte/components/InvoiceHeader.svelte +25 -22
  23. package/dist/svelte/components/InvoiceLineEditor.svelte +8 -1
  24. package/dist/svelte/components/InvoiceLineEditor.svelte.d.ts.map +1 -1
  25. package/dist/svelte/components/InvoiceLineItems.svelte +29 -26
  26. package/dist/svelte/components/InvoiceReview.svelte +4 -1
  27. package/dist/svelte/components/InvoiceTotals.svelte +14 -11
  28. package/dist/svelte/components/PartyAddressFields.svelte +3 -0
  29. package/dist/svelte/components/PartyContactFields.svelte +4 -1
  30. package/dist/svelte/components/PricingVersionDecision.svelte +4 -1
  31. package/dist/svelte/components/PricingVersionSummary.svelte +4 -1
  32. package/dist/svelte/components/PurchaseOrderEditor.svelte +4 -1
  33. package/dist/svelte/components/PurchaseOrderHeaderForm.svelte +1 -1
  34. package/dist/svelte/components/PurchaseSourceSelector.svelte +7 -2
  35. package/dist/svelte/components/QuoteEditor.svelte +4 -1
  36. package/dist/svelte/components/QuoteRevisionComparison.svelte +4 -1
  37. package/dist/svelte/components/QuoteRevisionHistory.svelte +4 -1
  38. package/dist/svelte/components/UnbilledItems.svelte +27 -24
  39. package/dist/svelte/components/VendorDetail.svelte +4 -1
  40. package/dist/svelte/components/VendorDirectory.svelte +4 -1
  41. package/dist/svelte/components/VendorForm.svelte +3 -0
  42. package/dist/svelte/invoices/calculations.d.ts +12 -3
  43. package/dist/svelte/invoices/calculations.d.ts.map +1 -1
  44. package/dist/svelte/invoices/calculations.js +40 -1
  45. package/dist/svelte/invoices/messages.d.ts +1 -0
  46. package/dist/svelte/invoices/messages.d.ts.map +1 -1
  47. package/dist/svelte/invoices/messages.js +1 -0
  48. package/dist/svelte/invoices/types.d.ts +3 -2
  49. package/dist/svelte/invoices/types.d.ts.map +1 -1
  50. package/dist/svelte/playground/InvoicePreparationPreview.svelte +6 -1
  51. package/dist/svelte/playground/PartySelectPreview.svelte +4 -1
  52. package/package.json +9 -9
  53. package/dist/chunks/calculations-DwBf83UE.js.map +0 -1
package/dist/invoices.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as resolveInvoiceLineDraft, n as calculateInvoiceLine, r as calculateInvoiceMinorLine, t as calculateInvoiceDraft } from "./chunks/calculations-DwBf83UE.js";
1
+ import { i as resolveInvoiceLineDraft, n as calculateInvoiceLine, r as calculateInvoiceMinorLine, t as calculateInvoiceDraft } from "./chunks/calculations-Bz7RB3qK.js";
2
2
  export { calculateInvoiceDraft, calculateInvoiceLine, calculateInvoiceMinorLine, resolveInvoiceLineDraft };
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-commerce",
5
- "packageVersion": "0.55.15",
5
+ "packageVersion": "0.55.17",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-commerce:ContractCollection": {
8
8
  "name": "contractcollection",
@@ -254,11 +254,13 @@ export declare class Invoice extends SmrtObject {
254
254
  * SENT → PAID is a structurally legal edge.
255
255
  *
256
256
  * Only enforced for the payment-derived statuses (PAID / PARTIAL and the
257
- * unpaid open states SENT / VIEWED). Lifecycle statuses that aren't a
258
- * function of amountPaid — DRAFT, OVERDUE, CANCELLED, WRITTEN_OFF — are left
257
+ * unpaid states DRAFT / SENT / VIEWED). Lifecycle statuses that aren't a
258
+ * function of amountPaid — OVERDUE, CANCELLED, WRITTEN_OFF — are left
259
259
  * to their own transition rules.
260
260
  */
261
261
  private assertPaymentStatusConsistent;
262
+ /** A payment reversal cannot erase an actual delivery event. */
263
+ private assertDraftDeliveryHistory;
262
264
  /**
263
265
  * Enforce `totalAmount === subtotal + taxAmount` exactly. Used when the
264
266
  * invoice has no line items to recompute from.
@@ -326,7 +328,7 @@ export declare class Invoice extends SmrtObject {
326
328
  * Update payment amount and status.
327
329
  *
328
330
  * Called when PaymentAllocations change. Handles both forward transitions
329
- * (SENT → PARTIAL → PAID) and reversals (PAID → PARTIAL → original status).
331
+ * (DRAFT/SENT → PARTIAL → PAID) and reversals (PAID → PARTIAL → original status).
330
332
  *
331
333
  * Terminal statuses (CANCELLED, WRITTEN_OFF) are not modified.
332
334
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Invoice.d.ts","sourceRoot":"","sources":["../../src/models/Invoice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,6BAA6B,CAAC;AAQ7E,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACn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WAAW;IAInB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAIvB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,6BAA6B;IAwCrC,gEAAgE;YAClD,0BAA0B;IAmBxC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,wBAAwB;IA2BhC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAiB9B;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,SAAS,IAAI,OAAO;IAMpB;;OAEG;IACH,YAAY,IAAI,MAAM;IAQtB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAmBhB;;;;;;;OAOG;IACH,UAAU,IAAI,IAAI;IAQlB;;;;;;;OAOG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAoC7C;;OAEG;IACH,MAAM,IAAI,IAAI;IASd;;OAEG;IACH,QAAQ,IAAI,IAAI;IAQhB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC;IAmG1E;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAiB7C;;;;;;;;;;;;;;;;;;;OAmBG;IACG,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAsC3D;AAED,eAAe,OAAO,CAAC"}
@@ -3,15 +3,15 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-commerce",
6
- "packageVersion": "0.55.15",
6
+ "packageVersion": "0.55.17",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "e38a26fbb921dfac665389a7d1fb4e65e00ba0840f65da003d9d882884fe0409",
11
- "packageJson": "bff099dbc9b6b2415bfb5f963b627f54b0d42a3addd19da0a23cabb1e730644d",
10
+ "manifest": "983906acad2c027023edf6bda224632b7eaa770f5767265089308997343a3dca",
11
+ "packageJson": "7b04148b9dfe3698d1e3b5743ef38d10601c4bf8dfc25aa66d6935ee793645e4",
12
12
  "agents": "5a4901577a0f007cf44f04658c4394e1b1fe292f24701d0ff00ccf66095b4217",
13
13
  "moduleDoc:agents/invoice-quantity.md": "bc3b617d4fb8cc87511763b281283107557ba64795e64522193ef967a3715d32",
14
- "moduleDoc:agents/payment-allocations.md": "eed7ea2cafe89fb59c1bb4a96ff71db4183b4bf6a06a49d4eb4a86f907458d78",
14
+ "moduleDoc:agents/payment-allocations.md": "46c0b921f0e40060cd1caec2dcefb01ed6612e31e4bf220a1a0b61e4e2a58212",
15
15
  "moduleDoc:agents/customer-vendor-ui.md": "1187b4d14e6bab661a2bb3312315239952dc955f90eceb177719f48dd0979150",
16
16
  "moduleDoc:agents/commercial-ui.md": "308729a481c82903d06837e7052c04509a92cf17d17345f71dce88d8d42d0431",
17
17
  "moduleDoc:agents/quote-ui.md": "514568e4e7815c47113627ac044a1f31a6933377b3f6c70f5d54b2508d94200c",
@@ -19843,7 +19843,7 @@
19843
19843
  {
19844
19844
  "path": "agents/payment-allocations.md",
19845
19845
  "module": "payment-allocations",
19846
- "content": "# Payment allocation integrity\n\n`PaymentAllocation.save()` owns the financial boundary for every direct or\ncollection write. Both payment and invoice must exist, belong to the same\nexact tenant (global is distinct), have the same customer and currency, and\nhave room for the positive safe-integer minor-unit amount. Zero-total invoices\nhave no room. Missing or zero-total invoice fixtures no longer bypass the cap.\nPending payments remain allocatable; this command does not establish settlement\nproof. Generated REST/MCP/CLI allocation writes remain closed. Applications\nmust authorize the actor before invoking these backend commands.\n\nUse `PaymentAllocationCollection.allocatePayment({ paymentId, allocations,\nallocatedBy })` for a split. Each allocation is `{ id, invoiceId, amount }`, with\na caller-generated stable UUID retained across retries. Exact replay\nreuses the existing rows without applying money again; an existing id with\ndifferent parents or amount fails. Replay preserves an already-paid invoice's\nrecorded payment date. Reversing\npayment clears that date; reaching full payment again records the new date.\nThe complete batch and invoice payment-status refresh share one transaction. Invoices must\nalready be in a status that permits payment (normally SENT); WRITTEN_OFF retains\nits terminal status. A failed leg rolls back every leg and parent revision.\nDirect allocation saves continue to leave status refresh to the caller. Allocation\nwrites advance both parent revisions: reload a previously held parent with\n`await parent.loadFromId()` before applying later edits or status refresh.\nStale parent saves continue to fail the core revision guard; no implicit\nrevision refresh bypasses another editor. In-package billing follows this rule.\n\nOnce inserted, allocation tenant/payment/invoice identity is immutable. Amount\ncorrections are capped against the other allocations. Parent saves reject\nchanges to tenant, customer, currency or amount that would invalidate committed\nallocations. A payment may be increased or reduced to its allocated total;\ninvoice totals continue to derive from persisted invoice lines where present.\nStandalone payments remain saveable when allocation storage has not been\nprovisioned. An existing allocation table always participates in validation;\nstorage probes and permission errors propagate instead of disabling the guard.\n\nAll participating writes bind collections to the owning transaction executor.\nThey claim parent revisions before reading balances. Concurrent writers can\nreceive a revision conflict or database serialization failure; reload and retry\nthe complete transaction with the same allocation ids. Never retry only the\nlast leg inside an already failed transaction. PostgreSQL Repeatable Read\nsnapshots fail closed through the same revision writes. SQLite serializes the\nowning write transaction. DuckDB is not a supported commerce allocation store:\nthe existing declared foreign keys require ON UPDATE CASCADE, which its DDL\nboundary explicitly refuses; no weaker schema is substituted.\n"
19846
+ "content": "# Payment allocation integrity\n\n`PaymentAllocation.save()` owns the financial boundary for every direct or\ncollection write. Both payment and invoice must exist, belong to the same\nexact tenant (global is distinct), have the same customer and currency, and\nhave room for the positive safe-integer minor-unit amount. Zero-total invoices\nhave no room. Missing or zero-total invoice fixtures no longer bypass the cap.\nPending payments remain allocatable; this command does not establish settlement\nproof. Generated REST/MCP/CLI allocation writes remain closed. Applications\nmust authorize the actor before invoking these backend commands.\n\nUse `PaymentAllocationCollection.allocatePayment({ paymentId, allocations,\nallocatedBy })` for a split. Each allocation is `{ id, invoiceId, amount }`, with\na caller-generated stable UUID retained across retries. Exact replay\nreuses the existing rows without applying money again; an existing id with\ndifferent parents or amount fails. Replay preserves an already-paid invoice's\nrecorded payment date. Reversing\npayment clears that date; reaching full payment again records the new date.\nThe complete batch and invoice payment-status refresh share one transaction. Invoices must\nalready be in a status that permits payment (normally SENT); WRITTEN_OFF retains\nits terminal status. A failed leg rolls back every leg and parent revision.\nDirect allocation saves continue to leave status refresh to the caller. Allocation\nwrites advance both parent revisions: reload a previously held parent with\n`await parent.loadFromId()` before applying later edits or status refresh.\nStale parent saves continue to fail the core revision guard; no implicit\nrevision refresh bypasses another editor. In-package billing follows this rule.\n\nOnce inserted, allocation tenant/payment/invoice identity is immutable. Amount\ncorrections are capped against the other allocations. Parent saves reject\nchanges to tenant, customer, currency or amount that would invalidate committed\nallocations. A payment may be increased or reduced to its allocated total;\ninvoice totals continue to derive from persisted invoice lines where present.\nStandalone payments remain saveable when allocation storage has not been\nprovisioned. An existing allocation table always participates in validation;\nstorage probes and permission errors propagate instead of disabling the guard.\n\nAll participating writes bind collections to the owning transaction executor.\nThey claim parent revisions before reading balances. Concurrent writers can\nreceive a revision conflict or database serialization failure; reload and retry\nthe complete transaction with the same allocation ids. Never retry only the\nlast leg inside an already failed transaction. PostgreSQL Repeatable Read\nsnapshots fail closed through the same revision writes. SQLite serializes the\nowning write transaction. DuckDB is not a supported commerce allocation store:\nthe existing declared foreign keys require ON UPDATE CASCADE, which its DDL\nboundary explicitly refuses; no weaker schema is substituted.\n\n### Undelivered invoice payment progress\n\nAllocation may move an undelivered DRAFT invoice to PARTIAL or PAID without a\ncustomer delivery event. Neither operation invents `sentAt` or `viewedAt`.\nAfter allocations are removed, reload the parent and call\n`updatePaymentStatus(remainingTotal)` and `save()` within the caller transaction.\nZero remaining allocations restore DRAFT only for an undelivered invoice;\na delivered invoice returns to SENT/VIEWED according to its delivery history.\nDRAFT cannot conceal positive allocations. A DRAFT save checks both its supplied\ndelivery timestamps and the currently persisted timestamps, so clearing them\nlocally during reversal cannot bypass the undelivered requirement. This guard\ndoes not introduce an immutable lifetime delivery-history record.\n\nIf a prepaid invoice is actually delivered later, call `markSent()` and save.\nFor PARTIAL/PAID invoices it records the first `sentAt` while preserving payment\nstatus, paid amount, paid date and any existing view timestamp. Repeating this\ncall preserves the first send timestamp. It records the caller's delivery\nevent; it does not send a customer message or manufacture earlier delivery.\n"
19847
19847
  },
19848
19848
  {
19849
19849
  "path": "agents/customer-vendor-ui.md",
@@ -99,7 +99,7 @@ function creditLimit(amountMinor: number): string {
99
99
  }
100
100
  </script>
101
101
 
102
- <section class="party-detail">
102
+ <section class="party-detail" data-smrt-component="CustomerDetail">
103
103
  {#if backHref}<Button href={backHref} variant="ghost">{t(M['commerce.party.back_to'], { plural })}</Button>{/if}
104
104
  <PageHeader title={customer.profile.name} subtitle={customer.profile.description ?? t(M['commerce.customer.details'])}>
105
105
  {#snippet actions()}
@@ -138,6 +138,8 @@ function creditLimit(amountMinor: number): string {
138
138
  </section>
139
139
 
140
140
  <style>
141
+ @layer smrt.reset, smrt.structure, smrt.theme;
142
+ @layer smrt.theme {
141
143
  .party-detail { display: grid; gap: var(--smrt-spacing-5); max-inline-size: 64rem; min-inline-size: 0; overflow-wrap: anywhere; }
142
144
  .summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--smrt-spacing-4); }
143
145
  h2 { margin: 0 0 var(--smrt-spacing-4); font: var(--smrt-typography-title-medium-font); color: var(--smrt-color-on-surface); }
@@ -147,4 +149,5 @@ function creditLimit(amountMinor: number): string {
147
149
  a { color: var(--smrt-color-primary); }
148
150
  .address, .notes { margin: 0; white-space: pre-wrap; }
149
151
  @media (max-width: 42rem) { .summary-grid { grid-template-columns: minmax(0, 1fr); } dl { grid-template-columns: minmax(0, 1fr); gap: var(--smrt-spacing-1); } dd { margin-block-end: var(--smrt-spacing-2); } }
152
+ }
150
153
  </style>
@@ -131,7 +131,7 @@ function customerTypeLabel(value: string | undefined): string {
131
131
  }
132
132
  </script>
133
133
 
134
- <section class="party-directory">
134
+ <section class="party-directory" data-smrt-component="CustomerDirectory">
135
135
  <PageHeader title={plural} subtitle={labels.plural ? t(M['commerce.party.manage_named'], { plural }) : t(M['commerce.customer.manage'])}>
136
136
  {#snippet actions()}
137
137
  {#if canCreate && addHref}<Button href={addHref}>{labels.add ?? (labels.singular ? t(M['commerce.party.add_named'], { singular }) : t(M['commerce.customer.add']))}</Button>{/if}
@@ -198,6 +198,8 @@ function customerTypeLabel(value: string | undefined): string {
198
198
  </section>
199
199
 
200
200
  <style>
201
+ @layer smrt.reset, smrt.structure, smrt.theme;
202
+ @layer smrt.theme {
201
203
  .party-directory { display: grid; gap: var(--smrt-spacing-5); max-inline-size: 64rem; min-inline-size: 0; }
202
204
  :global(.directory-search) { display: grid; grid-template-columns: minmax(12rem, 2fr) minmax(10rem, 1fr) auto; align-items: end; gap: var(--smrt-spacing-3); }
203
205
  :global(.directory-search .form-group) { margin: 0; min-inline-size: 0; }
@@ -211,4 +213,5 @@ function customerTypeLabel(value: string | undefined): string {
211
213
  .meta { margin-block-start: var(--smrt-spacing-2); color: var(--smrt-color-on-surface-variant); }
212
214
  .pagination { display: flex; align-items: center; justify-content: center; gap: var(--smrt-spacing-3); }
213
215
  @media (max-width: 42rem) { :global(.directory-search) { grid-template-columns: minmax(0, 1fr); } :global(.directory-search .button) { inline-size: 100%; } .party-row { align-items: start; } }
216
+ }
214
217
  </style>
@@ -222,6 +222,8 @@ const errorList = $derived(
222
222
  </Form>
223
223
 
224
224
  <style>
225
+ @layer smrt.reset, smrt.structure, smrt.theme;
226
+ @layer smrt.theme {
225
227
  :global(.party-form) { display: grid; gap: var(--smrt-spacing-5); min-inline-size: 0; padding-block-end: var(--smrt-spacing-8); }
226
228
  .native-default-submit { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
227
229
  .form-error { margin: 0; padding: var(--smrt-spacing-4); border-inline-start: 4px solid var(--smrt-color-error); background: var(--smrt-color-error-container); color: var(--smrt-color-on-error-container); border-radius: var(--smrt-radius-small); }
@@ -231,4 +233,5 @@ const errorList = $derived(
231
233
  .field-grid, .address-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--smrt-spacing-4); }
232
234
  .address-pair { gap: var(--smrt-spacing-4); }
233
235
  @media (max-width: 42rem) { .field-grid, .address-pair { grid-template-columns: minmax(0, 1fr); } }
236
+ }
234
237
  </style>
@@ -55,7 +55,7 @@ const canMarkPaid = $derived(
55
55
  const canDelete = $derived(status === 'draft');
56
56
  </script>
57
57
 
58
- <div class="invoice-actions">
58
+ <div class="invoice-actions" data-smrt-component="InvoiceActions">
59
59
  {#if canSend && onsend}
60
60
  <Button variant="primary" {size} onclick={onsend} disabled={loading}>
61
61
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5">
@@ -114,9 +114,12 @@ const canDelete = $derived(status === 'draft');
114
114
  </div>
115
115
 
116
116
  <style>
117
+ @layer smrt.reset, smrt.structure, smrt.theme;
118
+ @layer smrt.theme {
117
119
  .invoice-actions {
118
120
  display: flex;
119
121
  gap: var(--smrt-spacing-2, 0.5rem);
120
122
  flex-wrap: wrap;
121
123
  }
124
+ }
122
125
  </style>
@@ -33,7 +33,7 @@ const names = $derived({
33
33
  ...fields,
34
34
  });
35
35
  </script>
36
- <div class="allocations">
36
+ <div class="allocations" data-smrt-component="InvoiceAllocationFields">
37
37
  {#if !mayReadSources}<p>{t(M['commerce.preparation.restricted'])}</p>
38
38
  {:else if sources.length === 0}<p>{t(M['commerce.preparation.empty'])}</p>{/if}
39
39
  {#if allocations.length === 0}<p>{t(M['commerce.preparation.no_rows'])}</p>{/if}
@@ -66,7 +66,10 @@ const names = $derived({
66
66
  {#if canEdit}<Button type="submit" name={names.intent} value={addIntent} formnovalidate disabled={pending} variant="secondary">{t(M['commerce.preparation.add'])}</Button>{/if}
67
67
  </div>
68
68
  <style>
69
+ @layer smrt.reset, smrt.structure, smrt.theme;
70
+ @layer smrt.theme {
69
71
  .allocations { display: grid; gap: var(--smrt-spacing-4); min-width: 0; }
70
72
  fieldset { min-width: 0; margin: 0; padding: var(--smrt-spacing-4); border: 1px solid var(--smrt-color-outline); border-radius: var(--smrt-radius-small); }
71
73
  p { margin: 0; }
74
+ }
72
75
  </style>
@@ -107,7 +107,7 @@ const isOverdue = $derived.by(() => {
107
107
  </script>
108
108
 
109
109
  {#if href}
110
- <a class="invoice-card" {href} use:ripple>
110
+ <a class="invoice-card" {href} use:ripple data-smrt-component="InvoiceCard">
111
111
  <div class="card-header">
112
112
  <span class="invoice-number">{invoice.invoiceNumber}</span>
113
113
  <span class="status-badge {isOverdue ? 'status-error' : statusClass}">
@@ -133,7 +133,7 @@ const isOverdue = $derived.by(() => {
133
133
  {#if retained}{@render details?.(retained)}{/if}
134
134
  </a>
135
135
  {:else if retained}
136
- <article class="invoice-card">
136
+ <article class="invoice-card" data-smrt-component="InvoiceCard">
137
137
  <div class="card-header">
138
138
  <span class="invoice-number">{invoice.invoiceNumber}</span>
139
139
  <span class="status-badge {statusClass}">{retained.statusLabel}</span>
@@ -150,7 +150,7 @@ const isOverdue = $derived.by(() => {
150
150
  </article>
151
151
  {:else}
152
152
  <!-- raw-primitive-allow: large pressable invoice card wrapping rich header/body/footer content with use:ripple, a structural selection control no Button primitive should own (mirrors the href anchor branch) -->
153
- <button type="button" class="invoice-card" onclick={onclick} use:ripple>
153
+ <button type="button" class="invoice-card" onclick={onclick} use:ripple data-smrt-component="InvoiceCard">
154
154
  <div class="card-header">
155
155
  <span class="invoice-number">{invoice.invoiceNumber}</span>
156
156
  <span class="status-badge {isOverdue ? 'status-error' : statusClass}">
@@ -177,13 +177,15 @@ const isOverdue = $derived.by(() => {
177
177
  {/if}
178
178
 
179
179
  <style>
180
+ @layer smrt.reset, smrt.structure, smrt.theme;
181
+ @layer smrt.theme {
180
182
  .invoice-card {
181
183
  display: flex;
182
184
  flex-direction: column;
183
- gap: var(--smrt-spacing-3, 12px);
184
- padding: var(--smrt-spacing-4, 16px);
185
+ gap: var(--smrt-spacing-3);
186
+ padding: var(--smrt-spacing-4);
185
187
  background-color: var(--smrt-color-surface-container-low);
186
- border-radius: var(--smrt-radius-large, 12px);
188
+ border-radius: var(--smrt-radius-large);
187
189
  text-decoration: none;
188
190
  color: var(--smrt-color-on-surface);
189
191
  cursor: pointer;
@@ -223,12 +225,12 @@ const isOverdue = $derived.by(() => {
223
225
 
224
226
  .status-badge {
225
227
  display: inline-flex;
226
- padding: 0 var(--smrt-spacing-2, 8px);
228
+ padding: 0 var(--smrt-spacing-2);
227
229
  height: 20px;
228
230
  align-items: center;
229
231
  font: var(--smrt-typography-label-small-font);
230
232
  font-weight: var(--smrt-typography-weight-semibold, 600);
231
- border-radius: var(--smrt-radius-full, 10px);
233
+ border-radius: var(--smrt-radius-full);
232
234
  text-transform: uppercase;
233
235
  letter-spacing: 0.5px;
234
236
  }
@@ -254,7 +256,7 @@ const isOverdue = $derived.by(() => {
254
256
  .card-body {
255
257
  display: flex;
256
258
  flex-direction: column;
257
- gap: var(--smrt-spacing-1, 4px);
259
+ gap: var(--smrt-spacing-1);
258
260
  }
259
261
 
260
262
  .customer-name {
@@ -282,4 +284,5 @@ const isOverdue = $derived.by(() => {
282
284
  color: var(--smrt-color-error);
283
285
  font-weight: var(--smrt-typography-weight-semibold, 600);
284
286
  }
287
+ }
285
288
  </style>
@@ -30,6 +30,7 @@ let {
30
30
  id,
31
31
  title,
32
32
  values,
33
+ roundingScope = 'line',
33
34
  customers = [],
34
35
  errors = {},
35
36
  fields = {},
@@ -57,7 +58,7 @@ const busy = $derived(
57
58
  pending || retryStatus === 'submitting' || retryStatus === 'busy',
58
59
  );
59
60
  let draft = $derived(values);
60
- const calculation = $derived(calculateInvoiceDraft(draft));
61
+ const calculation = $derived(calculateInvoiceDraft(draft, { roundingScope }));
61
62
  function refresh(event: Event) {
62
63
  const data = new FormData(event.currentTarget as HTMLFormElement);
63
64
  const text = (name: string) => String(data.get(name) ?? '');
@@ -85,7 +86,7 @@ function lineErrors(key: string) {
85
86
  ) as Partial<Record<keyof InvoiceLineFieldNames, string>>;
86
87
  }
87
88
  </script>
88
- <section class="invoice-editor" aria-labelledby={`${formId}-title`}>
89
+ <section class="invoice-editor" aria-labelledby={`${formId}-title`} data-smrt-component="InvoiceEditor">
89
90
  <h2 id={`${formId}-title`}>{title ?? t(M['commerce.preparation.title'])}</h2>
90
91
  {#if review}<InvoiceReview {review} />{/if}
91
92
  {#if !canEdit}<p>{t(M['commerce.preparation.readonly'])}</p>{/if}
@@ -111,7 +112,7 @@ function lineErrors(key: string) {
111
112
  </fieldset>
112
113
  {#if draft.lines.length === 0}<p>{t(M['commerce.invoice.empty'])}</p>{/if}
113
114
  {#each draft.lines as line, index (line.key)}
114
- <InvoiceLineEditor {line} currency={draft.currency} inheritedTaxRate={draft.taxRate} number={index + 1} id={`${formId}-line-${index}`} fields={rowNames} errors={lineErrors(line.key)} {canEdit} pending={busy} intentField={names.intent} {removePrefix} />
115
+ <InvoiceLineEditor {line} {roundingScope} currency={draft.currency} inheritedTaxRate={draft.taxRate} number={index + 1} id={`${formId}-line-${index}`} fields={rowNames} errors={lineErrors(line.key)} {canEdit} pending={busy} intentField={names.intent} {removePrefix} />
115
116
  {/each}
116
117
  {#if canEdit}<Button type="submit" name={names.intent} value={addIntent} formnovalidate disabled={busy} variant="secondary">{t(M['commerce.invoice.add'])}</Button>{/if}
117
118
  <div aria-live="polite" class="summary">
@@ -126,9 +127,12 @@ function lineErrors(key: string) {
126
127
  </Form>
127
128
  </section>
128
129
  <style>
130
+ @layer smrt.reset, smrt.structure, smrt.theme;
131
+ @layer smrt.theme {
129
132
  .invoice-editor, .fields, .header-fields { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--smrt-spacing-4); min-width: 0; }
130
133
  .invoice-editor { max-width: 48rem; overflow-wrap: anywhere; }
131
134
  .header-fields { margin: 0; padding: 0; border: 0; }
132
135
  h2, p, dl, dd { margin: 0; }
133
136
  .summary dl { display: flex; flex-wrap: wrap; gap: var(--smrt-spacing-4); }
137
+ }
134
138
  </style>
@@ -1 +1 @@
1
- {"version":3,"file":"InvoiceEditor.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/InvoiceEditor.svelte.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAI9B,6FAA6F;AAC7F,MAAM,WAAW,KAAM,SAAQ,kBAAkB;CAAG;AAsHpD,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"InvoiceEditor.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/InvoiceEditor.svelte.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAI9B,6FAA6F;AAC7F,MAAM,WAAW,KAAM,SAAQ,kBAAkB;CAAG;AAuHpD,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
@@ -78,33 +78,33 @@ const statusConfig: Record<
78
78
  > = {
79
79
  draft: {
80
80
  label: 'Draft',
81
- bg: 'var(--smrt-color-surface-variant, #e7e0ec)',
82
- text: 'var(--smrt-color-on-surface-variant, #49454f)',
81
+ bg: 'var(--smrt-color-surface-variant)',
82
+ text: 'var(--smrt-color-on-surface-variant)',
83
83
  },
84
84
  sent: {
85
85
  label: 'Sent',
86
- bg: 'var(--smrt-color-primary-container, #d3e3fd)',
87
- text: 'var(--smrt-color-on-primary-container, #041e49)',
86
+ bg: 'var(--smrt-color-primary-container)',
87
+ text: 'var(--smrt-color-on-primary-container)',
88
88
  },
89
89
  viewed: {
90
90
  label: 'Viewed',
91
- bg: 'var(--smrt-color-secondary-container, #e3e0f9)',
92
- text: 'var(--smrt-color-on-secondary-container, #1d192b)',
91
+ bg: 'var(--smrt-color-secondary-container)',
92
+ text: 'var(--smrt-color-on-secondary-container)',
93
93
  },
94
94
  paid: {
95
95
  label: 'Paid',
96
- bg: 'var(--smrt-color-tertiary-container, #ddf5e5)',
97
- text: 'var(--smrt-color-on-tertiary-container, #0c1f15)',
96
+ bg: 'var(--smrt-color-tertiary-container)',
97
+ text: 'var(--smrt-color-on-tertiary-container)',
98
98
  },
99
99
  overdue: {
100
100
  label: 'Overdue',
101
- bg: 'var(--smrt-color-error-container, #ffdad6)',
102
- text: 'var(--smrt-color-on-error-container, #410002)',
101
+ bg: 'var(--smrt-color-error-container)',
102
+ text: 'var(--smrt-color-on-error-container)',
103
103
  },
104
104
  cancelled: {
105
105
  label: 'Cancelled',
106
- bg: 'var(--smrt-color-error-container, #ffdad6)',
107
- text: 'var(--smrt-color-error, #ba1a1a)',
106
+ bg: 'var(--smrt-color-error-container)',
107
+ text: 'var(--smrt-color-error)',
108
108
  },
109
109
  };
110
110
 
@@ -124,7 +124,7 @@ const isOverdue = $derived.by(() => {
124
124
  });
125
125
  </script>
126
126
 
127
- <div class="invoice-header">
127
+ <div class="invoice-header" data-smrt-component="InvoiceHeader">
128
128
  <div class="header-main">
129
129
  <div class="invoice-title">
130
130
  <h2 class="invoice-number">{invoiceNumber}</h2>
@@ -184,14 +184,16 @@ const isOverdue = $derived.by(() => {
184
184
  </div>
185
185
 
186
186
  <style>
187
+ @layer smrt.reset, smrt.structure, smrt.theme;
188
+ @layer smrt.theme {
187
189
  .invoice-header {
188
190
  display: flex;
189
191
  justify-content: space-between;
190
192
  align-items: flex-start;
191
193
  gap: var(--smrt-spacing-6, 1.5rem);
192
194
  padding: var(--smrt-spacing-6, 1.5rem);
193
- background: var(--smrt-color-surface, #ffffff);
194
- border: 1px solid var(--smrt-color-outline-variant, #c4c6d0);
195
+ background: var(--smrt-color-surface);
196
+ border: 1px solid var(--smrt-color-outline-variant);
195
197
  border-radius: var(--smrt-radius-medium, 0.5rem);
196
198
  flex-wrap: wrap;
197
199
  }
@@ -211,7 +213,7 @@ const isOverdue = $derived.by(() => {
211
213
  .invoice-number {
212
214
  font: var(--smrt-typography-title-large-font);
213
215
  font-weight: var(--smrt-typography-weight-semibold, 600);
214
- color: var(--smrt-color-on-surface, #1c1b1f);
216
+ color: var(--smrt-color-on-surface);
215
217
  margin: 0;
216
218
  }
217
219
 
@@ -221,7 +223,7 @@ const isOverdue = $derived.by(() => {
221
223
  padding: var(--smrt-spacing-1, 0.25rem) var(--smrt-spacing-3, 0.75rem);
222
224
  font: var(--smrt-typography-label-small-font);
223
225
  font-weight: var(--smrt-typography-weight-medium, 500);
224
- border-radius: var(--smrt-radius-full, 9999px);
226
+ border-radius: var(--smrt-radius-full);
225
227
  text-transform: capitalize;
226
228
  }
227
229
 
@@ -236,7 +238,7 @@ const isOverdue = $derived.by(() => {
236
238
  align-items: center;
237
239
  gap: var(--smrt-spacing-1_5, 0.375rem);
238
240
  font: var(--smrt-typography-body-medium-font);
239
- color: var(--smrt-color-on-surface-variant, #49454f);
241
+ color: var(--smrt-color-on-surface-variant);
240
242
  }
241
243
 
242
244
  .context-item svg {
@@ -257,7 +259,7 @@ const isOverdue = $derived.by(() => {
257
259
 
258
260
  .meta-label {
259
261
  font: var(--smrt-typography-label-small-font);
260
- color: var(--smrt-color-on-surface-variant, #49454f);
262
+ color: var(--smrt-color-on-surface-variant);
261
263
  text-transform: uppercase;
262
264
  letter-spacing: 0.025em;
263
265
  }
@@ -265,14 +267,15 @@ const isOverdue = $derived.by(() => {
265
267
  .meta-value {
266
268
  font: var(--smrt-typography-body-medium-font);
267
269
  font-weight: var(--smrt-typography-weight-medium, 500);
268
- color: var(--smrt-color-on-surface, #1c1b1f);
270
+ color: var(--smrt-color-on-surface);
269
271
  }
270
272
 
271
273
  .meta-item.overdue .meta-value {
272
- color: var(--smrt-color-error, #ba1a1a);
274
+ color: var(--smrt-color-error);
273
275
  }
274
276
 
275
277
  .meta-item.paid .meta-value {
276
- color: var(--smrt-color-tertiary, #006c4c);
278
+ color: var(--smrt-color-tertiary);
277
279
  }
280
+ }
278
281
  </style>
@@ -13,6 +13,7 @@ let {
13
13
  line,
14
14
  currency,
15
15
  inheritedTaxRate,
16
+ roundingScope = 'line',
16
17
  number = 1,
17
18
  id,
18
19
  fields = {},
@@ -46,7 +47,7 @@ function refresh(event: Event) {
46
47
  onchange?.(draft);
47
48
  }
48
49
  </script>
49
- <fieldset oninput={refresh} onchange={refresh} disabled={!canEdit} class="invoice-line">
50
+ <fieldset oninput={refresh} onchange={refresh} disabled={!canEdit} class="invoice-line" data-smrt-component="InvoiceLineEditor">
50
51
  <legend>{t(M['commerce.invoice.line'], { number })}</legend>
51
52
  <Input type="hidden" name={names.key} value={draft.key} interaction={false} />
52
53
  {#each ['description', 'sku', 'quantity', 'unitPrice'] as field}
@@ -71,15 +72,21 @@ function refresh(event: Event) {
71
72
  {#if calculation.valid}
72
73
  <dl class="totals">
73
74
  <div><dt>{t(M['commerce.invoice.subtotal'])}</dt><dd><CurrencyDisplay amount={calculation.subtotalMinor} {currency} unit="cents" /></dd></div>
75
+ {#if roundingScope === 'line'}
74
76
  <div><dt>{t(M['commerce.invoice.tax'])}</dt><dd><CurrencyDisplay amount={calculation.taxMinor} {currency} unit="cents" /></dd></div>
75
77
  <div><dt>{t(M['commerce.invoice.total'])}</dt><dd><CurrencyDisplay amount={calculation.totalMinor} {currency} unit="cents" /></dd></div>
78
+ {/if}
76
79
  </dl>
80
+ {#if roundingScope === 'invoice'}<p>{t(M['commerce.invoice.invoiceRounding'])}</p>{/if}
77
81
  {:else}<p role="status">{t(M['commerce.invoice.invalid'])}</p>{/if}
78
82
  {#if canEdit}<Button type="submit" name={intentField} value={`${removePrefix}${draft.key}`} formnovalidate disabled={pending} variant="secondary">{t(M['commerce.invoice.remove'])}</Button>{/if}
79
83
  </fieldset>
80
84
  <style>
85
+ @layer smrt.reset, smrt.structure, smrt.theme;
86
+ @layer smrt.theme {
81
87
  .invoice-line { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--smrt-spacing-3); min-width: 0; margin: 0; padding: var(--smrt-spacing-4); border: 1px solid var(--smrt-color-outline); border-radius: var(--smrt-radius-small); }
82
88
  legend { padding-inline: var(--smrt-spacing-2); }
83
89
  .totals { display: flex; flex-wrap: wrap; gap: var(--smrt-spacing-4); }
84
90
  dd { margin: 0; } p, dl { margin: 0; }
91
+ }
85
92
  </style>
@@ -1 +1 @@
1
- {"version":3,"file":"InvoiceLineEditor.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/InvoiceLineEditor.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,mFAAmF;AACnF,MAAM,WAAW,KAAM,SAAQ,sBAAsB;CAAG;AAmFxD,QAAA,MAAM,iBAAiB,2CAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"InvoiceLineEditor.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/InvoiceLineEditor.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,mFAAmF;AACnF,MAAM,WAAW,KAAM,SAAQ,sBAAsB;CAAG;AAuFxD,QAAA,MAAM,iBAAiB,2CAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}