@tallyui/core 3.2.0 → 3.3.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.
@@ -0,0 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
@@ -5,8 +5,9 @@ interface CommandEnvelope<P = unknown> {
5
5
  id: string;
6
6
  type: CommandType;
7
7
  /** 3 when the order carries ADR-065's `display` and `taxByRate` (the store accepts 3), else 2 when discounted, else 1;
8
- * 4 is 3 with every `discountMinor` tax-exclusive, built only when capped at 4 or more (#286). */
9
- version: 1 | 2 | 3 | 4;
8
+ * 4 is 3 with every `discountMinor` tax-exclusive, built only when capped at 4 or more (#286).
9
+ * 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one. */
10
+ version: 1 | 2 | 3 | 4 | 5;
10
11
  payload: P;
11
12
  createdAt: string;
12
13
  deviceId: string;
@@ -21,10 +22,10 @@ type RegisterCommandEnvelope<P = Record<string, unknown>> = Omit<CommandEnvelope
21
22
  };
22
23
  /** Any command a transport can carry. */
23
24
  type AnyCommandEnvelope = CommandEnvelope<unknown> | RegisterCommandEnvelope<unknown>;
24
- /** An order.create envelope: its version is 1 | 2 | 3 | 4 (ADR-062, ADR-065, #286). */
25
+ /** An order.create envelope: 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one. */
25
26
  type OrderCreateEnvelope = CommandEnvelope<OrderCreatePayload> & {
26
27
  type: 'order.create';
27
- version: 1 | 2 | 3 | 4;
28
+ version: 1 | 2 | 3 | 4 | 5;
28
29
  };
29
30
  /** Outcome of processing a command. */
30
31
  type CommandStatus = 'applied' | 'duplicate' | 'rejected';
@@ -185,7 +186,19 @@ interface RegisterClosureSubmitPayload {
185
186
  /** Order line with client identity and price in minor units. */
186
187
  interface OrderCreateLine {
187
188
  clientLineId: string;
188
- variantId: string;
189
+ /** Required unless `custom` is set (version 5). */
190
+ variantId?: string;
191
+ /** Version 5 instruction: a non-catalogue line, without variantId; takes line and order discounts. */
192
+ custom?: {
193
+ /** Recorded title, 1–255 characters. */
194
+ name: string;
195
+ /** Recorded SKU, at most 64 characters when present. */
196
+ sku?: string;
197
+ /** Instruction, at most 64 characters; absent means the standard class. */
198
+ taxClass?: string;
199
+ /** Instruction: `none` means no tax on this line. */
200
+ taxStatus: 'taxable' | 'none';
201
+ };
189
202
  title?: string;
190
203
  quantity: number;
191
204
  unitPriceMinor: number;
@@ -199,10 +212,32 @@ interface OrderCreateLine {
199
212
  * Version 2 (ADR-062): this line's total discount, its own line discounts plus its allocated share of
200
213
  * the order discount, in the line's own tax mode and integer minor units. The line is taxed on
201
214
  * `unitPriceMinor × quantity − discountMinor`. Present only when above 0.
202
- * Version 4 (#286): tax-exclusive (net) in every mode; an inclusive line's is `net(A) − net(A − D)`.
215
+ * Version 4+ (#286): tax-exclusive (net) in every mode; an inclusive line's is `net(A) − net(A − D)`.
203
216
  */
204
217
  discountMinor?: number;
205
218
  }
219
+ /** Version 5: a fee, never discounted (ADR-075). */
220
+ interface OrderCreateFee {
221
+ /** Identity: UUID, stable for the order's life, at most 36 characters. */
222
+ clientFeeId: string;
223
+ /** Recorded fee title, 1–255 characters. */
224
+ name: string;
225
+ /** Instruction: integer >= 0, gross when pricesIncludeTax, net otherwise; never discounted. */
226
+ amountMinor: number;
227
+ /** Instruction: `none` means no tax on this fee. */
228
+ taxStatus: 'taxable' | 'none';
229
+ /** Instruction, at most 64 characters; absent means the standard class. */
230
+ taxClass?: string;
231
+ /** Informational till tax, integer >= 0; a server difference is total_mismatch, not a refusal. */
232
+ taxMinor: number;
233
+ }
234
+ /** Version 5: the same instructions and recorded/informational fields as a fee, never discounted. */
235
+ interface OrderCreateShipping extends Omit<OrderCreateFee, 'clientFeeId'> {
236
+ /** Identity: UUID, stable for the order's life, at most 36 characters. */
237
+ clientShippingId: string;
238
+ /** Recorded shipping method id, at most 64 characters; absent means a POS-entered charge. */
239
+ methodId?: string;
240
+ }
206
241
  /** Supported order payment method. */
207
242
  type PaymentMethodKind = 'cash' | 'external';
208
243
  /** Order payment with client identity and amounts in minor units. */
@@ -233,6 +268,20 @@ interface OrderCreateDisplay {
233
268
  amountMinor: number;
234
269
  }>;
235
270
  }>;
271
+ /** Version 5 recorded figures: one row per payload fee, in the display tax mode. */
272
+ fees?: Array<{
273
+ /** Identity: the payload fee's clientFeeId. */
274
+ clientFeeId: string;
275
+ /** Recorded integer minor units, equal to the payload fee amount. */
276
+ amountMinor: number;
277
+ }>;
278
+ /** Version 5 recorded figures: one row per payload shipping charge, in the display tax mode. */
279
+ shipping?: Array<{
280
+ /** Identity: the payload shipping charge's clientShippingId. */
281
+ clientShippingId: string;
282
+ /** Recorded integer minor units, equal to the payload shipping amount. */
283
+ amountMinor: number;
284
+ }>;
236
285
  }
237
286
  /** Version 3 (ADR-065): one tax rate's net, tax and gross, as the receipt's tax summary splits them. */
238
287
  interface OrderCreateTaxRate {
@@ -249,28 +298,32 @@ interface OrderCreatePayload {
249
298
  currency: string;
250
299
  pricesIncludeTax: boolean;
251
300
  lines: OrderCreateLine[];
301
+ /** Version 5 instructions: fees in the order's tax mode; omitted when none. */
302
+ fees?: OrderCreateFee[];
303
+ /** Version 5 instructions: shipping in the order's tax mode; omitted when none. */
304
+ shipping?: OrderCreateShipping[];
252
305
  subtotalMinor: number;
253
306
  /**
254
307
  * Version 2 (ADR-062): the order's total discount, equal to Σ `lines[].discountMinor`. Present only when above 0.
255
- * Version 4 (#286) means every `discountMinor`, this and each line's, is tax-exclusive, so the sum still holds.
308
+ * Version 4+ (#286) means every `discountMinor`, this and each line's, is tax-exclusive, so the sum still holds.
256
309
  */
257
310
  discountMinor?: number;
258
311
  taxMinor: number;
259
312
  totalMinor: number;
260
313
  payments: OrderCreatePayment[];
261
- /** version 3 only; both or neither. */
314
+ /** Version 3+; both or neither. */
262
315
  display?: OrderCreateDisplay;
263
- /** version 3 only; both or neither. */
316
+ /** Version 3+; both or neither. */
264
317
  taxByRate?: OrderCreateTaxRate[];
265
318
  customer?: {
266
319
  email?: string;
267
- /** Version 3 only: the platform's id for the customer picked at the till, a soft reference of at most 64 characters. Absent for a guest sale, or when no customer was picked. */
320
+ /** Version 3+: the platform's id for the customer picked at the till, a soft reference of at most 64 characters. Absent for a guest sale, or when no customer was picked. */
268
321
  customerId?: string;
269
322
  } | null;
270
323
  registerId?: string;
271
324
  cashierRef?: string;
272
325
  locationId?: string;
273
- /** Version 3 only: the register session the sale was taken for, stamped or late (ADR-032). A late sale names the session that refused its stamp; the server tells the two apart by the session's closure `orderIds`. Absent when the sale had no session. */
326
+ /** Version 3+: the register session the sale was taken for, stamped or late (ADR-032). A late sale names the session that refused its stamp; the server tells the two apart by the session's closure `orderIds`. Absent when the sale had no session. */
274
327
  sessionId?: string;
275
328
  }
276
329
  /** Batch of commands submitted to the server. */
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RxReplicationPullStreamItem, RxReplicationWriteToMasterRow, RxJsonSchema } from 'rxdb';
2
2
  import { Observable } from 'rxjs';
3
- import { C as CommandWarning } from './commands-BW4YYgRG.js';
4
- export { A as AnyCommandEnvelope, B as BatchTooLargeBody, a as COMMANDS_PATH, b as CommandBatchRequest, c as CommandBatchResponse, d as CommandEnvelope, e as CommandError, f as CommandResult, g as CommandServerRefs, h as CommandStatus, i as CommandType, M as MAX_COMMANDS_PER_BATCH, O as OrderCreateDisplay, j as OrderCreateEnvelope, k as OrderCreateLine, l as OrderCreatePayload, m as OrderCreatePayment, n as OrderCreateTaxRate, P as PROTOCOL_HEADER, o as PROTOCOL_VERSION, p as PaymentMethodKind, R as RegisterClosureSubmitPayload, q as RegisterCommandEnvelope, r as RegisterCommandResult, s as RegisterCommandType, t as RegisterMovementRecordPayload, u as RegisterMovementVoidPayload, v as RegisterSessionOpenPayload, w as RegisterSessionTransitionPayload, x as isCommandBatchResponse } from './commands-BW4YYgRG.js';
3
+ import { C as CommandWarning } from './commands-xE2xMmC_.js';
4
+ export { A as AnyCommandEnvelope, B as BatchTooLargeBody, a as COMMANDS_PATH, b as CommandBatchRequest, c as CommandBatchResponse, d as CommandEnvelope, e as CommandError, f as CommandResult, g as CommandServerRefs, h as CommandStatus, i as CommandType, M as MAX_COMMANDS_PER_BATCH, O as OrderCreateDisplay, j as OrderCreateEnvelope, k as OrderCreateLine, l as OrderCreatePayload, m as OrderCreatePayment, n as OrderCreateTaxRate, P as PROTOCOL_HEADER, o as PROTOCOL_VERSION, p as PaymentMethodKind, R as RegisterClosureSubmitPayload, q as RegisterCommandEnvelope, r as RegisterCommandResult, s as RegisterCommandType, t as RegisterMovementRecordPayload, u as RegisterMovementVoidPayload, v as RegisterSessionOpenPayload, w as RegisterSessionTransitionPayload, x as isCommandBatchResponse } from './commands-xE2xMmC_.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ReactNode } from 'react';
7
7
 
@@ -115,6 +115,11 @@ interface ProductTraits<Doc = any> {
115
115
  * line is taxed at the default rate.
116
116
  */
117
117
  getTaxClass?: (doc: Doc, variantId?: string) => string | undefined;
118
+ /**
119
+ * Whether the variant `variantId` (or the product's default variant) is taxed: 'none' means the line carries no
120
+ * tax. Undefined means taxable. Optional: without it, every line is taxable.
121
+ */
122
+ getTaxStatus?: (doc: Doc, variantId?: string) => 'taxable' | 'none' | undefined;
118
123
  /** @deprecated Use `getPrices` with `resolvePrice`. */
119
124
  getPrice: (doc: Doc) => string | undefined;
120
125
  /** Regular (non-sale) price. @deprecated Use `getPrices` with `resolvePrice`. */
@@ -332,6 +337,19 @@ interface StoreSettings {
332
337
  };
333
338
  /** The backend's tax rate name per tax class (same keys as `taxRatesPpm`, including `default`), for `per_rate_group_items`' grouping (#324). Set by a connector whose rounding groups by rate name; absent otherwise. */
334
339
  taxRateCodes?: Record<string, string>;
340
+ /** WooCommerce rates already filtered to the store's tax address; the empty class uses `standard`. */
341
+ taxRates?: Record<string, {
342
+ id: number;
343
+ code: string;
344
+ label: string;
345
+ rate: string;
346
+ priority: number;
347
+ compound: boolean;
348
+ shipping: boolean;
349
+ }[]>;
350
+ taxRoundAtSubtotal?: boolean;
351
+ shippingTaxClass?: string;
352
+ taxClassSlugs?: string[];
335
353
  /** Connector-specific and opaque to the app: what the connector needs to price documents. The app passes it back to the connector unchanged, and never logs it. */
336
354
  pricingContext?: Record<string, string>;
337
355
  /** Derived, never read by `storeSettings`: the store's `ServerCapabilities.taxRounding`, which `useStoreSettings` fills in (#324). */
@@ -416,11 +434,26 @@ interface ServerCapabilities {
416
434
  register?: number;
417
435
  /** How the store rounds tax (#287). Absent: an older server, per_order + half_away_from_zero. */
418
436
  taxRounding?: TaxRounding;
437
+ /** Whether one order may carry several payments. Absent means it may: order.create's `payments` has always been a
438
+ * list. A WooCommerce store says false until its plugin records the list (`order_payments_list`). The app offers
439
+ * split tender only when this is not false. */
440
+ multiplePayments?: boolean;
441
+ /**
442
+ * What the store accepts for a fee's, a shipping charge's or a custom line's tax (order.create 5, ADR-075):
443
+ * `none` is `taxStatus: 'none'`, `classes` is a `taxClass`. Absent means neither; the UI hides what is false.
444
+ */
445
+ lineTax?: {
446
+ none: boolean;
447
+ classes: boolean;
448
+ };
419
449
  }
420
450
  /** #287, ADR-071. `custom`: the till computes as when absent; that server never emits `figures_mismatch` for subtotal or tax. */
421
451
  type TaxRounding = {
422
452
  granularity: 'per_order' | 'per_line_items' | 'per_rate_group_items';
423
453
  mode: 'half_away_from_zero' | 'half_up';
454
+ } | {
455
+ granularity: 'woocommerce';
456
+ roundAtSubtotal: boolean;
424
457
  } | {
425
458
  granularity: 'custom';
426
459
  };
@@ -439,10 +472,14 @@ declare function resolveCapabilities(fresh: ServerCapabilities | undefined, stor
439
472
  * no logger, so a malformed value gives `undefined` and one reason to `warn` for the caller to log.
440
473
  */
441
474
  declare function parseTaxRounding(value: unknown, warn?: (reason: string) => void): TaxRounding | undefined;
475
+ declare function parseLineTax(value: unknown, warn?: (reason: string) => void): {
476
+ none: boolean;
477
+ classes: boolean;
478
+ } | undefined;
442
479
  /**
443
480
  * Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
444
481
  * `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
445
- * `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287).
482
+ * `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287); malformed `lineTax` is ignored.
446
483
  * Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
447
484
  * A non-object body is also unknown, not a statement of the store's defaults.
448
485
  */
@@ -900,4 +937,213 @@ declare function useStockOverlayAsOf(): string | undefined;
900
937
  */
901
938
  declare function useCustomerTraits(): CustomerTraits<any> | undefined;
902
939
 
903
- export { type AuthField, type CatalogueReconcileAdapter, type CatalogueReconcileEntry, type CollectionSync, CommandWarning, type ConnectorAuth, ConnectorProvider, type ConnectorProviderProps, type ConnectorSchemas, type ConnectorTraits, ConnectorUnauthorizedError, type Customer, type CustomerInput, CustomerServiceError, type CustomerTraits, type ErrorKind, type FingerprintReconcileAdapter, type IdReconcileAdapter, type KeyedReconcileFeedOptions, type Money, type ProductPrice, type ProductTraits, type ReconcileFeed, type ReconcileFeedEntry, type ReconcileFetchEntry, type RemoteIdEntry, type ReplicationAdapter, type ResolvedPrice, STOCK_LEVELS_LAST_PASS, type ServerCapabilities, SignInError, type SignInErrorCode, type SignInResult, type StockLevel, type StockReconcileAdapter, type StockStatus, type StoreSettings, type StoreSettingsChoice, type StoreSettingsChoices, StoreSettingsError, type StoreSettingsErrorCode, type SyncContext, type SyncNotice, type TallyConnector, type TaxRounding, type TraitContext, type VariantSummary, combinePullAdapters, compareIds, createReconcileFeed, currencySymbol, customerTraits, errorKind, findVariantByCode, formatMoney, getProductStock, isRxdbRemoteVersionMismatch, knownWarnings, minorUnitDigits, moneyFromDecimalString, moneyFromMajor, moneyToMajor, parseInfoCapabilities, parseTaxRounding, resolveCapabilities, resolvePrice, resolvePriceRange, useConnector, useCustomerTraits, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay };
940
+ interface WooTaxRate {
941
+ id: number;
942
+ country: string;
943
+ state: string;
944
+ postcode: string;
945
+ city: string;
946
+ postcodes: string[];
947
+ cities: string[];
948
+ rate: string;
949
+ name: string;
950
+ priority: number;
951
+ compound: boolean;
952
+ shipping: boolean;
953
+ order: number;
954
+ class: string;
955
+ }
956
+ interface CalculateTaxesInput {
957
+ amount: number;
958
+ rates: {
959
+ id: number;
960
+ rate: string;
961
+ compound: boolean;
962
+ order: number;
963
+ priority?: number;
964
+ [key: string]: any;
965
+ }[];
966
+ amountIncludesTax: boolean;
967
+ dp?: number;
968
+ perRatePrecision?: number;
969
+ }
970
+ type ItemizedTax = {
971
+ id: number;
972
+ total: number;
973
+ [key: string]: any;
974
+ };
975
+ interface CalculateTaxesResult {
976
+ total: number;
977
+ taxes: {
978
+ id: number;
979
+ total: number;
980
+ }[];
981
+ }
982
+
983
+ /**
984
+ * Takes a price and an array of tax rates, eg: [{ id: 1, rate: '4.0000', order: 1 }]
985
+ * Returns the calculated array of taxes tax, eg: [{ id: 1, total: 1.2345 }]
986
+ *
987
+ * @param dp - Price decimal places (wc_get_price_decimals), default 2
988
+ * @param perRatePrecision - Decimals each rate is rounded to. Defaults to the cart-space
989
+ * precision below; order-item callers pass `getRoundingPrecision(dp)` (#2344).
990
+ */
991
+ declare function calculateTaxes({ amount, rates, amountIncludesTax, dp, perRatePrecision, }: CalculateTaxesInput): CalculateTaxesResult;
992
+
993
+ /**
994
+ * Filter tax rates based on the provided country, state, postcode, and city.
995
+ */
996
+ declare function filterTaxRates(taxRates: WooTaxRate[], country?: string, state?: string, postcode?: string, city?: string): WooTaxRate[];
997
+
998
+ /**
999
+ * WooCommerce-compatible precision and rounding utilities.
1000
+ *
1001
+ * These functions mirror the PHP implementations in:
1002
+ * - wc-core-functions.php (wc_get_rounding_precision, wc_add_number_precision, wc_remove_number_precision)
1003
+ * - wc-formatting-functions.php (wc_round_tax_total, wc_round_discount)
1004
+ * - class-woocommerce.php (WC_ROUNDING_PRECISION, WC_DISCOUNT_ROUNDING_MODE, WC_TAX_ROUNDING_MODE)
1005
+ */
1006
+ /**
1007
+ * Equivalent to PHP's round() with PHP_ROUND_HALF_UP (mode 1).
1008
+ * This is the default rounding in most languages, including JS Math.round for positive numbers,
1009
+ * but we need an explicit implementation that handles arbitrary precision.
1010
+ */
1011
+ declare function roundHalfUp(value: number, precision: number): number;
1012
+ /**
1013
+ * Equivalent to PHP's round() with PHP_ROUND_HALF_DOWN (mode 2).
1014
+ * When the value is exactly at the midpoint (e.g., 2.725 with precision 2),
1015
+ * it rounds DOWN (toward zero) instead of up.
1016
+ *
1017
+ * WooCommerce uses this for:
1018
+ * - Tax rounding when prices_include_tax = 'yes' (WC_TAX_ROUNDING_MODE = PHP_ROUND_HALF_DOWN)
1019
+ * - Discount rounding (WC_DISCOUNT_ROUNDING_MODE = PHP_ROUND_HALF_DOWN)
1020
+ */
1021
+ declare function roundHalfDown(value: number, precision: number): number;
1022
+ /**
1023
+ * WC: wc_get_rounding_precision()
1024
+ * Returns max(dp + 2, WC_ROUNDING_PRECISION) where WC_ROUNDING_PRECISION = 6.
1025
+ */
1026
+ declare function getRoundingPrecision(dp: number): number;
1027
+ /**
1028
+ * WC: wc_add_number_precision($value, $round)
1029
+ * Shifts a decimal value into "cents" (integer precision).
1030
+ *
1031
+ * e.g., with dp=2: 9.99 -> 999
1032
+ *
1033
+ * The $round parameter controls the rounding precision after multiplication:
1034
+ * - true (default): round to (roundingPrecision - dp) places, e.g. 6-2=4
1035
+ * - false: round to roundingPrecision places, e.g. 6
1036
+ */
1037
+ declare function addNumberPrecision(value: number, dp: number, round?: boolean): number;
1038
+ /**
1039
+ * WC: wc_remove_number_precision($value)
1040
+ * Shifts a "cents" value back to decimal.
1041
+ *
1042
+ * e.g., with dp=2: 999 -> 9.99
1043
+ */
1044
+ declare function removeNumberPrecision(value: number, dp: number): number;
1045
+ /**
1046
+ * WC: wc_round_tax_total($value, $precision)
1047
+ * Rounds a tax total using the appropriate rounding mode:
1048
+ * - HALF_DOWN when prices include tax (WC_TAX_ROUNDING_MODE = PHP_ROUND_HALF_DOWN)
1049
+ * - HALF_UP when prices exclude tax (WC_TAX_ROUNDING_MODE = PHP_ROUND_HALF_UP)
1050
+ *
1051
+ * @param value - The tax value to round
1052
+ * @param dp - The number of decimal places (wc_get_price_decimals)
1053
+ * @param pricesIncludeTax - Whether prices include tax
1054
+ * @param precision - Override precision (defaults to dp). Pass 0 for cent-precision rounding.
1055
+ */
1056
+ declare function roundTaxTotal(value: number, dp: number, pricesIncludeTax: boolean, precision?: number): number;
1057
+
1058
+ declare function sumTaxes({ taxes }: {
1059
+ taxes: {
1060
+ total: number;
1061
+ [key: string]: any;
1062
+ }[];
1063
+ }): number;
1064
+ declare function sumItemizedTaxes({ taxes }: {
1065
+ taxes: (ItemizedTax | ItemizedTax[])[];
1066
+ }): {
1067
+ id: number;
1068
+ total: number;
1069
+ }[];
1070
+
1071
+ /**
1072
+ * The WooCommerce REST API spells the standard tax class as an empty string on
1073
+ * order documents and line items (the wc/v3 taxes endpoint spells rate classes
1074
+ * 'standard'). Every read of an item's tax_class for rate matching must
1075
+ * normalize through this helper; the sites that inline the ternary are exactly
1076
+ * the ones that drift.
1077
+ *
1078
+ * The UI ⇄ wire codec for the same quirk lives below in this module.
1079
+ */
1080
+ declare const STANDARD_TAX_CLASS = "standard";
1081
+ declare function normalizeTaxClass(value?: string | null): string;
1082
+ /** Resolved to "no shipping tax at all", which is distinct from "the standard class". */
1083
+ declare const NO_SHIPPING_TAX: null;
1084
+ /**
1085
+ * Port of the `'inherit'` branch of `WC_Abstract_Order::calculate_taxes()` — the path
1086
+ * WooCommerce takes for an order, which is what this package builds (the storefront's
1087
+ * `WC_Tax::get_shipping_tax_rates()` reaches the same answer through the live cart).
1088
+ *
1089
+ * ```php
1090
+ * $found_classes = array_intersect( array_merge( array( '' ), WC_Tax::get_tax_class_slugs() ), $this->get_items_tax_classes() );
1091
+ * $shipping_tax_class = count( $found_classes ) ? current( $found_classes ) : false;
1092
+ * // Orders without product line items have no tax class to inherit, so use the standard class.
1093
+ * if ( false === $shipping_tax_class && 0 === count( $this->get_items() ) ) {
1094
+ * $shipping_tax_class = '';
1095
+ * }
1096
+ * ```
1097
+ *
1098
+ * Three details the PHP encodes positionally and are easy to lose in a port:
1099
+ *
1100
+ * 1. `array_intersect` preserves the order of its FIRST argument, so the candidate
1101
+ * order is the configured tax-class order with the standard class ahead of it —
1102
+ * **the standard class wins whenever any line item carries it**, never "the first
1103
+ * class in the cart".
1104
+ * 2. `get_items()` defaults to `'line_item'`, so **fee lines are not inherited from**,
1105
+ * and only line items count toward the "no items" fallback.
1106
+ * 3. `get_items_tax_classes()` skips items that are not taxable. Line items that exist
1107
+ * but are all non-taxable therefore give `false`, not `''` — and WooCommerce then
1108
+ * charges **no shipping tax**. Returning the standard class there would invent tax
1109
+ * on an order WooCommerce leaves untaxed.
1110
+ */
1111
+ declare function resolveInheritedShippingTaxClass(activeLineItems: readonly {
1112
+ tax_class?: string | null;
1113
+ taxable: boolean;
1114
+ }[], taxClassSlugs: readonly string[]): string | typeof NO_SHIPPING_TAX;
1115
+ /**
1116
+ * The WooCommerce REST API spells the standard tax class as an empty string and
1117
+ * rejects the literal 'standard' with an error, while UI selects can't hold ''
1118
+ * as a value — so the app spells it 'standard'. Every read of a wire/document
1119
+ * tax_class and every write back to one must go through this codec; the sites
1120
+ * that inline the ternary are exactly the ones that drift.
1121
+ */
1122
+ declare function taxClassFromWire(value?: string | null): string;
1123
+ declare function taxClassToWire(value?: string | null): string;
1124
+
1125
+ type index_CalculateTaxesInput = CalculateTaxesInput;
1126
+ type index_CalculateTaxesResult = CalculateTaxesResult;
1127
+ type index_ItemizedTax = ItemizedTax;
1128
+ declare const index_NO_SHIPPING_TAX: typeof NO_SHIPPING_TAX;
1129
+ declare const index_STANDARD_TAX_CLASS: typeof STANDARD_TAX_CLASS;
1130
+ type index_WooTaxRate = WooTaxRate;
1131
+ declare const index_addNumberPrecision: typeof addNumberPrecision;
1132
+ declare const index_calculateTaxes: typeof calculateTaxes;
1133
+ declare const index_filterTaxRates: typeof filterTaxRates;
1134
+ declare const index_getRoundingPrecision: typeof getRoundingPrecision;
1135
+ declare const index_normalizeTaxClass: typeof normalizeTaxClass;
1136
+ declare const index_removeNumberPrecision: typeof removeNumberPrecision;
1137
+ declare const index_resolveInheritedShippingTaxClass: typeof resolveInheritedShippingTaxClass;
1138
+ declare const index_roundHalfDown: typeof roundHalfDown;
1139
+ declare const index_roundHalfUp: typeof roundHalfUp;
1140
+ declare const index_roundTaxTotal: typeof roundTaxTotal;
1141
+ declare const index_sumItemizedTaxes: typeof sumItemizedTaxes;
1142
+ declare const index_sumTaxes: typeof sumTaxes;
1143
+ declare const index_taxClassFromWire: typeof taxClassFromWire;
1144
+ declare const index_taxClassToWire: typeof taxClassToWire;
1145
+ declare namespace index {
1146
+ export { type index_CalculateTaxesInput as CalculateTaxesInput, type index_CalculateTaxesResult as CalculateTaxesResult, type index_ItemizedTax as ItemizedTax, index_NO_SHIPPING_TAX as NO_SHIPPING_TAX, index_STANDARD_TAX_CLASS as STANDARD_TAX_CLASS, type index_WooTaxRate as WooTaxRate, index_addNumberPrecision as addNumberPrecision, index_calculateTaxes as calculateTaxes, index_filterTaxRates as filterTaxRates, index_getRoundingPrecision as getRoundingPrecision, index_normalizeTaxClass as normalizeTaxClass, index_removeNumberPrecision as removeNumberPrecision, index_resolveInheritedShippingTaxClass as resolveInheritedShippingTaxClass, index_roundHalfDown as roundHalfDown, index_roundHalfUp as roundHalfUp, index_roundTaxTotal as roundTaxTotal, index_sumItemizedTaxes as sumItemizedTaxes, index_sumTaxes as sumTaxes, index_taxClassFromWire as taxClassFromWire, index_taxClassToWire as taxClassToWire };
1147
+ }
1148
+
1149
+ export { type AuthField, type CatalogueReconcileAdapter, type CatalogueReconcileEntry, type CollectionSync, CommandWarning, type ConnectorAuth, ConnectorProvider, type ConnectorProviderProps, type ConnectorSchemas, type ConnectorTraits, ConnectorUnauthorizedError, type Customer, type CustomerInput, CustomerServiceError, type CustomerTraits, type ErrorKind, type FingerprintReconcileAdapter, type IdReconcileAdapter, type KeyedReconcileFeedOptions, type Money, type ProductPrice, type ProductTraits, type ReconcileFeed, type ReconcileFeedEntry, type ReconcileFetchEntry, type RemoteIdEntry, type ReplicationAdapter, type ResolvedPrice, STOCK_LEVELS_LAST_PASS, type ServerCapabilities, SignInError, type SignInErrorCode, type SignInResult, type StockLevel, type StockReconcileAdapter, type StockStatus, type StoreSettings, type StoreSettingsChoice, type StoreSettingsChoices, StoreSettingsError, type StoreSettingsErrorCode, type SyncContext, type SyncNotice, type TallyConnector, type TaxRounding, type TraitContext, type VariantSummary, combinePullAdapters, compareIds, createReconcileFeed, currencySymbol, customerTraits, errorKind, findVariantByCode, formatMoney, getProductStock, isRxdbRemoteVersionMismatch, knownWarnings, minorUnitDigits, moneyFromDecimalString, moneyFromMajor, moneyToMajor, parseInfoCapabilities, parseLineTax, parseTaxRounding, resolveCapabilities, resolvePrice, resolvePriceRange, useConnector, useCustomerTraits, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay, index as woocommerceTax };