@shushed/helpers 0.0.294 → 0.0.295

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.
@@ -114,15 +114,19 @@ function transformMasterOrder(payload) {
114
114
  if (value === null || value === undefined)
115
115
  return null;
116
116
  if (typeof value === "number") {
117
- return Number.isInteger(value) ? value : null;
117
+ if (!Number.isInteger(value) || value === 0)
118
+ return null;
119
+ return value;
118
120
  }
119
121
  if (typeof value === "string") {
120
122
  const s = value.trim();
121
- if (!s)
123
+ if (!s || s === "0")
122
124
  return null;
123
125
  if (/^-?\d+$/.test(s)) {
124
126
  const parsed = Number(s);
125
- return Number.isInteger(parsed) ? parsed : null;
127
+ if (!Number.isInteger(parsed) || parsed === 0)
128
+ return null;
129
+ return parsed;
126
130
  }
127
131
  }
128
132
  return null;
@@ -874,9 +878,17 @@ function transformMasterOrder(payload) {
874
878
  else if (shippedGrossMinor > 0 && totalOrderGrossMinor > 0) {
875
879
  status = shippedGrossMinor >= totalOrderGrossMinor ? "SHIPPED" : "PARTIALLY-SHIPPED";
876
880
  }
877
- const sfcc_order_id = (sale0?.created_by === "STOREFRONT")
878
- ? (sale0?.no || null)
879
- : ((invoice0?.created_by === "STOREFRONT") ? (invoice0?.order_no || null) : null);
881
+ const sfcc_order_id = (() => {
882
+ const raw = (sale0?.created_by === "STOREFRONT")
883
+ ? (sale0?.no ?? null)
884
+ : ((invoice0?.created_by === "STOREFRONT") ? (invoice0?.order_no ?? null) : null);
885
+ if (raw === null || raw === undefined)
886
+ return null;
887
+ const s = String(raw).trim();
888
+ if (!s || s === "0")
889
+ return null;
890
+ return s;
891
+ })();
880
892
  const billing_from = invoice0 || sale0 || null;
881
893
  const shipping_from = invoice0 || sale0 || null;
882
894
  const mapPaymentMethod = (code, card) => {
@@ -1270,7 +1282,9 @@ function transformMasterOrder(payload) {
1270
1282
  if (v === null || v === undefined)
1271
1283
  return null;
1272
1284
  const s = String(v).trim();
1273
- return s.length > 0 ? s : null;
1285
+ if (!s || s === "0")
1286
+ return null;
1287
+ return s;
1274
1288
  })(),
1275
1289
  system_created_by,
1276
1290
  ordered_at,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.294",
3
+ "version": "0.0.295",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",