@tallyui/pos 3.10.0 → 3.11.0

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.
package/dist/index.d.ts CHANGED
@@ -337,6 +337,8 @@ interface LineItem {
337
337
  productId: string;
338
338
  variantId?: string;
339
339
  name: string;
340
+ /** The variant's chosen options, name to value (#495). */
341
+ attributes?: Record<string, string>;
340
342
  sku: string;
341
343
  imageUrl?: string;
342
344
  unitPriceMinor: number;
@@ -418,6 +420,8 @@ interface AddLineInput {
418
420
  taxStatus?: 'taxable' | 'none';
419
421
  variantId?: string;
420
422
  name: string;
423
+ /** The variant's chosen options, name to value (#495). */
424
+ attributes?: Record<string, string>;
421
425
  sku?: string;
422
426
  imageUrl?: string;
423
427
  unitPrice: Money & {
@@ -585,6 +589,8 @@ interface ReceiptFiscal {
585
589
  }
586
590
  interface ReceiptLineItem {
587
591
  name: string;
592
+ /** The variant's chosen options, name to value (#495); absent when none. */
593
+ attributes?: Record<string, string>;
588
594
  sku: string;
589
595
  quantity: number;
590
596
  unitPriceMinor: number;
@@ -920,7 +926,8 @@ declare function toOrderCreateEnvelope(order: PosOrder, deviceId: string, attemp
920
926
  * It also stores the WooCommerce 6dp net (`netMicros`) under the woocommerce rounding (ADR-076 amendment).
921
927
  * Its migration is the identity. It is one-way like version 7.
922
928
  * Version 9 adds the order's `coupons` and the receipt's `display.coupons` (ADR-077 d2), and a line's `attributes` (#495)
923
- * and `regularUnitPriceMinor` (ADR-077 d2), and `reopenedAt`: when a refused order was reopened as a parked sale (ADR-077 d4b), and lets `sentVersion` and `downgradedFrom` be 6 (order.create version 6, ADR-077 d4), and changes nothing else. Nothing writes them yet.
929
+ * and `regularUnitPriceMinor` (ADR-077 d2), and `reopenedAt`: when a refused order was reopened as a parked sale (ADR-077 d4b), and lets `sentVersion` and `downgradedFrom` be 6 (order.create version 6, ADR-077 d4), and changes nothing else.
930
+ * `finalizeOrder` writes a line's `attributes`; the order.create envelope sends them only at version 6.
924
931
  * Its migration is the identity. It is one-way like version 8.
925
932
  */
926
933
  declare const posOrderSchema: RxJsonSchema<PosOrder>;
@@ -2872,4 +2879,4 @@ declare function tenderVoidCollection(): {
2872
2879
  readonly schema: RxJsonSchema<TenderVoid>;
2873
2880
  };
2874
2881
 
2875
- export { type Actor, type AddLineInput, type AppliedDiscount, type BackendNotFound, type BasketLine, COUPONS_UNSUPPORTED, CartError, type CashMovement, type CashMovementCollection, type CatalogueEntry, type CatalogueGridColumns, type CatalogueView, type CatalogueViewAction, type CatalogueViewState, type ChargeInput, type ChargeLine, type Closure, type ClosureCollection, type ClosureContext, type ClosureScope, type CommandTransport, type Correction, CurrencyProvider, type CurrencyProviderProps, type CustomerSummary, DEFAULT_CATALOGUE_VIEW_STATE, DISCOUNTS_UNSUPPORTED, type Discount, type DisplayLine, type DisplayTotals, type FeeLine, type FinalizeOptions, type HttpTransportOptions, type LedgerRow, type LineItem, type LineTaxLine, type LogEntry, type LogLevel, type LogSink, type Logger, MAX_TENDER_MINOR, MICROS_PER_MINOR, type Movement$1 as Movement, type MovementType, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderCoupon, type OrderCouponContext, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderRefundOutcome, type OrderTaxTotals, type OrderTransportContext, type OutboxState, PRODUCT_SORT_FIELDS, type ParkedOrderSummary, type Payment, type PaymentMethod, type PaymentTransport, type PlanLeg, type PosOrder, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type PosRefund, type PosRefundCollection, type PosRefundStatus, type ProductSort, type ProductSortValue, RECEIPT_SCHEMA_VERSION, REGISTER_SESSION_MIGRATION_CLOSE_WAIT_MS, REOPENABLE_CODES, type RateTaxLine, type ReceiptConfig, type ReceiptData, type ReceiptFiscal, type ReceiptLineItem, type ReceiptRegister, type ReceiptSoftware, type RecordedFigures, RefundAnswerPendingError, RegisterApprovalRequiredError, type RegisterBucket, RegisterCloseIncompleteError, type RegisterCommand, type RegisterCommandCollection, type RegisterCounters, type RegisterDocument, type RegisterFact, type RegisterHost, RegisterIdInvalidError, RegisterMovementAmountError, RegisterMovementReasonError, RegisterMovementStrandedError, RegisterNeedsUpgradeError, type RegisterOutbox, type RegisterOutboxOptions, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionConflictError, RegisterSessionOpenClosedError, RegisterSessionRequiredError, type RegisterStore, RegisterTakeOverError, RegisterTenderInProgressError, type ReopenRefusal, ReopenRefusedOrderError, type Repository, type ResolveStoreSettingsOptions, SALE_SAVING, type SaleDiscountCodes, type SaleDiscountState, type SaleStage, type SentOrder, type ShippingLine, type SplitTab, type StoreSettingsResolution, type StoreSettingsState, TAX_ROUNDING_MIXED_NOTE, type TaxContext, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TenderAction, type TenderKey, type TenderLineId, type TenderPlan, type TenderState, type TenderView, type TenderVoid, type TransportOutcome, UnsupportedOrderVersionError, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, abandonSession, activePlan, addEntryToCart, addPosOrderCollection, addRegisterSessionCollection, adoptRegisterResults, advancePerpetual, allocateOrderDiscount, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildXReportDocument, callbackSink, cashMovementSchema, catalogueEntries, catalogueViewReducer, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureCommand, closureSchema, computeOrderTax, consoleSink, countVariance, createBackendNotFound, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createRegisterOutbox, createRepository, denominationTotal, denominations, deriveExpected, deriveSettled, ensureRegister, evenSplitShareMinor, exportCsv, finalizeOrder, findEntryByCode, formatClosureDate, getBoundRegisterId, getDeviceId, inCategory, initTenderState, initialTenderState, isKnownSessionStatus, isReopened, isRequeueable, isServerDecimal, labelKeys, listCategories, minorToDecimal, mintClosureNumber, mintUuid, movementCommand, movementFieldError, needsAttention, nextSaleCounter, normalizeAmount, normalizeCatalogueViewState, observeRegister$, openSession, openSessionSelector, orderDraftSchema, outboxLogger, overThreshold, parkedOrderSummaries$, parseMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, posRefundCollection, posRefundSchema, productCategories, productSortValue, quickTenderedAmounts, ratePpmFromPercent, readBoundRegister, readRegister, reconcileRegisterCommands, recordMovement, recordRegisterFact, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, registerSessionsLogger, reopenRefusedOrder, replacedOrderIds, requireOpenSession, resolveGridColumns, resolveStoreSettings, restoreOrderDraft, roundMicrosToMinor, saleLogger, sameSale, searchProducts, selectClosureRows, sendOrderRefund, sessionOpenCommand, sessionTransitionCommand, sortProducts, stampSession, startCounting, stockOverlay$, stockOverlayAsOf$, submitOrderRefund, takeOverSession, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, tenderReducer, tenderVoidCollection, tenderVoidSchema, toOrderCreateEnvelope, unbindRegister, useCurrencyCode, useCurrencyFormatter, useOrderOutbox, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useStoreSettings, useTax, uuidv7, validAmount, varianceText, variantPriceLabel, voidMovement, withPricingContext, index as woocommerceDiscountCodes, writeClosure, writeOrderDraft };
2882
+ export { type Actor, type AddLineInput, type AppliedDiscount, type BackendNotFound, type BasketLine, COUPONS_UNSUPPORTED, CartError, type CashMovement, type CashMovementCollection, type CatalogueEntry, type CatalogueGridColumns, type CatalogueView, type CatalogueViewAction, type CatalogueViewState, type ChargeInput, type ChargeLine, type Closure, type ClosureCollection, type ClosureContext, type ClosureScope, type CommandTransport, type Correction, CurrencyProvider, type CurrencyProviderProps, type CustomerSummary, DEFAULT_CATALOGUE_VIEW_STATE, DISCOUNTS_UNSUPPORTED, type Discount, type DisplayLine, type DisplayTotals, type FeeLine, type FinalizeOptions, type HttpTransportOptions, type LedgerRow, type LineItem, type LineTaxLine, type LogEntry, type LogLevel, type LogSink, type Logger, MAX_TENDER_MINOR, MICROS_PER_MINOR, type Movement$1 as Movement, type MovementType, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderCoupon, type OrderCouponContext, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderRefundOutcome, type OrderTaxTotals, type OrderTransportContext, type OutboxState, PRODUCT_SORT_FIELDS, type ParkedOrderSummary, type Payment, type PaymentMethod, type PaymentTransport, type PlanLeg, type PosOrder, type PosOrderCoupon, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type PosRefund, type PosRefundCollection, type PosRefundStatus, type ProductSort, type ProductSortValue, RECEIPT_SCHEMA_VERSION, REGISTER_SESSION_MIGRATION_CLOSE_WAIT_MS, REOPENABLE_CODES, type RateTaxLine, type ReceiptConfig, type ReceiptData, type ReceiptFiscal, type ReceiptLineItem, type ReceiptRegister, type ReceiptSoftware, type RecordedFigures, RefundAnswerPendingError, RegisterApprovalRequiredError, type RegisterBucket, RegisterCloseIncompleteError, type RegisterCommand, type RegisterCommandCollection, type RegisterCounters, type RegisterDocument, type RegisterFact, type RegisterHost, RegisterIdInvalidError, RegisterMovementAmountError, RegisterMovementReasonError, RegisterMovementStrandedError, RegisterNeedsUpgradeError, type RegisterOutbox, type RegisterOutboxOptions, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionConflictError, RegisterSessionOpenClosedError, RegisterSessionRequiredError, type RegisterStore, RegisterTakeOverError, RegisterTenderInProgressError, type ReopenRefusal, ReopenRefusedOrderError, type Repository, type ResolveStoreSettingsOptions, SALE_SAVING, type SaleDiscountCodes, type SaleDiscountState, type SaleStage, type SentOrder, type ShippingLine, type SplitTab, type StoreSettingsResolution, type StoreSettingsState, TAX_ROUNDING_MIXED_NOTE, type TaxContext, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TenderAction, type TenderKey, type TenderLineId, type TenderPlan, type TenderState, type TenderView, type TenderVoid, type TransportOutcome, UnsupportedOrderVersionError, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, abandonSession, activePlan, addEntryToCart, addPosOrderCollection, addRegisterSessionCollection, adoptRegisterResults, advancePerpetual, allocateOrderDiscount, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildXReportDocument, callbackSink, cashMovementSchema, catalogueEntries, catalogueViewReducer, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureCommand, closureSchema, computeOrderTax, consoleSink, countVariance, createBackendNotFound, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createRegisterOutbox, createRepository, denominationTotal, denominations, deriveExpected, deriveSettled, ensureRegister, evenSplitShareMinor, exportCsv, finalizeOrder, findEntryByCode, formatClosureDate, getBoundRegisterId, getDeviceId, inCategory, initTenderState, initialTenderState, isKnownSessionStatus, isReopened, isRequeueable, isServerDecimal, labelKeys, listCategories, minorToDecimal, mintClosureNumber, mintUuid, movementCommand, movementFieldError, needsAttention, nextSaleCounter, normalizeAmount, normalizeCatalogueViewState, observeRegister$, openSession, openSessionSelector, orderDraftSchema, outboxLogger, overThreshold, parkedOrderSummaries$, parseMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, posRefundCollection, posRefundSchema, productCategories, productSortValue, quickTenderedAmounts, ratePpmFromPercent, readBoundRegister, readRegister, reconcileRegisterCommands, recordMovement, recordRegisterFact, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, registerSessionsLogger, reopenRefusedOrder, replacedOrderIds, requireOpenSession, resolveGridColumns, resolveStoreSettings, restoreOrderDraft, roundMicrosToMinor, saleLogger, sameSale, searchProducts, selectClosureRows, sendOrderRefund, sessionOpenCommand, sessionTransitionCommand, sortProducts, stampSession, startCounting, stockOverlay$, stockOverlayAsOf$, submitOrderRefund, takeOverSession, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, tenderReducer, tenderVoidCollection, tenderVoidSchema, toOrderCreateEnvelope, unbindRegister, useCurrencyCode, useCurrencyFormatter, useOrderOutbox, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useStoreSettings, useTax, uuidv7, validAmount, varianceText, variantPriceLabel, voidMovement, withPricingContext, index as woocommerceDiscountCodes, writeClosure, writeOrderDraft };
package/dist/index.js CHANGED
@@ -976,6 +976,7 @@ function createOrderBuilder(options) {
976
976
  ...input.taxStatus === "none" ? { taxStatus: "none" } : {},
977
977
  variantId,
978
978
  name: input.name,
979
+ ...input.attributes && Object.keys(input.attributes).length ? { attributes: { ...input.attributes } } : {},
979
980
  sku: input.sku ?? "",
980
981
  imageUrl: input.imageUrl,
981
982
  unitPriceMinor: unitPrice.amount,
@@ -1373,6 +1374,7 @@ function restoreOrderDraft(saved, options) {
1373
1374
  ...taxContext.rounding?.granularity === "woocommerce" ? { taxClass: line.taxClass } : {},
1374
1375
  variantId: line.variantId,
1375
1376
  name: line.name,
1377
+ ...line.attributes !== void 0 ? { attributes: line.attributes } : {},
1376
1378
  sku: line.sku,
1377
1379
  imageUrl: line.imageUrl,
1378
1380
  unitPrice: { amount: line.unitPriceMinor, currency, taxInclusive: line.taxInclusive },
@@ -1543,6 +1545,7 @@ function buildReceiptData(order, config) {
1543
1545
  },
1544
1546
  lineItems: order.lineItems.map((li, index) => ({
1545
1547
  name: li.name,
1548
+ ...li.attributes && Object.keys(li.attributes).length ? { attributes: { ...li.attributes } } : {},
1546
1549
  sku: li.sku,
1547
1550
  quantity: li.quantity,
1548
1551
  unitPriceMinor: li.unitPriceMinor,
@@ -1922,6 +1925,7 @@ function finalizeOrder(order, options = {}) {
1922
1925
  sku: line.sku,
1923
1926
  quantity: line.quantity,
1924
1927
  unitPriceMinor: line.unitPriceMinor,
1928
+ ...line.attributes && Object.keys(line.attributes).length ? { attributes: { ...line.attributes } } : {},
1925
1929
  ...line.regularUnitPriceMinor !== void 0 ? { regularUnitPriceMinor: line.regularUnitPriceMinor } : {},
1926
1930
  discountMinor: line.discountMinor,
1927
1931
  netMinor: line.netMinor,
@@ -3218,6 +3222,7 @@ async function reopenRefusedOrder(orderId, deps) {
3218
3222
  sku: line.sku,
3219
3223
  unitPrice: { amount: line.unitPriceMinor, currency: order.currency, taxInclusive: line.taxInclusive },
3220
3224
  ...line.regularUnitPriceMinor !== void 0 ? { regularUnitPriceMinor: line.regularUnitPriceMinor } : {},
3225
+ ...line.attributes !== void 0 ? { attributes: line.attributes } : {},
3221
3226
  quantity: line.quantity,
3222
3227
  taxRates: line.taxLines.map(({ code, ratePpm }) => ({ code, ratePpm })),
3223
3228
  ...line.custom ? { custom: true, taxClass: line.custom.taxClass, taxStatus: line.custom.taxStatus } : { taxClass: deps.taxClassOf?.(line.productId, line.variantId) ?? "standard", taxStatus: line.taxStatus }
@@ -4535,6 +4540,7 @@ function addEntryToCart(builder, entry, traits, currency) {
4535
4540
  productId: traits.getId(product),
4536
4541
  variantId: variant.id,
4537
4542
  name,
4543
+ ...variant.options && Object.keys(variant.options).length ? { attributes: variant.options } : {},
4538
4544
  sku: variant.sku ?? "",
4539
4545
  imageUrl: traits.getImageUrl?.(product),
4540
4546
  unitPrice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/pos",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "type": "module",
5
5
  "description": "Shared POS business logic for Tally UI — tax, orders, payments, discounts, receipts",
6
6
  "main": "./dist/index.js",
@@ -28,20 +28,20 @@
28
28
  "directory": "packages/pos"
29
29
  },
30
30
  "peerDependencies": {
31
- "@tallyui/core": "^3.10.0",
31
+ "@tallyui/core": "^3.11.0",
32
32
  "react": ">=18",
33
33
  "rxdb": "~17.5.0",
34
34
  "rxjs": ">=7"
35
35
  },
36
36
  "devDependencies": {
37
- "@tallyui/core": "3.10.0",
37
+ "@tallyui/core": "3.11.0",
38
38
  "@types/react": ">=18",
39
39
  "react": "^19.2.4",
40
40
  "rxdb": "17.5.0",
41
41
  "rxjs": "7.8.2",
42
- "@tallyui/connector-medusa": "3.10.0",
43
- "@tallyui/connector-woocommerce": "3.10.0",
44
- "@tallyui/database": "3.10.0"
42
+ "@tallyui/connector-medusa": "3.11.0",
43
+ "@tallyui/connector-woocommerce": "3.11.0",
44
+ "@tallyui/database": "3.11.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup",
package/src/index.ts CHANGED
@@ -64,7 +64,7 @@ export type { SaleStage, CatalogueEntry, SaleDiscountCodes, SaleDiscountState }
64
64
 
65
65
  export { uuidv7, finalizeOrder, toOrderCreateEnvelope, UnsupportedOrderVersionError, posOrderSchema, posOrderCollection, addPosOrderCollection, PosOrderOpenClosedError, posOrdersLogger, getDeviceId, needsAttention, isReopened, replacedOrderIds, sameSale, OrderContentMismatchError } from './pos-order';
66
66
  export { REOPENABLE_CODES, ReopenRefusedOrderError, reopenRefusedOrder, type ReopenRefusal } from './pos-order';
67
- export type { PosOrderSyncStatus, PosOrderLine, PosOrderPayment, PosOrderLocalWarning, PosOrderServerFailures, PosOrder, FinalizeOptions } from './pos-order';
67
+ export type { PosOrderSyncStatus, PosOrderLine, PosOrderCoupon, PosOrderPayment, PosOrderLocalWarning, PosOrderServerFailures, PosOrder, FinalizeOptions } from './pos-order';
68
68
  export { createHttpCommandTransport, createOrderOutbox, isRequeueable, useOrderOutbox, outboxLogger } from './outbox';
69
69
  export { createRegisterOutbox, useRegisterOutbox } from './outbox';
70
70
  export type { RegisterOutboxOptions, RegisterOutbox, UseRegisterOutboxOptions, UseRegisterOutboxResult } from './outbox';
@@ -401,6 +401,7 @@ export function createOrderBuilder(options: OrderBuilderOptions): OrderBuilder {
401
401
  ...(input.taxStatus === 'none' ? { taxStatus: 'none' as const } : {}),
402
402
  variantId,
403
403
  name: input.name,
404
+ ...(input.attributes && Object.keys(input.attributes).length ? { attributes: { ...input.attributes } } : {}),
404
405
  sku: input.sku ?? '',
405
406
  imageUrl: input.imageUrl,
406
407
  unitPriceMinor: unitPrice.amount,
@@ -70,6 +70,7 @@ export function restoreOrderDraft(saved: Order, options: { currency: string; tax
70
70
  ...(taxContext.rounding?.granularity === 'woocommerce' ? { taxClass: line.taxClass } : {}),
71
71
  variantId: line.variantId,
72
72
  name: line.name,
73
+ ...(line.attributes !== undefined ? { attributes: line.attributes } : {}),
73
74
  sku: line.sku,
74
75
  imageUrl: line.imageUrl,
75
76
  unitPrice: { amount: line.unitPriceMinor, currency, taxInclusive: line.taxInclusive },
@@ -75,6 +75,8 @@ export interface LineItem {
75
75
  productId: string;
76
76
  variantId?: string;
77
77
  name: string;
78
+ /** The variant's chosen options, name to value (#495). */
79
+ attributes?: Record<string, string>;
78
80
  sku: string;
79
81
  imageUrl?: string;
80
82
  unitPriceMinor: number; // as sold, integer
@@ -158,6 +160,8 @@ export interface AddLineInput {
158
160
  taxStatus?: 'taxable' | 'none';
159
161
  variantId?: string;
160
162
  name: string;
163
+ /** The variant's chosen options, name to value (#495). */
164
+ attributes?: Record<string, string>;
161
165
  sku?: string;
162
166
  imageUrl?: string;
163
167
  unitPrice: Money & { taxInclusive?: boolean }; // currency must equal the order currency; taxInclusive wins over the order's pricesIncludeTax
@@ -168,6 +168,7 @@ export function finalizeOrder(order: Order, options: FinalizeOptions = {}): PosO
168
168
  ...(line.taxClass !== undefined ? { taxClass: line.taxClass } : {}), taxStatus: line.taxStatus ?? 'taxable' } } : {}),
169
169
  ...(line.taxStatus !== undefined ? { taxStatus: line.taxStatus } : {}),
170
170
  name: line.name, sku: line.sku, quantity: line.quantity, unitPriceMinor: line.unitPriceMinor,
171
+ ...(line.attributes && Object.keys(line.attributes).length ? { attributes: { ...line.attributes } } : {}),
171
172
  ...(line.regularUnitPriceMinor !== undefined ? { regularUnitPriceMinor: line.regularUnitPriceMinor } : {}),
172
173
  discountMinor: line.discountMinor, netMinor: line.netMinor,
173
174
  ...(order.taxRounding?.granularity === 'woocommerce' ? { netMicros: line.netMicros } : {}),
@@ -44,6 +44,7 @@ export async function reopenRefusedOrder(orderId: string, deps: {
44
44
  productId: line.productId, variantId: line.variantId, name: line.name, sku: line.sku,
45
45
  unitPrice: { amount: line.unitPriceMinor, currency: order.currency, taxInclusive: line.taxInclusive },
46
46
  ...(line.regularUnitPriceMinor !== undefined ? { regularUnitPriceMinor: line.regularUnitPriceMinor } : {}),
47
+ ...(line.attributes !== undefined ? { attributes: line.attributes } : {}),
47
48
  quantity: line.quantity,
48
49
  taxRates: line.taxLines.map(({ code, ratePpm }) => ({ code, ratePpm })),
49
50
  ...(line.custom ? { custom: true, taxClass: line.custom.taxClass, taxStatus: line.custom.taxStatus }
@@ -24,7 +24,8 @@ import type { PosOrder } from './types';
24
24
  * It also stores the WooCommerce 6dp net (`netMicros`) under the woocommerce rounding (ADR-076 amendment).
25
25
  * Its migration is the identity. It is one-way like version 7.
26
26
  * Version 9 adds the order's `coupons` and the receipt's `display.coupons` (ADR-077 d2), and a line's `attributes` (#495)
27
- * and `regularUnitPriceMinor` (ADR-077 d2), and `reopenedAt`: when a refused order was reopened as a parked sale (ADR-077 d4b), and lets `sentVersion` and `downgradedFrom` be 6 (order.create version 6, ADR-077 d4), and changes nothing else. Nothing writes them yet.
27
+ * and `regularUnitPriceMinor` (ADR-077 d2), and `reopenedAt`: when a refused order was reopened as a parked sale (ADR-077 d4b), and lets `sentVersion` and `downgradedFrom` be 6 (order.create version 6, ADR-077 d4), and changes nothing else.
28
+ * `finalizeOrder` writes a line's `attributes`; the order.create envelope sends them only at version 6.
28
29
  * Its migration is the identity. It is one-way like version 8.
29
30
  */
30
31
  export const posOrderSchema: RxJsonSchema<PosOrder> = {
@@ -49,6 +49,7 @@ export function buildReceiptData(order: SentOrder, config: ReceiptConfig): Recei
49
49
  },
50
50
  lineItems: order.lineItems.map((li, index) => ({
51
51
  name: li.name,
52
+ ...(li.attributes && Object.keys(li.attributes).length ? { attributes: { ...li.attributes } } : {}),
52
53
  sku: li.sku,
53
54
  quantity: li.quantity,
54
55
  unitPriceMinor: li.unitPriceMinor,
@@ -15,6 +15,8 @@ export interface ReceiptFiscal {
15
15
 
16
16
  export interface ReceiptLineItem {
17
17
  name: string;
18
+ /** The variant's chosen options, name to value (#495); absent when none. */
19
+ attributes?: Record<string, string>;
18
20
  sku: string;
19
21
  quantity: number;
20
22
  unitPriceMinor: number;
package/src/sale/cart.ts CHANGED
@@ -19,6 +19,7 @@ export function addEntryToCart<Doc>(builder: OrderBuilder, entry: CatalogueEntry
19
19
  const unitPrice = resolved.current, regularPrice = regularUnitPriceMinor(resolved);
20
20
  return builder.addLine({
21
21
  productId: traits.getId(product), variantId: variant.id, name,
22
+ ...(variant.options && Object.keys(variant.options).length ? { attributes: variant.options } : {}),
22
23
  sku: variant.sku ?? '', imageUrl: traits.getImageUrl?.(product), unitPrice,
23
24
  ...(regularPrice !== undefined ? { regularUnitPriceMinor: regularPrice } : {}),
24
25
  taxClass: traits.getTaxClass?.(product, variant.id),
package/src/tax/index.ts CHANGED
@@ -2,4 +2,4 @@ export { MICROS_PER_MINOR, ratePpmFromPercent, taxMicros, roundMicrosToMinor, co
2
2
  export type { TaxLineInput, OrderTaxTotals, RateTaxLine } from './exact';
3
3
  export { TaxProvider, useTax, taxLogger } from './tax-provider';
4
4
  export type { TaxProviderProps } from './tax-provider';
5
- export type { TaxRateMap, TaxContext, WooRate } from './types';
5
+ export type { TaxRateMap, TaxContext } from './types';