@final-commerce/common 1.1.4-beta.5 → 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 +22 -3
- package/dist/index.d.ts +22 -3
- 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 +55 -5
- package/dist/pos-types/index.d.ts +55 -5
- 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/index.mjs
CHANGED
|
@@ -231,6 +231,7 @@ var InventorySpecificActionType = /* @__PURE__ */ ((InventorySpecificActionType2
|
|
|
231
231
|
InventorySpecificActionType2["TRANSFER"] = "TRANSFER";
|
|
232
232
|
InventorySpecificActionType2["BULK_RECOUNT"] = "BULK_RECOUNT";
|
|
233
233
|
InventorySpecificActionType2["APPLIED_FROM_WOO"] = "APPLIED_FROM_WOO";
|
|
234
|
+
InventorySpecificActionType2["PO_RECEIVED"] = "PO_RECEIVED";
|
|
234
235
|
return InventorySpecificActionType2;
|
|
235
236
|
})(InventorySpecificActionType || {});
|
|
236
237
|
var ExtensionCategory = /* @__PURE__ */ ((ExtensionCategory2) => {
|
|
@@ -425,6 +426,14 @@ var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
|
|
|
425
426
|
return ProductStatus2;
|
|
426
427
|
})(ProductStatus || {});
|
|
427
428
|
|
|
429
|
+
// enums/payments.enum.ts
|
|
430
|
+
var PaymentProcessor = /* @__PURE__ */ ((PaymentProcessor2) => {
|
|
431
|
+
PaymentProcessor2["STRIPE"] = "stripe";
|
|
432
|
+
PaymentProcessor2["ADYEN"] = "adyen";
|
|
433
|
+
PaymentProcessor2["EXTERNAL"] = "external";
|
|
434
|
+
return PaymentProcessor2;
|
|
435
|
+
})(PaymentProcessor || {});
|
|
436
|
+
|
|
428
437
|
// utils/currency.util.ts
|
|
429
438
|
var CURRENCY_CONFIG = {
|
|
430
439
|
// Major currencies with 2 decimal places
|
|
@@ -708,6 +717,29 @@ function amountToString(amount) {
|
|
|
708
717
|
return majorValue.toFixed(amount.minorUnits);
|
|
709
718
|
}
|
|
710
719
|
|
|
720
|
+
// utils/order-totals.util.ts
|
|
721
|
+
function toMinorUnits2(value) {
|
|
722
|
+
return Number(value) || 0;
|
|
723
|
+
}
|
|
724
|
+
function getTotalCollected(amountPaid, tipTotal) {
|
|
725
|
+
return toMinorUnits2(amountPaid) + toMinorUnits2(tipTotal);
|
|
726
|
+
}
|
|
727
|
+
function getPaymentLegTotal(amount, tipAmount) {
|
|
728
|
+
return toMinorUnits2(amount) + toMinorUnits2(tipAmount);
|
|
729
|
+
}
|
|
730
|
+
function getCashAmountDue(amount, cashRounding) {
|
|
731
|
+
return toMinorUnits2(amount) - toMinorUnits2(cashRounding);
|
|
732
|
+
}
|
|
733
|
+
function getSettlementTotal(payments, tipTotal) {
|
|
734
|
+
return toMinorUnits2(payments?.cardTotal) + toMinorUnits2(payments?.cashTotal) + toMinorUnits2(payments?.customTotal) + toMinorUnits2(tipTotal);
|
|
735
|
+
}
|
|
736
|
+
function getLineSubtotal(price, quantity) {
|
|
737
|
+
return toMinorUnits2(price) * toMinorUnits2(quantity);
|
|
738
|
+
}
|
|
739
|
+
function getGoodsPortion(total, totalTax) {
|
|
740
|
+
return toMinorUnits2(total) - toMinorUnits2(totalTax);
|
|
741
|
+
}
|
|
742
|
+
|
|
711
743
|
// constants/pricing.constants.ts
|
|
712
744
|
var REGION_MAPPING = {
|
|
713
745
|
// North America
|
|
@@ -957,7 +989,8 @@ var REPORT_NEGATE_PATHS = /* @__PURE__ */ new Set([
|
|
|
957
989
|
"taxBreakdown.refunds.total.tax",
|
|
958
990
|
// Refunds breakdown — reductions and naturally-signed entries
|
|
959
991
|
"refundsBreakdown.discountsReversed",
|
|
960
|
-
|
|
992
|
+
// 2026 AUG10, cashRoundingRefund is showing as natural sign
|
|
993
|
+
// 'refundsBreakdown.cashRoundingRefund',
|
|
961
994
|
// Fees breakdown — refunded magnitudes are money flowing back out
|
|
962
995
|
"feesBreakdown.productFee.refundedProductFees",
|
|
963
996
|
"feesBreakdown.cartFee.refundedCartFees",
|
|
@@ -1266,7 +1299,7 @@ var DEFAULT_CONFIG = {
|
|
|
1266
1299
|
fulfillmentPaths: [],
|
|
1267
1300
|
paymentPathMode: "permissive",
|
|
1268
1301
|
fulfillmentPathMode: "permissive",
|
|
1269
|
-
crossAxisRules: [
|
|
1302
|
+
crossAxisRules: [],
|
|
1270
1303
|
transitionConditions: [],
|
|
1271
1304
|
validInitialStates: [{ payment: "unpaid", fulfillment: "draft" }],
|
|
1272
1305
|
displayStateMap: [...DEFAULT_DISPLAY_STATE_MAP],
|
|
@@ -1283,19 +1316,6 @@ function buildResolvedConfig(config) {
|
|
|
1283
1316
|
var DEFAULT_RESOLVED_CONFIG = buildResolvedConfig(DEFAULT_CONFIG);
|
|
1284
1317
|
|
|
1285
1318
|
// order-state-machine/pos-preset.ts
|
|
1286
|
-
var POS_CROSS_AXIS_RULES = [
|
|
1287
|
-
{
|
|
1288
|
-
id: "pos-pay-requires-open-fulfillment",
|
|
1289
|
-
label: "Payments only on open fulfillment states",
|
|
1290
|
-
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.",
|
|
1291
|
-
enabled: true,
|
|
1292
|
-
trigger: { axis: "payment", to: ["payment_pending", "paid", "partially_paid"] },
|
|
1293
|
-
requires: {
|
|
1294
|
-
axis: "fulfillment",
|
|
1295
|
-
states: ["draft", "pending", "on_hold", "fulfilled"]
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
];
|
|
1299
1319
|
var POS_VALID_INITIAL_STATES = [
|
|
1300
1320
|
{ payment: "unpaid", fulfillment: "draft" },
|
|
1301
1321
|
{ payment: "unpaid", fulfillment: "on_hold" },
|
|
@@ -1310,7 +1330,7 @@ function buildPosPresetConfig(companyId) {
|
|
|
1310
1330
|
_id: "pos-preset",
|
|
1311
1331
|
companyId: companyId ?? DEFAULT_CONFIG.companyId,
|
|
1312
1332
|
name: "POS Preset",
|
|
1313
|
-
crossAxisRules: [
|
|
1333
|
+
crossAxisRules: [],
|
|
1314
1334
|
validInitialStates: [...POS_VALID_INITIAL_STATES],
|
|
1315
1335
|
displayStateMap: [...DEFAULT_DISPLAY_STATE_MAP]
|
|
1316
1336
|
};
|
|
@@ -2483,9 +2503,9 @@ export {
|
|
|
2483
2503
|
OwnerType,
|
|
2484
2504
|
PATH_MODES,
|
|
2485
2505
|
PAYMENT_STATES,
|
|
2486
|
-
POS_CROSS_AXIS_RULES,
|
|
2487
2506
|
POS_VALID_INITIAL_STATES,
|
|
2488
2507
|
PaymentMethod,
|
|
2508
|
+
PaymentProcessor,
|
|
2489
2509
|
Platform,
|
|
2490
2510
|
PreviewImageMode,
|
|
2491
2511
|
PricingLevel,
|
|
@@ -2532,13 +2552,19 @@ export {
|
|
|
2532
2552
|
fromMinorUnits,
|
|
2533
2553
|
generateMongoID,
|
|
2534
2554
|
getAvailableTransitions,
|
|
2555
|
+
getCashAmountDue,
|
|
2535
2556
|
getCountriesByRegion,
|
|
2536
2557
|
getCurrencyConfig,
|
|
2537
2558
|
getCurrentISODate,
|
|
2538
2559
|
getFinancialInvariantViolations,
|
|
2560
|
+
getGoodsPortion,
|
|
2561
|
+
getLineSubtotal,
|
|
2539
2562
|
getMinorUnitMultiplier,
|
|
2540
2563
|
getMinorUnits,
|
|
2564
|
+
getPaymentLegTotal,
|
|
2541
2565
|
getPricingRegionFromCountry,
|
|
2566
|
+
getSettlementTotal,
|
|
2567
|
+
getTotalCollected,
|
|
2542
2568
|
inferStatesFromLegacyStatus,
|
|
2543
2569
|
isConditionOperator,
|
|
2544
2570
|
isFulfillmentState,
|