@final-commerce/common 2.10.0 → 2.11.1-online.1
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/bin/gate-done.mjs +11 -24
- package/dist/index.d.mts +297 -20
- package/dist/index.d.ts +297 -20
- package/dist/index.js +671 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +636 -20
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +440 -337
- package/dist/pos-types/index.d.ts +440 -337
- package/dist/pos-types/index.js +1 -0
- package/dist/pos-types/index.js.map +1 -1
- package/dist/pos-types/index.mjs +1 -0
- package/dist/pos-types/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
BookingResourceStatus: () => BookingResourceStatus,
|
|
37
37
|
BookingRulesError: () => BookingRulesError,
|
|
38
38
|
BookingType: () => BookingType,
|
|
39
|
+
CANADA_PROVINCES: () => CANADA_PROVINCES,
|
|
39
40
|
CONDITION_OPERATORS: () => CONDITION_OPERATORS,
|
|
40
41
|
COUNTRY_CURRENCIES: () => COUNTRY_CURRENCIES,
|
|
41
42
|
CURRENCY_CONFIG: () => CURRENCY_CONFIG,
|
|
@@ -52,6 +53,7 @@ __export(index_exports, {
|
|
|
52
53
|
DualWriteStrategy: () => DualWriteStrategy,
|
|
53
54
|
EUFixedRates: () => EUFixedRates,
|
|
54
55
|
EUROPE: () => EUROPE,
|
|
56
|
+
EVERYWHERE_KEY: () => EVERYWHERE_KEY,
|
|
55
57
|
EXPENSE_DEFAULT_CATEGORIES: () => EXPENSE_DEFAULT_CATEGORIES,
|
|
56
58
|
EXPENSE_NAME_MAX_LENGTH: () => EXPENSE_NAME_MAX_LENGTH,
|
|
57
59
|
EXPENSE_PAYMENT_METHOD_PRESETS: () => EXPENSE_PAYMENT_METHOD_PRESETS,
|
|
@@ -75,6 +77,7 @@ __export(index_exports, {
|
|
|
75
77
|
ORDER_STATE_TOPIC: () => ORDER_STATE_TOPIC,
|
|
76
78
|
OrderPlatform: () => OrderPlatform,
|
|
77
79
|
OtherFixedRates: () => OtherFixedRates,
|
|
80
|
+
OutOfProvinceTaxes: () => OutOfProvinceTaxes,
|
|
78
81
|
OwnerType: () => OwnerType,
|
|
79
82
|
PATH_MODES: () => PATH_MODES,
|
|
80
83
|
PAYMENT_CHANNELS: () => PAYMENT_CHANNELS,
|
|
@@ -102,6 +105,8 @@ __export(index_exports, {
|
|
|
102
105
|
ResidualPaymentMethod: () => ResidualPaymentMethod,
|
|
103
106
|
ResidualStatus: () => ResidualStatus,
|
|
104
107
|
ResourceAvailabilityState: () => ResourceAvailabilityState,
|
|
108
|
+
SHIPPING_COUNTRIES: () => SHIPPING_COUNTRIES,
|
|
109
|
+
STANDARD_TAX_TYPE: () => STANDARD_TAX_TYPE,
|
|
105
110
|
STATE_SCHEMA: () => STATE_SCHEMA,
|
|
106
111
|
STRIPE_SUPPORTED_COUNTRIES: () => STRIPE_SUPPORTED_COUNTRIES,
|
|
107
112
|
SYSTEM_FAMILIES: () => SYSTEM_FAMILIES,
|
|
@@ -110,13 +115,23 @@ __export(index_exports, {
|
|
|
110
115
|
SYSTEM_UNIT_IDS: () => SYSTEM_UNIT_IDS,
|
|
111
116
|
SalesLineAction: () => SalesLineAction,
|
|
112
117
|
SalesLineSourceArray: () => SalesLineSourceArray,
|
|
118
|
+
ShippingChannel: () => ShippingChannel,
|
|
119
|
+
ShippingNoOptionReason: () => ShippingNoOptionReason,
|
|
120
|
+
ShippingOptionType: () => ShippingOptionType,
|
|
121
|
+
ShippingRateType: () => ShippingRateType,
|
|
122
|
+
ShippingZoneError: () => ShippingZoneError,
|
|
123
|
+
ShippingZoneKind: () => ShippingZoneKind,
|
|
113
124
|
StationStatus: () => StationStatus,
|
|
114
125
|
StripeCurrencyCode: () => StripeCurrencyCode,
|
|
115
126
|
StripeStatus: () => StripeStatus,
|
|
127
|
+
TaxRegistrationKind: () => TaxRegistrationKind,
|
|
128
|
+
TaxSource: () => TaxSource,
|
|
129
|
+
TaxWarningCode: () => TaxWarningCode,
|
|
116
130
|
TimePeriod: () => TimePeriod,
|
|
117
131
|
TopMetericsSort: () => TopMetericsSort,
|
|
118
132
|
UserTypes: () => UserTypes,
|
|
119
133
|
addAmounts: () => addAmounts,
|
|
134
|
+
addressPlaceKeys: () => addressPlaceKeys,
|
|
120
135
|
adyenLegalEntityRequiresStateOrProvince: () => adyenLegalEntityRequiresStateOrProvince,
|
|
121
136
|
adyenRequiresJobTitle: () => adyenRequiresJobTitle,
|
|
122
137
|
adyenStoreRequiresStateOrProvince: () => adyenStoreRequiresStateOrProvince,
|
|
@@ -126,11 +141,13 @@ __export(index_exports, {
|
|
|
126
141
|
ancestorChain: () => ancestorChain,
|
|
127
142
|
applyAssignment: () => applyAssignment,
|
|
128
143
|
assertUnitSane: () => assertUnitSane,
|
|
144
|
+
automaticTaxTableVersion: () => automaticTaxTableVersion,
|
|
129
145
|
availableIn: () => availableIn,
|
|
130
146
|
baseFor: () => baseFor,
|
|
131
147
|
baseFulfillmentDefinitions: () => baseFulfillmentDefinitions,
|
|
132
148
|
baseOf: () => baseOf,
|
|
133
149
|
basePaymentDefinitions: () => basePaymentDefinitions,
|
|
150
|
+
buildAutomaticTaxTable: () => buildAutomaticTaxTable,
|
|
134
151
|
buildAvailability: () => buildAvailability,
|
|
135
152
|
buildGrid: () => buildGrid,
|
|
136
153
|
buildOrderContext: () => buildOrderContext,
|
|
@@ -197,31 +214,48 @@ __export(index_exports, {
|
|
|
197
214
|
isSystemFamilyCode: () => isSystemFamilyCode,
|
|
198
215
|
isValidQuantity: () => isValidQuantity,
|
|
199
216
|
isWhole: () => isWhole,
|
|
217
|
+
lineStockMoves: () => lineStockMoves,
|
|
218
|
+
listCountries: () => listCountries,
|
|
219
|
+
listProvinces: () => listProvinces,
|
|
220
|
+
listShippingCountries: () => listShippingCountries,
|
|
200
221
|
mapToLegacyStatus: () => mapToLegacyStatus,
|
|
201
222
|
maxPrecisionFor: () => maxPrecisionFor,
|
|
202
223
|
mergeFragment: () => mergeFragment,
|
|
203
224
|
modifiersSellable: () => modifiersSellable,
|
|
204
225
|
multiplyAmount: () => multiplyAmount,
|
|
226
|
+
normalizeAddress: () => normalizeAddress,
|
|
227
|
+
normalizeCityKey: () => normalizeCityKey,
|
|
228
|
+
normalizeCountry: () => normalizeCountry,
|
|
205
229
|
normalizeMongoIdString: () => normalizeMongoIdString,
|
|
230
|
+
normalizePostCode: () => normalizePostCode,
|
|
231
|
+
normalizeProvince: () => normalizeProvince,
|
|
206
232
|
occupancyIn: () => occupancyIn,
|
|
207
233
|
orderAssignments: () => orderAssignments,
|
|
208
234
|
parseAmountToMinorUnits: () => parseAmountToMinorUnits,
|
|
209
235
|
parseCurrencyCode: () => parseCurrencyCode,
|
|
210
236
|
parseStripeCurrencyCode: () => parseStripeCurrencyCode,
|
|
237
|
+
placeKey: () => placeKey,
|
|
211
238
|
planWindow: () => planWindow,
|
|
212
239
|
poolDemand: () => poolDemand,
|
|
213
240
|
poolOf: () => poolOf,
|
|
214
241
|
poolShortfall: () => poolShortfall,
|
|
215
242
|
poolStockAt: () => poolStockAt,
|
|
243
|
+
postCodeMatchesProvince: () => postCodeMatchesProvince,
|
|
216
244
|
presentAt: () => presentAt,
|
|
245
|
+
priceForTotal: () => priceForTotal,
|
|
246
|
+
provincesForPostCode: () => provincesForPostCode,
|
|
247
|
+
registrationPlacesByKind: () => registrationPlacesByKind,
|
|
217
248
|
removeFragment: () => removeFragment,
|
|
218
249
|
resolveFamily: () => resolveFamily,
|
|
219
250
|
resolveModifiersForProduct: () => resolveModifiersForProduct,
|
|
251
|
+
resolveShipping: () => resolveShipping,
|
|
220
252
|
resolveTemplate: () => resolveTemplate,
|
|
221
253
|
resolveUnit: () => resolveUnit,
|
|
222
254
|
roundToPrecision: () => roundToPrecision,
|
|
223
255
|
sameFamily: () => sameFamily,
|
|
224
256
|
setOrderState: () => setOrderState,
|
|
257
|
+
sha1Hex: () => sha1Hex,
|
|
258
|
+
shipsToCountry: () => shipsToCountry,
|
|
225
259
|
shopDayKey: () => shopDayKey,
|
|
226
260
|
shopDayRange: () => shopDayRange,
|
|
227
261
|
signReportForDisplay: () => signReportForDisplay,
|
|
@@ -233,6 +267,7 @@ __export(index_exports, {
|
|
|
233
267
|
validateConfig: () => validateConfig,
|
|
234
268
|
validateFragmentCompatibility: () => validateFragmentCompatibility,
|
|
235
269
|
validateOrderStatuses: () => validateOrderStatuses,
|
|
270
|
+
validateShippingZone: () => validateShippingZone,
|
|
236
271
|
violatesFinancialInvariant: () => violatesFinancialInvariant,
|
|
237
272
|
windowEndsAt: () => windowEndsAt,
|
|
238
273
|
withinPresence: () => withinPresence
|
|
@@ -441,6 +476,7 @@ var OrderPlatform = /* @__PURE__ */ ((OrderPlatform2) => {
|
|
|
441
476
|
OrderPlatform2["POS"] = "in-store";
|
|
442
477
|
OrderPlatform2["WOO_COMMERCE"] = "woo-commerce";
|
|
443
478
|
OrderPlatform2["PUBLIC_API"] = "public-api";
|
|
479
|
+
OrderPlatform2["ONLINE_STORE"] = "online-store";
|
|
444
480
|
return OrderPlatform2;
|
|
445
481
|
})(OrderPlatform || {});
|
|
446
482
|
var CustomerPlatform = /* @__PURE__ */ ((CustomerPlatform2) => {
|
|
@@ -737,6 +773,74 @@ var ResourceAvailabilityState = /* @__PURE__ */ ((ResourceAvailabilityState2) =>
|
|
|
737
773
|
return ResourceAvailabilityState2;
|
|
738
774
|
})(ResourceAvailabilityState || {});
|
|
739
775
|
|
|
776
|
+
// enums/shipping.enum.ts
|
|
777
|
+
var ShippingZoneKind = /* @__PURE__ */ ((ShippingZoneKind2) => {
|
|
778
|
+
ShippingZoneKind2["COUNTRY"] = "country";
|
|
779
|
+
ShippingZoneKind2["PROVINCE"] = "province";
|
|
780
|
+
ShippingZoneKind2["CITY"] = "city";
|
|
781
|
+
ShippingZoneKind2["EVERYWHERE"] = "everywhere";
|
|
782
|
+
return ShippingZoneKind2;
|
|
783
|
+
})(ShippingZoneKind || {});
|
|
784
|
+
var ShippingOptionType = /* @__PURE__ */ ((ShippingOptionType2) => {
|
|
785
|
+
ShippingOptionType2["SHIP"] = "ship";
|
|
786
|
+
ShippingOptionType2["PICKUP"] = "pickup";
|
|
787
|
+
return ShippingOptionType2;
|
|
788
|
+
})(ShippingOptionType || {});
|
|
789
|
+
var ShippingRateType = /* @__PURE__ */ ((ShippingRateType2) => {
|
|
790
|
+
ShippingRateType2["FLAT"] = "flat";
|
|
791
|
+
return ShippingRateType2;
|
|
792
|
+
})(ShippingRateType || {});
|
|
793
|
+
var ShippingChannel = /* @__PURE__ */ ((ShippingChannel2) => {
|
|
794
|
+
ShippingChannel2["WEB"] = "web";
|
|
795
|
+
ShippingChannel2["POS"] = "pos";
|
|
796
|
+
return ShippingChannel2;
|
|
797
|
+
})(ShippingChannel || {});
|
|
798
|
+
var ShippingNoOptionReason = /* @__PURE__ */ ((ShippingNoOptionReason2) => {
|
|
799
|
+
ShippingNoOptionReason2["INCOMPLETE"] = "INCOMPLETE";
|
|
800
|
+
ShippingNoOptionReason2["ADDRESS_MISMATCH"] = "ADDRESS_MISMATCH";
|
|
801
|
+
ShippingNoOptionReason2["NO_COVERAGE"] = "NO_COVERAGE";
|
|
802
|
+
ShippingNoOptionReason2["BLOCKED"] = "BLOCKED";
|
|
803
|
+
ShippingNoOptionReason2["NO_OPTION"] = "NO_OPTION";
|
|
804
|
+
return ShippingNoOptionReason2;
|
|
805
|
+
})(ShippingNoOptionReason || {});
|
|
806
|
+
var ShippingZoneError = /* @__PURE__ */ ((ShippingZoneError2) => {
|
|
807
|
+
ShippingZoneError2["NO_PLACES"] = "NO_PLACES";
|
|
808
|
+
ShippingZoneError2["INVALID_PLACE"] = "INVALID_PLACE";
|
|
809
|
+
ShippingZoneError2["DUPLICATE_PLACE"] = "DUPLICATE_PLACE";
|
|
810
|
+
ShippingZoneError2["NO_WEBSITE_OPTION"] = "NO_WEBSITE_OPTION";
|
|
811
|
+
ShippingZoneError2["INVALID_PRICE"] = "INVALID_PRICE";
|
|
812
|
+
ShippingZoneError2["INVALID_DAYS"] = "INVALID_DAYS";
|
|
813
|
+
ShippingZoneError2["INVALID_TIERS"] = "INVALID_TIERS";
|
|
814
|
+
ShippingZoneError2["NO_CHANNEL"] = "NO_CHANNEL";
|
|
815
|
+
ShippingZoneError2["PICKUP_WITHOUT_STORE"] = "PICKUP_WITHOUT_STORE";
|
|
816
|
+
ShippingZoneError2["MISSING_NAME"] = "MISSING_NAME";
|
|
817
|
+
return ShippingZoneError2;
|
|
818
|
+
})(ShippingZoneError || {});
|
|
819
|
+
|
|
820
|
+
// enums/tax.enum.ts
|
|
821
|
+
var TaxRegistrationKind = /* @__PURE__ */ ((TaxRegistrationKind2) => {
|
|
822
|
+
TaxRegistrationKind2["GST_HST"] = "GST_HST";
|
|
823
|
+
TaxRegistrationKind2["PST"] = "PST";
|
|
824
|
+
TaxRegistrationKind2["QST"] = "QST";
|
|
825
|
+
return TaxRegistrationKind2;
|
|
826
|
+
})(TaxRegistrationKind || {});
|
|
827
|
+
var TaxSource = /* @__PURE__ */ ((TaxSource2) => {
|
|
828
|
+
TaxSource2["MERCHANT"] = "merchant";
|
|
829
|
+
TaxSource2["AUTOMATIC"] = "automatic";
|
|
830
|
+
return TaxSource2;
|
|
831
|
+
})(TaxSource || {});
|
|
832
|
+
var OutOfProvinceTaxes = /* @__PURE__ */ ((OutOfProvinceTaxes2) => {
|
|
833
|
+
OutOfProvinceTaxes2["AUTOMATIC"] = "automatic";
|
|
834
|
+
OutOfProvinceTaxes2["HOME"] = "home";
|
|
835
|
+
return OutOfProvinceTaxes2;
|
|
836
|
+
})(OutOfProvinceTaxes || {});
|
|
837
|
+
var TaxWarningCode = /* @__PURE__ */ ((TaxWarningCode2) => {
|
|
838
|
+
TaxWarningCode2["NOT_REGISTERED"] = "NOT_REGISTERED";
|
|
839
|
+
TaxWarningCode2["NO_RULES_FOR_PLACE"] = "NO_RULES_FOR_PLACE";
|
|
840
|
+
TaxWarningCode2["NO_TABLE"] = "NO_TABLE";
|
|
841
|
+
return TaxWarningCode2;
|
|
842
|
+
})(TaxWarningCode || {});
|
|
843
|
+
|
|
740
844
|
// enums/sales-line.enum.ts
|
|
741
845
|
var SalesLineAction = /* @__PURE__ */ ((SalesLineAction2) => {
|
|
742
846
|
SalesLineAction2["SALE"] = "sale";
|
|
@@ -1935,6 +2039,48 @@ function compositeReservationMismatches(order) {
|
|
|
1935
2039
|
});
|
|
1936
2040
|
}
|
|
1937
2041
|
|
|
2042
|
+
// utils/line-stock-moves.util.ts
|
|
2043
|
+
function lineStockMoves(item, quantity, reservations = []) {
|
|
2044
|
+
const sign = Math.sign(quantity);
|
|
2045
|
+
const pool = (stockVariantId) => stockVariantId ? { stockVariantId: stockVariantId.toString() } : {};
|
|
2046
|
+
if (!item.components?.length)
|
|
2047
|
+
return [
|
|
2048
|
+
{
|
|
2049
|
+
productId: item.productId.toString(),
|
|
2050
|
+
variantId: item.variantId.toString(),
|
|
2051
|
+
fields: {
|
|
2052
|
+
quantity,
|
|
2053
|
+
...item.stockQuantity != null ? { stockQuantity: sign * item.stockQuantity, unitId: item.unitId?.toString() } : {},
|
|
2054
|
+
...pool(item.stockVariantId)
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
];
|
|
2058
|
+
const booked = new Set(
|
|
2059
|
+
reservations.filter((reservation) => reservation.lineItemInternalId && reservation.lineItemInternalId === item.internalId).map((reservation) => reservation.componentIndex)
|
|
2060
|
+
);
|
|
2061
|
+
return item.components.flatMap((component, componentIndex) => {
|
|
2062
|
+
if (booked.has(componentIndex)) return [];
|
|
2063
|
+
if (component.unitId && component.stockQuantity == null)
|
|
2064
|
+
throw new Error(
|
|
2065
|
+
`Composite ${item.productId?.toString()} component ${component.variantId.toString()} is sold in ${component.unitId.toString()} but carries no stockQuantity`
|
|
2066
|
+
);
|
|
2067
|
+
return [
|
|
2068
|
+
{
|
|
2069
|
+
productId: component.productId.toString(),
|
|
2070
|
+
variantId: component.variantId.toString(),
|
|
2071
|
+
componentIndex,
|
|
2072
|
+
fields: {
|
|
2073
|
+
quantity: component.quantity * quantity,
|
|
2074
|
+
...component.stockQuantity != null ? { stockQuantity: component.stockQuantity * quantity, unitId: component.unitId?.toString() } : {},
|
|
2075
|
+
...pool(component.stockVariantId),
|
|
2076
|
+
...item.productId ? { compositeProductId: item.productId.toString() } : {},
|
|
2077
|
+
...item.name ? { compositeName: item.name } : {}
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
];
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1938
2084
|
// units/family-code.ts
|
|
1939
2085
|
var MAX_SLUG_LENGTH = 32;
|
|
1940
2086
|
var FALLBACK_SLUG = "family";
|
|
@@ -3871,6 +4017,475 @@ function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy = [] }
|
|
|
3871
4017
|
}
|
|
3872
4018
|
var holdExpiresAt = (rule, now) => new Date(now.getTime() + (rule.window.holdMinutes ?? DEFAULT_HOLD_MINUTES) * 6e4);
|
|
3873
4019
|
|
|
4020
|
+
// shipping/fold-text.ts
|
|
4021
|
+
function foldText(value) {
|
|
4022
|
+
return value.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/&/g, " and ").replace(/[^a-z0-9]+/g, " ").trim();
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
// shipping/countries.ts
|
|
4026
|
+
var NOT_COUNTRIES = /* @__PURE__ */ new Set(["AC", "CP", "CQ", "DG", "EA", "EU", "EZ", "IC", "QO", "TA", "UN", "XA", "XB", "ZZ"]);
|
|
4027
|
+
var ALIASES = {
|
|
4028
|
+
canada: "CA",
|
|
4029
|
+
"united states": "US",
|
|
4030
|
+
usa: "US",
|
|
4031
|
+
"united states of america": "US",
|
|
4032
|
+
uk: "GB",
|
|
4033
|
+
"great britain": "GB",
|
|
4034
|
+
england: "GB",
|
|
4035
|
+
uae: "AE",
|
|
4036
|
+
can: "CA",
|
|
4037
|
+
mex: "MX",
|
|
4038
|
+
aus: "AU",
|
|
4039
|
+
gbr: "GB"
|
|
4040
|
+
};
|
|
4041
|
+
var NAME_LOCALES = ["en", "fr"];
|
|
4042
|
+
function regionNames(locale) {
|
|
4043
|
+
try {
|
|
4044
|
+
return new Intl.DisplayNames([locale], { type: "region", fallback: "none" });
|
|
4045
|
+
} catch {
|
|
4046
|
+
return null;
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
function canonicalCode(code) {
|
|
4050
|
+
try {
|
|
4051
|
+
return new Intl.Locale(`und-${code}`).maximize().region ?? code;
|
|
4052
|
+
} catch {
|
|
4053
|
+
return code;
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
function allCodes() {
|
|
4057
|
+
const names = regionNames("en");
|
|
4058
|
+
if (!names) return [];
|
|
4059
|
+
const codes2 = [];
|
|
4060
|
+
for (let a = 65; a <= 90; a++) {
|
|
4061
|
+
for (let b = 65; b <= 90; b++) {
|
|
4062
|
+
const code = String.fromCharCode(a, b);
|
|
4063
|
+
if (!NOT_COUNTRIES.has(code) && names.of(code) && canonicalCode(code) === code) codes2.push(code);
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
return codes2;
|
|
4067
|
+
}
|
|
4068
|
+
var lookup = null;
|
|
4069
|
+
var codes = null;
|
|
4070
|
+
function countryCodes() {
|
|
4071
|
+
codes ??= allCodes();
|
|
4072
|
+
return codes;
|
|
4073
|
+
}
|
|
4074
|
+
function countryLookup() {
|
|
4075
|
+
if (lookup) return lookup;
|
|
4076
|
+
lookup = new Map(Object.entries(ALIASES));
|
|
4077
|
+
for (const locale of NAME_LOCALES) {
|
|
4078
|
+
const names = regionNames(locale);
|
|
4079
|
+
if (!names) continue;
|
|
4080
|
+
for (const code of countryCodes()) {
|
|
4081
|
+
const name = names.of(code);
|
|
4082
|
+
if (name) lookup.set(foldText(name), code);
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
return lookup;
|
|
4086
|
+
}
|
|
4087
|
+
function normalizeCountry(value) {
|
|
4088
|
+
const text = (value ?? "").trim();
|
|
4089
|
+
if (!text) return void 0;
|
|
4090
|
+
const upper = text.toUpperCase();
|
|
4091
|
+
if (upper.length === 2) {
|
|
4092
|
+
if (NOT_COUNTRIES.has(upper)) return void 0;
|
|
4093
|
+
if (countryCodes().length === 0) return /^[A-Z]{2}$/.test(upper) ? upper : void 0;
|
|
4094
|
+
const code = canonicalCode(upper);
|
|
4095
|
+
if (countryCodes().includes(code)) return code;
|
|
4096
|
+
}
|
|
4097
|
+
return countryLookup().get(foldText(text));
|
|
4098
|
+
}
|
|
4099
|
+
function listCountries(locale = "en") {
|
|
4100
|
+
const names = regionNames(locale) ?? regionNames("en");
|
|
4101
|
+
return countryCodes().map((code) => ({ code, name: names?.of(code) ?? code })).sort((a, b) => a.name.localeCompare(b.name, locale));
|
|
4102
|
+
}
|
|
4103
|
+
var SHIPPING_COUNTRIES = ["CA"];
|
|
4104
|
+
function shipsToCountry(code) {
|
|
4105
|
+
return !!code && SHIPPING_COUNTRIES.includes(code);
|
|
4106
|
+
}
|
|
4107
|
+
function listShippingCountries(locale = "en") {
|
|
4108
|
+
const names = regionNames(locale) ?? regionNames("en");
|
|
4109
|
+
return SHIPPING_COUNTRIES.map((code) => ({ code, name: names?.of(code) ?? code })).sort(
|
|
4110
|
+
(a, b) => a.name.localeCompare(b.name, locale)
|
|
4111
|
+
);
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
// shipping/provinces.ts
|
|
4115
|
+
var CANADA_PROVINCES = [
|
|
4116
|
+
{ code: "AB", name: "Alberta", nameFr: "Alberta", postalLetters: ["T"] },
|
|
4117
|
+
{ code: "BC", name: "British Columbia", nameFr: "Colombie-Britannique", postalLetters: ["V"] },
|
|
4118
|
+
{ code: "MB", name: "Manitoba", nameFr: "Manitoba", postalLetters: ["R"] },
|
|
4119
|
+
{ code: "NB", name: "New Brunswick", nameFr: "Nouveau-Brunswick", postalLetters: ["E"] },
|
|
4120
|
+
{
|
|
4121
|
+
code: "NL",
|
|
4122
|
+
name: "Newfoundland and Labrador",
|
|
4123
|
+
nameFr: "Terre-Neuve-et-Labrador",
|
|
4124
|
+
postalLetters: ["A"],
|
|
4125
|
+
aliases: ["NF", "LB", "Newfoundland", "Labrador"]
|
|
4126
|
+
},
|
|
4127
|
+
{ code: "NS", name: "Nova Scotia", nameFr: "Nouvelle-\xC9cosse", postalLetters: ["B"] },
|
|
4128
|
+
{ code: "NT", name: "Northwest Territories", nameFr: "Territoires du Nord-Ouest", postalLetters: ["X"] },
|
|
4129
|
+
{ code: "NU", name: "Nunavut", nameFr: "Nunavut", postalLetters: ["X"] },
|
|
4130
|
+
{ code: "ON", name: "Ontario", nameFr: "Ontario", postalLetters: ["K", "L", "M", "N", "P"] },
|
|
4131
|
+
{
|
|
4132
|
+
code: "PE",
|
|
4133
|
+
name: "Prince Edward Island",
|
|
4134
|
+
nameFr: "\xCEle-du-Prince-\xC9douard",
|
|
4135
|
+
postalLetters: ["C"],
|
|
4136
|
+
aliases: ["PEI"]
|
|
4137
|
+
},
|
|
4138
|
+
{ code: "QC", name: "Quebec", nameFr: "Qu\xE9bec", postalLetters: ["G", "H", "J"], aliases: ["PQ"] },
|
|
4139
|
+
{ code: "SK", name: "Saskatchewan", nameFr: "Saskatchewan", postalLetters: ["S"] },
|
|
4140
|
+
{ code: "YT", name: "Yukon", nameFr: "Yukon", postalLetters: ["Y"], aliases: ["YK"] }
|
|
4141
|
+
];
|
|
4142
|
+
var PROVINCES_BY_COUNTRY = { CA: CANADA_PROVINCES };
|
|
4143
|
+
var lookups = /* @__PURE__ */ new Map();
|
|
4144
|
+
function provinceLookup(country) {
|
|
4145
|
+
const provinces = PROVINCES_BY_COUNTRY[country];
|
|
4146
|
+
if (!provinces) return void 0;
|
|
4147
|
+
let lookup2 = lookups.get(country);
|
|
4148
|
+
if (!lookup2) {
|
|
4149
|
+
lookup2 = /* @__PURE__ */ new Map();
|
|
4150
|
+
for (const p of provinces) {
|
|
4151
|
+
for (const label of [p.code, p.name, p.nameFr, ...p.aliases ?? []]) lookup2.set(foldText(label), p.code);
|
|
4152
|
+
}
|
|
4153
|
+
lookups.set(country, lookup2);
|
|
4154
|
+
}
|
|
4155
|
+
return lookup2;
|
|
4156
|
+
}
|
|
4157
|
+
function normalizeProvince(country, value) {
|
|
4158
|
+
if (!country || !value?.trim()) return void 0;
|
|
4159
|
+
return provinceLookup(country)?.get(foldText(value));
|
|
4160
|
+
}
|
|
4161
|
+
function listProvinces(country) {
|
|
4162
|
+
return PROVINCES_BY_COUNTRY[country] ?? [];
|
|
4163
|
+
}
|
|
4164
|
+
function provincesForPostCode(country, postCode) {
|
|
4165
|
+
const letter = postCode?.charAt(0);
|
|
4166
|
+
if (!country || !letter) return [];
|
|
4167
|
+
return listProvinces(country).filter((p) => p.postalLetters.includes(letter)).map((p) => p.code);
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
// shipping/normalize.ts
|
|
4171
|
+
var EVERYWHERE_KEY = "*";
|
|
4172
|
+
function normalizeCityKey(value) {
|
|
4173
|
+
const words = foldText(value ?? "").split(" ").filter(Boolean).map((word) => word === "saint" ? "st" : word === "sainte" ? "ste" : word);
|
|
4174
|
+
return words.length ? words.join("") : void 0;
|
|
4175
|
+
}
|
|
4176
|
+
function normalizePostCode(value) {
|
|
4177
|
+
const compact = (value ?? "").replace(/[^0-9a-z]/gi, "").toUpperCase();
|
|
4178
|
+
return compact || void 0;
|
|
4179
|
+
}
|
|
4180
|
+
function normalizeAddress(address) {
|
|
4181
|
+
if (!address) return {};
|
|
4182
|
+
const country = normalizeCountry(address.country);
|
|
4183
|
+
const postCode = normalizePostCode(address.postCode ?? address.postalCode ?? address.zip);
|
|
4184
|
+
const fromPostCode = provincesForPostCode(country, postCode);
|
|
4185
|
+
const province = normalizeProvince(country, address.state ?? address.province) ?? (fromPostCode.length === 1 ? fromPostCode[0] : void 0);
|
|
4186
|
+
return { country, province, cityKey: normalizeCityKey(address.city), postCode };
|
|
4187
|
+
}
|
|
4188
|
+
function postCodeMatchesProvince(address) {
|
|
4189
|
+
const candidates = provincesForPostCode(address.country, address.postCode);
|
|
4190
|
+
if (!address.province || candidates.length === 0) return true;
|
|
4191
|
+
return candidates.includes(address.province);
|
|
4192
|
+
}
|
|
4193
|
+
function placeKey(place) {
|
|
4194
|
+
const country = normalizeCountry(place.country);
|
|
4195
|
+
if (!country) return void 0;
|
|
4196
|
+
if (!place.province) return country;
|
|
4197
|
+
const province = normalizeProvince(country, place.province);
|
|
4198
|
+
if (!province) return void 0;
|
|
4199
|
+
if (!place.city) return `${country}-${province}`;
|
|
4200
|
+
const city = normalizeCityKey(place.city);
|
|
4201
|
+
return city ? `${country}-${province}/${city}` : void 0;
|
|
4202
|
+
}
|
|
4203
|
+
function addressPlaceKeys(address) {
|
|
4204
|
+
const keys = [];
|
|
4205
|
+
if (address.country && address.province && address.cityKey) {
|
|
4206
|
+
keys.push(`${address.country}-${address.province}/${address.cityKey}`);
|
|
4207
|
+
}
|
|
4208
|
+
if (address.country && address.province) keys.push(`${address.country}-${address.province}`);
|
|
4209
|
+
if (address.country) keys.push(address.country);
|
|
4210
|
+
keys.push(EVERYWHERE_KEY);
|
|
4211
|
+
return keys;
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
// shipping/resolve.ts
|
|
4215
|
+
function resolveShipping({ zones, address, itemsTotal, channel }) {
|
|
4216
|
+
const shipsToCountries = countriesShippedTo(zones);
|
|
4217
|
+
const none = (reason, zone2) => ({
|
|
4218
|
+
zoneId: zone2?.id ?? null,
|
|
4219
|
+
options: [],
|
|
4220
|
+
reason,
|
|
4221
|
+
message: zone2?.message?.trim() || null,
|
|
4222
|
+
shipsToCountries
|
|
4223
|
+
});
|
|
4224
|
+
const normalized = normalizeAddress(address);
|
|
4225
|
+
if (!normalized.country) return none("INCOMPLETE" /* INCOMPLETE */);
|
|
4226
|
+
if (!shipsToCountry(normalized.country)) return none("NO_COVERAGE" /* NO_COVERAGE */);
|
|
4227
|
+
if (!postCodeMatchesProvince(normalized)) return none("ADDRESS_MISMATCH" /* ADDRESS_MISMATCH */);
|
|
4228
|
+
const zone = findZone(zones, addressPlaceKeys(normalized));
|
|
4229
|
+
if (!zone) return none("NO_COVERAGE" /* NO_COVERAGE */);
|
|
4230
|
+
const offered = zone.options.filter((option) => isOffered(option, zone, channel));
|
|
4231
|
+
if (offered.length === 0) {
|
|
4232
|
+
return none(zone.ships ? "NO_OPTION" /* NO_OPTION */ : "BLOCKED" /* BLOCKED */, zone);
|
|
4233
|
+
}
|
|
4234
|
+
const quotes = offered.map((option) => quote(option, zone.id, itemsTotal));
|
|
4235
|
+
const ship = quotes.filter((q) => q.type === "ship" /* SHIP */).sort((a, b) => a.amount - b.amount);
|
|
4236
|
+
const pickup = quotes.filter((q) => q.type === "pickup" /* PICKUP */).sort((a, b) => a.amount - b.amount);
|
|
4237
|
+
return {
|
|
4238
|
+
zoneId: zone.id,
|
|
4239
|
+
options: [...ship, ...pickup],
|
|
4240
|
+
reason: null,
|
|
4241
|
+
message: zone.ships ? null : zone.message?.trim() || null,
|
|
4242
|
+
shipsToCountries
|
|
4243
|
+
};
|
|
4244
|
+
}
|
|
4245
|
+
function findZone(zones, keys) {
|
|
4246
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
4247
|
+
for (const zone of zones) {
|
|
4248
|
+
for (const key of zoneKeys(zone)) if (!byKey.has(key)) byKey.set(key, zone);
|
|
4249
|
+
}
|
|
4250
|
+
for (const key of keys) {
|
|
4251
|
+
const zone = byKey.get(key);
|
|
4252
|
+
if (zone) return zone;
|
|
4253
|
+
}
|
|
4254
|
+
return void 0;
|
|
4255
|
+
}
|
|
4256
|
+
function zoneKeys(zone) {
|
|
4257
|
+
if (zone.kind === "everywhere" /* EVERYWHERE */) return [EVERYWHERE_KEY];
|
|
4258
|
+
return zone.places.map(placeKey).filter((key) => Boolean(key));
|
|
4259
|
+
}
|
|
4260
|
+
function isOffered(option, zone, channel) {
|
|
4261
|
+
if (!option.channels.some((c) => c === channel)) return false;
|
|
4262
|
+
if (option.type === "pickup" /* PICKUP */) return channel !== "pos" /* POS */;
|
|
4263
|
+
return zone.ships;
|
|
4264
|
+
}
|
|
4265
|
+
function priceForTotal(option, itemsTotal) {
|
|
4266
|
+
const tiers = [...option.priceByTotal ?? []].sort((a, b) => a.from - b.from);
|
|
4267
|
+
let price = option.price;
|
|
4268
|
+
for (const tier of tiers) if (itemsTotal >= tier.from) price = tier.price;
|
|
4269
|
+
if (option.freeOver != null && itemsTotal >= option.freeOver) return 0;
|
|
4270
|
+
return price;
|
|
4271
|
+
}
|
|
4272
|
+
function quote(option, zoneId, itemsTotal) {
|
|
4273
|
+
const amount = priceForTotal(option, itemsTotal);
|
|
4274
|
+
const freeOver = option.freeOver ?? null;
|
|
4275
|
+
return {
|
|
4276
|
+
optionId: option.id,
|
|
4277
|
+
zoneId,
|
|
4278
|
+
type: option.type,
|
|
4279
|
+
name: option.name?.trim() || null,
|
|
4280
|
+
amount,
|
|
4281
|
+
amountToFree: freeOver != null && amount > 0 ? freeOver - itemsTotal : null,
|
|
4282
|
+
minDays: option.minDays ?? null,
|
|
4283
|
+
maxDays: option.maxDays ?? null,
|
|
4284
|
+
outletId: option.outletId ?? null
|
|
4285
|
+
};
|
|
4286
|
+
}
|
|
4287
|
+
function countriesShippedTo(zones) {
|
|
4288
|
+
const countries = /* @__PURE__ */ new Set();
|
|
4289
|
+
for (const zone of zones) {
|
|
4290
|
+
if (!zone.ships) continue;
|
|
4291
|
+
for (const key of zoneKeys(zone)) {
|
|
4292
|
+
if (key !== EVERYWHERE_KEY && shipsToCountry(key.slice(0, 2))) countries.add(key.slice(0, 2));
|
|
4293
|
+
}
|
|
4294
|
+
}
|
|
4295
|
+
return [...countries].sort();
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4298
|
+
// shipping/validate.ts
|
|
4299
|
+
function validateShippingZone(zone) {
|
|
4300
|
+
const problems = [...placeProblems(zone)];
|
|
4301
|
+
for (const option of zone.options) problems.push(...optionProblems(option));
|
|
4302
|
+
const reachesWebsite = zone.options.some((option) => option.channels.includes("web" /* WEB */));
|
|
4303
|
+
if (zone.ships && !reachesWebsite) problems.push({ code: "NO_WEBSITE_OPTION" /* NO_WEBSITE_OPTION */ });
|
|
4304
|
+
return problems;
|
|
4305
|
+
}
|
|
4306
|
+
function placeProblems(zone) {
|
|
4307
|
+
if (zone.kind === "everywhere" /* EVERYWHERE */) {
|
|
4308
|
+
return zone.places.length ? [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }] : [];
|
|
4309
|
+
}
|
|
4310
|
+
if (zone.places.length === 0) return [{ code: "NO_PLACES" /* NO_PLACES */ }];
|
|
4311
|
+
if (!zone.places.every((place) => fitsKind(place, zone.kind))) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
|
|
4312
|
+
const keys = zone.places.map(placeKey);
|
|
4313
|
+
if (keys.some((key) => !key || !shipsToCountry(key.slice(0, 2)))) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
|
|
4314
|
+
if (new Set(keys).size !== keys.length) return [{ code: "DUPLICATE_PLACE" /* DUPLICATE_PLACE */ }];
|
|
4315
|
+
return [];
|
|
4316
|
+
}
|
|
4317
|
+
function fitsKind(place, kind) {
|
|
4318
|
+
const hasProvince = Boolean(place.province?.trim());
|
|
4319
|
+
const hasCity = Boolean(place.city?.trim());
|
|
4320
|
+
if (kind === "country" /* COUNTRY */) return !hasProvince && !hasCity;
|
|
4321
|
+
if (kind === "province" /* PROVINCE */) return hasProvince && !hasCity;
|
|
4322
|
+
if (kind === "city" /* CITY */) return hasProvince && hasCity;
|
|
4323
|
+
return false;
|
|
4324
|
+
}
|
|
4325
|
+
var isAmount = (value) => Number.isInteger(value) && value >= 0;
|
|
4326
|
+
var isDays = (value) => value == null || isAmount(value);
|
|
4327
|
+
function optionProblems(option) {
|
|
4328
|
+
const problems = [];
|
|
4329
|
+
const isPickup = option.type === "pickup" /* PICKUP */;
|
|
4330
|
+
if (!isAmount(option.price) || option.freeOver != null && !isAmount(option.freeOver)) {
|
|
4331
|
+
problems.push("INVALID_PRICE" /* INVALID_PRICE */);
|
|
4332
|
+
}
|
|
4333
|
+
if (!isPickup && !option.name?.trim()) problems.push("MISSING_NAME" /* MISSING_NAME */);
|
|
4334
|
+
if (!isDays(option.minDays) || !isDays(option.maxDays) || (option.minDays ?? 0) > (option.maxDays ?? Infinity)) {
|
|
4335
|
+
problems.push("INVALID_DAYS" /* INVALID_DAYS */);
|
|
4336
|
+
}
|
|
4337
|
+
if (!tiersAreValid(option)) problems.push("INVALID_TIERS" /* INVALID_TIERS */);
|
|
4338
|
+
if (option.channels.length === 0) problems.push("NO_CHANNEL" /* NO_CHANNEL */);
|
|
4339
|
+
if (isPickup && !option.outletId) problems.push("PICKUP_WITHOUT_STORE" /* PICKUP_WITHOUT_STORE */);
|
|
4340
|
+
return problems.map((code) => ({ code, optionId: option.id }));
|
|
4341
|
+
}
|
|
4342
|
+
function tiersAreValid(option) {
|
|
4343
|
+
const tiers = option.priceByTotal ?? [];
|
|
4344
|
+
const froms = tiers.map((tier) => tier.from);
|
|
4345
|
+
return tiers.every((tier) => Number.isInteger(tier.from) && tier.from > 0 && isAmount(tier.price)) && new Set(froms).size === froms.length;
|
|
4346
|
+
}
|
|
4347
|
+
|
|
4348
|
+
// tax/sha1.ts
|
|
4349
|
+
function utf8Bytes(text) {
|
|
4350
|
+
const bytes = [];
|
|
4351
|
+
for (const char of text) {
|
|
4352
|
+
const cp = char.codePointAt(0);
|
|
4353
|
+
if (cp < 128) bytes.push(cp);
|
|
4354
|
+
else if (cp < 2048) bytes.push(192 | cp >> 6, 128 | cp & 63);
|
|
4355
|
+
else if (cp < 65536) bytes.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
4356
|
+
else bytes.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
4357
|
+
}
|
|
4358
|
+
return bytes;
|
|
4359
|
+
}
|
|
4360
|
+
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
4361
|
+
function sha1Hex(text) {
|
|
4362
|
+
const bytes = utf8Bytes(text);
|
|
4363
|
+
const bitLength = bytes.length * 8;
|
|
4364
|
+
bytes.push(128);
|
|
4365
|
+
while (bytes.length % 64 !== 56) bytes.push(0);
|
|
4366
|
+
const high = Math.floor(bitLength / 4294967296);
|
|
4367
|
+
for (const word of [high, bitLength >>> 0])
|
|
4368
|
+
bytes.push(word >>> 24 & 255, word >>> 16 & 255, word >>> 8 & 255, word & 255);
|
|
4369
|
+
const h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
4370
|
+
const w = new Array(80);
|
|
4371
|
+
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
4372
|
+
for (let i = 0; i < 16; i++) {
|
|
4373
|
+
const j = offset + i * 4;
|
|
4374
|
+
w[i] = bytes[j] << 24 | bytes[j + 1] << 16 | bytes[j + 2] << 8 | bytes[j + 3];
|
|
4375
|
+
}
|
|
4376
|
+
for (let i = 16; i < 80; i++) w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
4377
|
+
let [a, b, c, d, e] = h;
|
|
4378
|
+
for (let i = 0; i < 80; i++) {
|
|
4379
|
+
const [f, k] = i < 20 ? [b & c | ~b & d, 1518500249] : i < 40 ? [b ^ c ^ d, 1859775393] : i < 60 ? [b & c | b & d | c & d, 2400959708] : [b ^ c ^ d, 3395469782];
|
|
4380
|
+
const t = rotl(a, 5) + f + e + k + w[i] | 0;
|
|
4381
|
+
e = d;
|
|
4382
|
+
d = c;
|
|
4383
|
+
c = rotl(b, 30);
|
|
4384
|
+
b = a;
|
|
4385
|
+
a = t;
|
|
4386
|
+
}
|
|
4387
|
+
h[0] = h[0] + a | 0;
|
|
4388
|
+
h[1] = h[1] + b | 0;
|
|
4389
|
+
h[2] = h[2] + c | 0;
|
|
4390
|
+
h[3] = h[3] + d | 0;
|
|
4391
|
+
h[4] = h[4] + e | 0;
|
|
4392
|
+
}
|
|
4393
|
+
return h.map((x) => (x >>> 0).toString(16).padStart(8, "0")).join("");
|
|
4394
|
+
}
|
|
4395
|
+
|
|
4396
|
+
// tax/table.ts
|
|
4397
|
+
var STANDARD_TAX_TYPE = "standard";
|
|
4398
|
+
var TYPE_FIELDS = ["key", "name", "description", "sortOrder", "active"];
|
|
4399
|
+
var RATE_FIELDS = [
|
|
4400
|
+
"code",
|
|
4401
|
+
"name",
|
|
4402
|
+
"kind",
|
|
4403
|
+
"places",
|
|
4404
|
+
"rate",
|
|
4405
|
+
"from",
|
|
4406
|
+
"to",
|
|
4407
|
+
"order",
|
|
4408
|
+
"compound",
|
|
4409
|
+
"registrationPlace",
|
|
4410
|
+
"harmonized",
|
|
4411
|
+
"parts",
|
|
4412
|
+
"sourceUrl",
|
|
4413
|
+
"status"
|
|
4414
|
+
];
|
|
4415
|
+
var RULE_FIELDS = ["taxType", "codes", "rate", "from", "to", "sourceUrl", "status", "note"];
|
|
4416
|
+
function canonical(row, fields) {
|
|
4417
|
+
return JSON.stringify(fields.map((field) => row[field] ?? null));
|
|
4418
|
+
}
|
|
4419
|
+
var sortedCanonical = (rows, fields) => rows.map((row) => canonical(row, fields)).sort();
|
|
4420
|
+
function automaticTaxTableVersion(table) {
|
|
4421
|
+
return sha1Hex(
|
|
4422
|
+
JSON.stringify([
|
|
4423
|
+
sortedCanonical(table.types, TYPE_FIELDS),
|
|
4424
|
+
sortedCanonical(table.rates, RATE_FIELDS),
|
|
4425
|
+
sortedCanonical(table.rules, RULE_FIELDS)
|
|
4426
|
+
])
|
|
4427
|
+
);
|
|
4428
|
+
}
|
|
4429
|
+
var toTypeRow = ({ key, name, description, sortOrder, active }) => ({
|
|
4430
|
+
key,
|
|
4431
|
+
name,
|
|
4432
|
+
description,
|
|
4433
|
+
sortOrder,
|
|
4434
|
+
active
|
|
4435
|
+
});
|
|
4436
|
+
var toRateRow = (rate) => ({
|
|
4437
|
+
code: rate.code,
|
|
4438
|
+
name: rate.name,
|
|
4439
|
+
kind: rate.kind,
|
|
4440
|
+
places: rate.places,
|
|
4441
|
+
rate: rate.rate,
|
|
4442
|
+
from: rate.from,
|
|
4443
|
+
to: rate.to,
|
|
4444
|
+
order: rate.order,
|
|
4445
|
+
compound: rate.compound,
|
|
4446
|
+
registrationPlace: rate.registrationPlace,
|
|
4447
|
+
harmonized: rate.harmonized,
|
|
4448
|
+
parts: rate.parts?.map(({ code, name, rate: partRate, level }) => ({ code, name, rate: partRate, level })),
|
|
4449
|
+
sourceUrl: rate.sourceUrl,
|
|
4450
|
+
status: rate.status
|
|
4451
|
+
});
|
|
4452
|
+
var toRuleRow = ({
|
|
4453
|
+
taxType,
|
|
4454
|
+
codes: codes2,
|
|
4455
|
+
rate,
|
|
4456
|
+
from,
|
|
4457
|
+
to,
|
|
4458
|
+
sourceUrl,
|
|
4459
|
+
status,
|
|
4460
|
+
note
|
|
4461
|
+
}) => ({
|
|
4462
|
+
taxType,
|
|
4463
|
+
codes: codes2,
|
|
4464
|
+
rate,
|
|
4465
|
+
from,
|
|
4466
|
+
to,
|
|
4467
|
+
sourceUrl,
|
|
4468
|
+
status,
|
|
4469
|
+
note
|
|
4470
|
+
});
|
|
4471
|
+
function buildAutomaticTaxTable(rows) {
|
|
4472
|
+
const table = {
|
|
4473
|
+
types: [...rows.types].sort((a, b) => a.sortOrder - b.sortOrder).map(toTypeRow),
|
|
4474
|
+
rates: rows.rates.map(toRateRow),
|
|
4475
|
+
rules: rows.rules.map(toRuleRow)
|
|
4476
|
+
};
|
|
4477
|
+
return { version: automaticTaxTableVersion(table), ...table };
|
|
4478
|
+
}
|
|
4479
|
+
function registrationPlacesByKind(rates) {
|
|
4480
|
+
const places = /* @__PURE__ */ new Map();
|
|
4481
|
+
for (const rate of rates) {
|
|
4482
|
+
const list = places.get(rate.kind) ?? [];
|
|
4483
|
+
if (!list.includes(rate.registrationPlace)) list.push(rate.registrationPlace);
|
|
4484
|
+
places.set(rate.kind, list);
|
|
4485
|
+
}
|
|
4486
|
+
return places;
|
|
4487
|
+
}
|
|
4488
|
+
|
|
3874
4489
|
// constants/adyen.constants.ts
|
|
3875
4490
|
var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
|
|
3876
4491
|
function isAdyenRolloutCountry(alpha2) {
|
|
@@ -3920,6 +4535,27 @@ var BNPL_SKIP_REASON = {
|
|
|
3920
4535
|
NO_BUSINESS_LINE: "no_business_line"
|
|
3921
4536
|
};
|
|
3922
4537
|
|
|
4538
|
+
// pos-types/active/ProcessorType.ts
|
|
4539
|
+
var ProcessorType = /* @__PURE__ */ ((ProcessorType2) => {
|
|
4540
|
+
ProcessorType2["FINAL_PAY"] = "Terminal";
|
|
4541
|
+
ProcessorType2["TAP_TO_PAY"] = "TapToPay";
|
|
4542
|
+
ProcessorType2["MOTO"] = "Moto";
|
|
4543
|
+
ProcessorType2["CLOUD"] = "Cloud";
|
|
4544
|
+
ProcessorType2["BLUETOOTH"] = "Bluetooth";
|
|
4545
|
+
ProcessorType2["CASH"] = "Cash";
|
|
4546
|
+
ProcessorType2["CUSTOM_PAY"] = "CustomPay";
|
|
4547
|
+
ProcessorType2["VENDARA"] = "Vendara";
|
|
4548
|
+
ProcessorType2["REDEEM"] = "Redeem";
|
|
4549
|
+
ProcessorType2["INTEGRATION"] = "Integration";
|
|
4550
|
+
ProcessorType2["PAYMENT_LINK"] = "PaymentLink";
|
|
4551
|
+
ProcessorType2["ONLINE_PAYMENT"] = "OnlinePayment";
|
|
4552
|
+
ProcessorType2["EXTERNAL"] = "External";
|
|
4553
|
+
return ProcessorType2;
|
|
4554
|
+
})(ProcessorType || {});
|
|
4555
|
+
|
|
4556
|
+
// constants/payment-channel.constants.ts
|
|
4557
|
+
var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
4558
|
+
|
|
3923
4559
|
// constants/expense.constants.ts
|
|
3924
4560
|
var EXPENSE_PAYMENT_METHOD_PRESETS = [
|
|
3925
4561
|
"Cash",
|
|
@@ -3943,26 +4579,6 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
3943
4579
|
{ key: "vehicle-fuel", name: "Vehicle & fuel" },
|
|
3944
4580
|
{ key: "other", name: "Other" }
|
|
3945
4581
|
];
|
|
3946
|
-
|
|
3947
|
-
// pos-types/active/ProcessorType.ts
|
|
3948
|
-
var ProcessorType = /* @__PURE__ */ ((ProcessorType2) => {
|
|
3949
|
-
ProcessorType2["FINAL_PAY"] = "Terminal";
|
|
3950
|
-
ProcessorType2["TAP_TO_PAY"] = "TapToPay";
|
|
3951
|
-
ProcessorType2["MOTO"] = "Moto";
|
|
3952
|
-
ProcessorType2["CLOUD"] = "Cloud";
|
|
3953
|
-
ProcessorType2["BLUETOOTH"] = "Bluetooth";
|
|
3954
|
-
ProcessorType2["CASH"] = "Cash";
|
|
3955
|
-
ProcessorType2["CUSTOM_PAY"] = "CustomPay";
|
|
3956
|
-
ProcessorType2["VENDARA"] = "Vendara";
|
|
3957
|
-
ProcessorType2["REDEEM"] = "Redeem";
|
|
3958
|
-
ProcessorType2["INTEGRATION"] = "Integration";
|
|
3959
|
-
ProcessorType2["PAYMENT_LINK"] = "PaymentLink";
|
|
3960
|
-
ProcessorType2["EXTERNAL"] = "External";
|
|
3961
|
-
return ProcessorType2;
|
|
3962
|
-
})(ProcessorType || {});
|
|
3963
|
-
|
|
3964
|
-
// constants/payment-channel.constants.ts
|
|
3965
|
-
var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
3966
4582
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3967
4583
|
0 && (module.exports = {
|
|
3968
4584
|
ADYEN_JOB_TITLE_ASSOCIATION_TYPES,
|
|
@@ -3982,6 +4598,7 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
3982
4598
|
BookingResourceStatus,
|
|
3983
4599
|
BookingRulesError,
|
|
3984
4600
|
BookingType,
|
|
4601
|
+
CANADA_PROVINCES,
|
|
3985
4602
|
CONDITION_OPERATORS,
|
|
3986
4603
|
COUNTRY_CURRENCIES,
|
|
3987
4604
|
CURRENCY_CONFIG,
|
|
@@ -3998,6 +4615,7 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
3998
4615
|
DualWriteStrategy,
|
|
3999
4616
|
EUFixedRates,
|
|
4000
4617
|
EUROPE,
|
|
4618
|
+
EVERYWHERE_KEY,
|
|
4001
4619
|
EXPENSE_DEFAULT_CATEGORIES,
|
|
4002
4620
|
EXPENSE_NAME_MAX_LENGTH,
|
|
4003
4621
|
EXPENSE_PAYMENT_METHOD_PRESETS,
|
|
@@ -4021,6 +4639,7 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
4021
4639
|
ORDER_STATE_TOPIC,
|
|
4022
4640
|
OrderPlatform,
|
|
4023
4641
|
OtherFixedRates,
|
|
4642
|
+
OutOfProvinceTaxes,
|
|
4024
4643
|
OwnerType,
|
|
4025
4644
|
PATH_MODES,
|
|
4026
4645
|
PAYMENT_CHANNELS,
|
|
@@ -4048,6 +4667,8 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
4048
4667
|
ResidualPaymentMethod,
|
|
4049
4668
|
ResidualStatus,
|
|
4050
4669
|
ResourceAvailabilityState,
|
|
4670
|
+
SHIPPING_COUNTRIES,
|
|
4671
|
+
STANDARD_TAX_TYPE,
|
|
4051
4672
|
STATE_SCHEMA,
|
|
4052
4673
|
STRIPE_SUPPORTED_COUNTRIES,
|
|
4053
4674
|
SYSTEM_FAMILIES,
|
|
@@ -4056,13 +4677,23 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
4056
4677
|
SYSTEM_UNIT_IDS,
|
|
4057
4678
|
SalesLineAction,
|
|
4058
4679
|
SalesLineSourceArray,
|
|
4680
|
+
ShippingChannel,
|
|
4681
|
+
ShippingNoOptionReason,
|
|
4682
|
+
ShippingOptionType,
|
|
4683
|
+
ShippingRateType,
|
|
4684
|
+
ShippingZoneError,
|
|
4685
|
+
ShippingZoneKind,
|
|
4059
4686
|
StationStatus,
|
|
4060
4687
|
StripeCurrencyCode,
|
|
4061
4688
|
StripeStatus,
|
|
4689
|
+
TaxRegistrationKind,
|
|
4690
|
+
TaxSource,
|
|
4691
|
+
TaxWarningCode,
|
|
4062
4692
|
TimePeriod,
|
|
4063
4693
|
TopMetericsSort,
|
|
4064
4694
|
UserTypes,
|
|
4065
4695
|
addAmounts,
|
|
4696
|
+
addressPlaceKeys,
|
|
4066
4697
|
adyenLegalEntityRequiresStateOrProvince,
|
|
4067
4698
|
adyenRequiresJobTitle,
|
|
4068
4699
|
adyenStoreRequiresStateOrProvince,
|
|
@@ -4072,11 +4703,13 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
4072
4703
|
ancestorChain,
|
|
4073
4704
|
applyAssignment,
|
|
4074
4705
|
assertUnitSane,
|
|
4706
|
+
automaticTaxTableVersion,
|
|
4075
4707
|
availableIn,
|
|
4076
4708
|
baseFor,
|
|
4077
4709
|
baseFulfillmentDefinitions,
|
|
4078
4710
|
baseOf,
|
|
4079
4711
|
basePaymentDefinitions,
|
|
4712
|
+
buildAutomaticTaxTable,
|
|
4080
4713
|
buildAvailability,
|
|
4081
4714
|
buildGrid,
|
|
4082
4715
|
buildOrderContext,
|
|
@@ -4143,31 +4776,48 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
4143
4776
|
isSystemFamilyCode,
|
|
4144
4777
|
isValidQuantity,
|
|
4145
4778
|
isWhole,
|
|
4779
|
+
lineStockMoves,
|
|
4780
|
+
listCountries,
|
|
4781
|
+
listProvinces,
|
|
4782
|
+
listShippingCountries,
|
|
4146
4783
|
mapToLegacyStatus,
|
|
4147
4784
|
maxPrecisionFor,
|
|
4148
4785
|
mergeFragment,
|
|
4149
4786
|
modifiersSellable,
|
|
4150
4787
|
multiplyAmount,
|
|
4788
|
+
normalizeAddress,
|
|
4789
|
+
normalizeCityKey,
|
|
4790
|
+
normalizeCountry,
|
|
4151
4791
|
normalizeMongoIdString,
|
|
4792
|
+
normalizePostCode,
|
|
4793
|
+
normalizeProvince,
|
|
4152
4794
|
occupancyIn,
|
|
4153
4795
|
orderAssignments,
|
|
4154
4796
|
parseAmountToMinorUnits,
|
|
4155
4797
|
parseCurrencyCode,
|
|
4156
4798
|
parseStripeCurrencyCode,
|
|
4799
|
+
placeKey,
|
|
4157
4800
|
planWindow,
|
|
4158
4801
|
poolDemand,
|
|
4159
4802
|
poolOf,
|
|
4160
4803
|
poolShortfall,
|
|
4161
4804
|
poolStockAt,
|
|
4805
|
+
postCodeMatchesProvince,
|
|
4162
4806
|
presentAt,
|
|
4807
|
+
priceForTotal,
|
|
4808
|
+
provincesForPostCode,
|
|
4809
|
+
registrationPlacesByKind,
|
|
4163
4810
|
removeFragment,
|
|
4164
4811
|
resolveFamily,
|
|
4165
4812
|
resolveModifiersForProduct,
|
|
4813
|
+
resolveShipping,
|
|
4166
4814
|
resolveTemplate,
|
|
4167
4815
|
resolveUnit,
|
|
4168
4816
|
roundToPrecision,
|
|
4169
4817
|
sameFamily,
|
|
4170
4818
|
setOrderState,
|
|
4819
|
+
sha1Hex,
|
|
4820
|
+
shipsToCountry,
|
|
4171
4821
|
shopDayKey,
|
|
4172
4822
|
shopDayRange,
|
|
4173
4823
|
signReportForDisplay,
|
|
@@ -4179,6 +4829,7 @@ var PAYMENT_CHANNELS = ["inPerson", "online"];
|
|
|
4179
4829
|
validateConfig,
|
|
4180
4830
|
validateFragmentCompatibility,
|
|
4181
4831
|
validateOrderStatuses,
|
|
4832
|
+
validateShippingZone,
|
|
4182
4833
|
violatesFinancialInvariant,
|
|
4183
4834
|
windowEndsAt,
|
|
4184
4835
|
withinPresence
|