@final-commerce/common 2.8.1-online.1 → 2.8.1-online.3

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.mjs CHANGED
@@ -531,6 +531,36 @@ var ShippingZoneError = /* @__PURE__ */ ((ShippingZoneError2) => {
531
531
  return ShippingZoneError2;
532
532
  })(ShippingZoneError || {});
533
533
 
534
+ // enums/tax.enum.ts
535
+ var TaxProductType = /* @__PURE__ */ ((TaxProductType2) => {
536
+ TaxProductType2["STANDARD"] = "standard";
537
+ TaxProductType2["BASIC_FOOD"] = "basic_food";
538
+ TaxProductType2["CHILDRENS_CLOTHING"] = "childrens_clothing";
539
+ TaxProductType2["EXEMPT"] = "exempt";
540
+ return TaxProductType2;
541
+ })(TaxProductType || {});
542
+ var TaxRegistrationKind = /* @__PURE__ */ ((TaxRegistrationKind2) => {
543
+ TaxRegistrationKind2["GST_HST"] = "GST_HST";
544
+ TaxRegistrationKind2["PST"] = "PST";
545
+ TaxRegistrationKind2["QST"] = "QST";
546
+ return TaxRegistrationKind2;
547
+ })(TaxRegistrationKind || {});
548
+ var TaxSource = /* @__PURE__ */ ((TaxSource2) => {
549
+ TaxSource2["MERCHANT"] = "merchant";
550
+ TaxSource2["AUTOMATIC"] = "automatic";
551
+ return TaxSource2;
552
+ })(TaxSource || {});
553
+ var OutOfProvinceTaxes = /* @__PURE__ */ ((OutOfProvinceTaxes2) => {
554
+ OutOfProvinceTaxes2["AUTOMATIC"] = "automatic";
555
+ OutOfProvinceTaxes2["HOME"] = "home";
556
+ return OutOfProvinceTaxes2;
557
+ })(OutOfProvinceTaxes || {});
558
+ var TaxWarningCode = /* @__PURE__ */ ((TaxWarningCode2) => {
559
+ TaxWarningCode2["NOT_REGISTERED"] = "NOT_REGISTERED";
560
+ TaxWarningCode2["NO_RULES_FOR_PLACE"] = "NO_RULES_FOR_PLACE";
561
+ return TaxWarningCode2;
562
+ })(TaxWarningCode || {});
563
+
534
564
  // utils/currency.util.ts
535
565
  var CURRENCY_CONFIG = {
536
566
  // Major currencies with 2 decimal places
@@ -1706,6 +1736,48 @@ function compositeReservationMismatches(order) {
1706
1736
  });
1707
1737
  }
1708
1738
 
1739
+ // utils/line-stock-moves.util.ts
1740
+ function lineStockMoves(item, quantity, reservations = []) {
1741
+ const sign = Math.sign(quantity);
1742
+ const pool = (stockVariantId) => stockVariantId ? { stockVariantId: stockVariantId.toString() } : {};
1743
+ if (!item.components?.length)
1744
+ return [
1745
+ {
1746
+ productId: item.productId.toString(),
1747
+ variantId: item.variantId.toString(),
1748
+ fields: {
1749
+ quantity,
1750
+ ...item.stockQuantity != null ? { stockQuantity: sign * item.stockQuantity, unitId: item.unitId?.toString() } : {},
1751
+ ...pool(item.stockVariantId)
1752
+ }
1753
+ }
1754
+ ];
1755
+ const booked = new Set(
1756
+ reservations.filter((reservation) => reservation.lineItemInternalId && reservation.lineItemInternalId === item.internalId).map((reservation) => reservation.componentIndex)
1757
+ );
1758
+ return item.components.flatMap((component, componentIndex) => {
1759
+ if (booked.has(componentIndex)) return [];
1760
+ if (component.unitId && component.stockQuantity == null)
1761
+ throw new Error(
1762
+ `Composite ${item.productId?.toString()} component ${component.variantId.toString()} is sold in ${component.unitId.toString()} but carries no stockQuantity`
1763
+ );
1764
+ return [
1765
+ {
1766
+ productId: component.productId.toString(),
1767
+ variantId: component.variantId.toString(),
1768
+ componentIndex,
1769
+ fields: {
1770
+ quantity: component.quantity * quantity,
1771
+ ...component.stockQuantity != null ? { stockQuantity: component.stockQuantity * quantity, unitId: component.unitId?.toString() } : {},
1772
+ ...pool(component.stockVariantId),
1773
+ ...item.productId ? { compositeProductId: item.productId.toString() } : {},
1774
+ ...item.name ? { compositeName: item.name } : {}
1775
+ }
1776
+ }
1777
+ ];
1778
+ });
1779
+ }
1780
+
1709
1781
  // units/family-code.ts
1710
1782
  var MAX_SLUG_LENGTH = 32;
1711
1783
  var FALLBACK_SLUG = "family";
@@ -3924,6 +3996,13 @@ function tiersAreValid(option) {
3924
3996
  return tiers.every((tier) => Number.isInteger(tier.from) && tier.from > 0 && isAmount(tier.price)) && new Set(froms).size === froms.length;
3925
3997
  }
3926
3998
 
3999
+ // tax/registrations.ts
4000
+ var TAX_REGISTRATION_PLACES = {
4001
+ ["GST_HST" /* GST_HST */]: ["CA"],
4002
+ ["PST" /* PST */]: ["CA-BC", "CA-SK", "CA-MB"],
4003
+ ["QST" /* QST */]: ["CA-QC"]
4004
+ };
4005
+
3927
4006
  // constants/adyen.constants.ts
3928
4007
  var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
3929
4008
  function isAdyenRolloutCountry(alpha2) {
@@ -4075,6 +4154,7 @@ export {
4075
4154
  ORDER_STATE_TOPIC,
4076
4155
  OrderPlatform,
4077
4156
  OtherFixedRates,
4157
+ OutOfProvinceTaxes,
4078
4158
  OwnerType,
4079
4159
  PATH_MODES,
4080
4160
  PAYMENT_CHANNELS,
@@ -4115,6 +4195,11 @@ export {
4115
4195
  StationStatus,
4116
4196
  StripeCurrencyCode,
4117
4197
  StripeStatus,
4198
+ TAX_REGISTRATION_PLACES,
4199
+ TaxProductType,
4200
+ TaxRegistrationKind,
4201
+ TaxSource,
4202
+ TaxWarningCode,
4118
4203
  TimePeriod,
4119
4204
  TopMetericsSort,
4120
4205
  UserTypes,
@@ -4198,6 +4283,7 @@ export {
4198
4283
  isSystemFamilyCode,
4199
4284
  isValidQuantity,
4200
4285
  isWhole,
4286
+ lineStockMoves,
4201
4287
  listCountries,
4202
4288
  listProvinces,
4203
4289
  mapToLegacyStatus,