@final-commerce/common 1.1.4-beta.4 → 1.2.4-beta.2
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.mts +617 -4
- package/dist/index.d.ts +617 -4
- package/dist/index.js +50 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -17
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +346 -6
- package/dist/pos-types/index.d.ts +346 -6
- package/dist/pos-types/index.js +3 -3
- package/dist/pos-types/index.js.map +1 -1
- package/dist/pos-types/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/interfaces-6GnQyqYd.d.mts +0 -598
- package/dist/interfaces-6GnQyqYd.d.ts +0 -598
package/dist/index.js
CHANGED
|
@@ -53,9 +53,9 @@ __export(index_exports, {
|
|
|
53
53
|
OwnerType: () => OwnerType,
|
|
54
54
|
PATH_MODES: () => PATH_MODES,
|
|
55
55
|
PAYMENT_STATES: () => PAYMENT_STATES,
|
|
56
|
-
POS_CROSS_AXIS_RULES: () => POS_CROSS_AXIS_RULES,
|
|
57
56
|
POS_VALID_INITIAL_STATES: () => POS_VALID_INITIAL_STATES,
|
|
58
57
|
PaymentMethod: () => PaymentMethod,
|
|
58
|
+
PaymentProcessor: () => PaymentProcessor,
|
|
59
59
|
Platform: () => Platform,
|
|
60
60
|
PreviewImageMode: () => PreviewImageMode,
|
|
61
61
|
PricingLevel: () => PricingLevel,
|
|
@@ -102,13 +102,19 @@ __export(index_exports, {
|
|
|
102
102
|
fromMinorUnits: () => fromMinorUnits,
|
|
103
103
|
generateMongoID: () => generateMongoID,
|
|
104
104
|
getAvailableTransitions: () => getAvailableTransitions,
|
|
105
|
+
getCashAmountDue: () => getCashAmountDue,
|
|
105
106
|
getCountriesByRegion: () => getCountriesByRegion,
|
|
106
107
|
getCurrencyConfig: () => getCurrencyConfig,
|
|
107
108
|
getCurrentISODate: () => getCurrentISODate,
|
|
108
109
|
getFinancialInvariantViolations: () => getFinancialInvariantViolations,
|
|
110
|
+
getGoodsPortion: () => getGoodsPortion,
|
|
111
|
+
getLineSubtotal: () => getLineSubtotal,
|
|
109
112
|
getMinorUnitMultiplier: () => getMinorUnitMultiplier,
|
|
110
113
|
getMinorUnits: () => getMinorUnits,
|
|
114
|
+
getPaymentLegTotal: () => getPaymentLegTotal,
|
|
111
115
|
getPricingRegionFromCountry: () => getPricingRegionFromCountry,
|
|
116
|
+
getSettlementTotal: () => getSettlementTotal,
|
|
117
|
+
getTotalCollected: () => getTotalCollected,
|
|
112
118
|
inferStatesFromLegacyStatus: () => inferStatesFromLegacyStatus,
|
|
113
119
|
isConditionOperator: () => isConditionOperator,
|
|
114
120
|
isFulfillmentState: () => isFulfillmentState,
|
|
@@ -367,6 +373,7 @@ var InventorySpecificActionType = /* @__PURE__ */ ((InventorySpecificActionType2
|
|
|
367
373
|
InventorySpecificActionType2["TRANSFER"] = "TRANSFER";
|
|
368
374
|
InventorySpecificActionType2["BULK_RECOUNT"] = "BULK_RECOUNT";
|
|
369
375
|
InventorySpecificActionType2["APPLIED_FROM_WOO"] = "APPLIED_FROM_WOO";
|
|
376
|
+
InventorySpecificActionType2["PO_RECEIVED"] = "PO_RECEIVED";
|
|
370
377
|
return InventorySpecificActionType2;
|
|
371
378
|
})(InventorySpecificActionType || {});
|
|
372
379
|
var ExtensionCategory = /* @__PURE__ */ ((ExtensionCategory2) => {
|
|
@@ -561,6 +568,14 @@ var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
|
|
|
561
568
|
return ProductStatus2;
|
|
562
569
|
})(ProductStatus || {});
|
|
563
570
|
|
|
571
|
+
// enums/payments.enum.ts
|
|
572
|
+
var PaymentProcessor = /* @__PURE__ */ ((PaymentProcessor2) => {
|
|
573
|
+
PaymentProcessor2["STRIPE"] = "stripe";
|
|
574
|
+
PaymentProcessor2["ADYEN"] = "adyen";
|
|
575
|
+
PaymentProcessor2["EXTERNAL"] = "external";
|
|
576
|
+
return PaymentProcessor2;
|
|
577
|
+
})(PaymentProcessor || {});
|
|
578
|
+
|
|
564
579
|
// utils/currency.util.ts
|
|
565
580
|
var CURRENCY_CONFIG = {
|
|
566
581
|
// Major currencies with 2 decimal places
|
|
@@ -844,6 +859,29 @@ function amountToString(amount) {
|
|
|
844
859
|
return majorValue.toFixed(amount.minorUnits);
|
|
845
860
|
}
|
|
846
861
|
|
|
862
|
+
// utils/order-totals.util.ts
|
|
863
|
+
function toMinorUnits2(value) {
|
|
864
|
+
return Number(value) || 0;
|
|
865
|
+
}
|
|
866
|
+
function getTotalCollected(amountPaid, tipTotal) {
|
|
867
|
+
return toMinorUnits2(amountPaid) + toMinorUnits2(tipTotal);
|
|
868
|
+
}
|
|
869
|
+
function getPaymentLegTotal(amount, tipAmount) {
|
|
870
|
+
return toMinorUnits2(amount) + toMinorUnits2(tipAmount);
|
|
871
|
+
}
|
|
872
|
+
function getCashAmountDue(amount, cashRounding) {
|
|
873
|
+
return toMinorUnits2(amount) - toMinorUnits2(cashRounding);
|
|
874
|
+
}
|
|
875
|
+
function getSettlementTotal(payments, tipTotal) {
|
|
876
|
+
return toMinorUnits2(payments?.cardTotal) + toMinorUnits2(payments?.cashTotal) + toMinorUnits2(payments?.customTotal) + toMinorUnits2(tipTotal);
|
|
877
|
+
}
|
|
878
|
+
function getLineSubtotal(price, quantity) {
|
|
879
|
+
return toMinorUnits2(price) * toMinorUnits2(quantity);
|
|
880
|
+
}
|
|
881
|
+
function getGoodsPortion(total, totalTax) {
|
|
882
|
+
return toMinorUnits2(total) - toMinorUnits2(totalTax);
|
|
883
|
+
}
|
|
884
|
+
|
|
847
885
|
// constants/pricing.constants.ts
|
|
848
886
|
var REGION_MAPPING = {
|
|
849
887
|
// North America
|
|
@@ -1093,7 +1131,8 @@ var REPORT_NEGATE_PATHS = /* @__PURE__ */ new Set([
|
|
|
1093
1131
|
"taxBreakdown.refunds.total.tax",
|
|
1094
1132
|
// Refunds breakdown — reductions and naturally-signed entries
|
|
1095
1133
|
"refundsBreakdown.discountsReversed",
|
|
1096
|
-
|
|
1134
|
+
// 2026 AUG10, cashRoundingRefund is showing as natural sign
|
|
1135
|
+
// 'refundsBreakdown.cashRoundingRefund',
|
|
1097
1136
|
// Fees breakdown — refunded magnitudes are money flowing back out
|
|
1098
1137
|
"feesBreakdown.productFee.refundedProductFees",
|
|
1099
1138
|
"feesBreakdown.cartFee.refundedCartFees",
|
|
@@ -1402,7 +1441,7 @@ var DEFAULT_CONFIG = {
|
|
|
1402
1441
|
fulfillmentPaths: [],
|
|
1403
1442
|
paymentPathMode: "permissive",
|
|
1404
1443
|
fulfillmentPathMode: "permissive",
|
|
1405
|
-
crossAxisRules: [
|
|
1444
|
+
crossAxisRules: [],
|
|
1406
1445
|
transitionConditions: [],
|
|
1407
1446
|
validInitialStates: [{ payment: "unpaid", fulfillment: "draft" }],
|
|
1408
1447
|
displayStateMap: [...DEFAULT_DISPLAY_STATE_MAP],
|
|
@@ -1419,19 +1458,6 @@ function buildResolvedConfig(config) {
|
|
|
1419
1458
|
var DEFAULT_RESOLVED_CONFIG = buildResolvedConfig(DEFAULT_CONFIG);
|
|
1420
1459
|
|
|
1421
1460
|
// order-state-machine/pos-preset.ts
|
|
1422
|
-
var POS_CROSS_AXIS_RULES = [
|
|
1423
|
-
{
|
|
1424
|
-
id: "pos-pay-requires-open-fulfillment",
|
|
1425
|
-
label: "Payments only on open fulfillment states",
|
|
1426
|
-
description: "POS payments are only valid on orders whose fulfillment is open (draft / pending / on_hold) or auto-fulfilled in lock-step (fulfilled). Returned / cancelled / in-progress fulfillment must use refund flows instead.",
|
|
1427
|
-
enabled: true,
|
|
1428
|
-
trigger: { axis: "payment", to: ["payment_pending", "paid", "partially_paid"] },
|
|
1429
|
-
requires: {
|
|
1430
|
-
axis: "fulfillment",
|
|
1431
|
-
states: ["draft", "pending", "on_hold", "fulfilled"]
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
];
|
|
1435
1461
|
var POS_VALID_INITIAL_STATES = [
|
|
1436
1462
|
{ payment: "unpaid", fulfillment: "draft" },
|
|
1437
1463
|
{ payment: "unpaid", fulfillment: "on_hold" },
|
|
@@ -1446,7 +1472,7 @@ function buildPosPresetConfig(companyId) {
|
|
|
1446
1472
|
_id: "pos-preset",
|
|
1447
1473
|
companyId: companyId ?? DEFAULT_CONFIG.companyId,
|
|
1448
1474
|
name: "POS Preset",
|
|
1449
|
-
crossAxisRules: [
|
|
1475
|
+
crossAxisRules: [],
|
|
1450
1476
|
validInitialStates: [...POS_VALID_INITIAL_STATES],
|
|
1451
1477
|
displayStateMap: [...DEFAULT_DISPLAY_STATE_MAP]
|
|
1452
1478
|
};
|
|
@@ -2620,9 +2646,9 @@ var ORDER_STATE_EVENTS = {
|
|
|
2620
2646
|
OwnerType,
|
|
2621
2647
|
PATH_MODES,
|
|
2622
2648
|
PAYMENT_STATES,
|
|
2623
|
-
POS_CROSS_AXIS_RULES,
|
|
2624
2649
|
POS_VALID_INITIAL_STATES,
|
|
2625
2650
|
PaymentMethod,
|
|
2651
|
+
PaymentProcessor,
|
|
2626
2652
|
Platform,
|
|
2627
2653
|
PreviewImageMode,
|
|
2628
2654
|
PricingLevel,
|
|
@@ -2669,13 +2695,19 @@ var ORDER_STATE_EVENTS = {
|
|
|
2669
2695
|
fromMinorUnits,
|
|
2670
2696
|
generateMongoID,
|
|
2671
2697
|
getAvailableTransitions,
|
|
2698
|
+
getCashAmountDue,
|
|
2672
2699
|
getCountriesByRegion,
|
|
2673
2700
|
getCurrencyConfig,
|
|
2674
2701
|
getCurrentISODate,
|
|
2675
2702
|
getFinancialInvariantViolations,
|
|
2703
|
+
getGoodsPortion,
|
|
2704
|
+
getLineSubtotal,
|
|
2676
2705
|
getMinorUnitMultiplier,
|
|
2677
2706
|
getMinorUnits,
|
|
2707
|
+
getPaymentLegTotal,
|
|
2678
2708
|
getPricingRegionFromCountry,
|
|
2709
|
+
getSettlementTotal,
|
|
2710
|
+
getTotalCollected,
|
|
2679
2711
|
inferStatesFromLegacyStatus,
|
|
2680
2712
|
isConditionOperator,
|
|
2681
2713
|
isFulfillmentState,
|