@tallyui/core 5.0.0 → 5.1.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.
@@ -12,6 +12,7 @@ import type { ReceiptTemplate, ReceiptTemplateKind } from './receipt-templates';
12
12
  import type { RegisterInfo } from './registers';
13
13
  import type { ClosureReads } from './closures';
14
14
  import type { Cashier } from './cashier';
15
+ import type { PaymentMethodKind } from './commands';
15
16
  import type { FailureClass } from '../connectivity';
16
17
  import type { DisplayAdvertisement, DisplaySignalling } from './display-signalling';
17
18
  import { parseDisplayAdvertisement } from '../customer-display/advertisement';
@@ -293,6 +294,41 @@ export interface ConnectorTraits {
293
294
  customer?: CustomerTraits;
294
295
  }
295
296
 
297
+ /** The answer to one `settleRefusedOrder` call. */
298
+ export type SettleOutcome =
299
+ /** The order is cancelled. */
300
+ | { kind: 'done'; status: string }
301
+ /** It is not a waiting unpaid order any more; nothing was cancelled. `capturedMinor` is what the store holds as captured. */
302
+ | { kind: 'changed'; status: string; capturedMinor: number }
303
+ /** The store or this check said no. */
304
+ | { kind: 'refused'; code: string; message: string }
305
+ /** The store no longer has it. */
306
+ | { kind: 'gone' }
307
+ /** No definite answer: try again later with the same `attemptId`. */
308
+ | { kind: 'retry'; reason: string };
309
+
310
+ /** Which order to settle: the store's id, the till's own order uuid, and the id of this attempt. */
311
+ export interface SettleCancelRequest { storeOrderId: string; clientOrderId: string; attemptId: string }
312
+
313
+ /** One till leg to record on the store order (#1101 slice 3): a new payment id, the till leg's method, amount and cash tendered. */
314
+ export interface SettlePayment { id: string; method: PaymentMethodKind; amountMinor: number; tenderedMinor?: number }
315
+ /** Record the till's unrecorded legs on the store order a refused sale left part paid. */
316
+ export interface SettlePayRequest extends SettleCancelRequest { currency: string; payments: readonly SettlePayment[] }
317
+ /** `recorded`: the ids in `payments` the store holds as captured when the call ends, in request order. */
318
+ export interface SettlePayResult { outcome: SettleOutcome; recorded: readonly string[] }
319
+
320
+ /** Settlement of an order the store created before it refused the sale. */
321
+ export interface RefusedOrderSettlement {
322
+ cancel?: (context: SyncContext, request: SettleCancelRequest) => Promise<SettleOutcome>;
323
+ /**
324
+ * Records the till's unrecorded legs, money the customer already paid at the till, on a part-paid store order: no new
325
+ * money is taken. `done` means every payment is recorded and the order reads `completed`; `changed` means nothing was
326
+ * sent because the store's figures or status do not match; `gone` comes only from the uuid resolver's 404; `retry`
327
+ * means no definite answer: send again with the same `attemptId` and payment ids.
328
+ */
329
+ pay?: (context: SyncContext, request: SettlePayRequest) => Promise<SettlePayResult>;
330
+ }
331
+
296
332
  /**
297
333
  * The main connector interface.
298
334
  * Each backend (WooCommerce, Medusa, Vendure, etc.) implements this.
@@ -424,6 +460,14 @@ export interface TallyConnector {
424
460
  * read-only; rejects as `listOrders`. `undefined` when the connector has no order history.
425
461
  */
426
462
  getOrders?: (context: SyncContext, ids: readonly string[]) => Promise<StoreOrder[]>;
463
+ /**
464
+ * Settles an order the store created before it refused the sale: online only, never through the outbox. `cancel`
465
+ * cancels it only when the store's own current record shows nothing paid; `pay` records the till's unrecorded legs
466
+ * only when the store's due is exactly their sum. `attemptId` identifies one attempt and is
467
+ * sent again unchanged until a definite answer; `retry` means no definite answer. Rejects with
468
+ * `ConnectorUnauthorizedError` for credentials. `undefined` when the connector can't settle refused orders.
469
+ */
470
+ settleRefusedOrder?: RefusedOrderSettlement;
427
471
  /**
428
472
  * The store's refunds, newest first, one page per call, dated by when each was made (ADR-081 decision 7): online only,
429
473
  * read-only. Rejects as `listOrders` does; a `dateRange` end that is not a UTC instant ending in Z is a TypeError