rerobe-js-orm 4.6.6 → 4.6.7
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/lib/models/Product.d.ts +1 -1
- package/lib/models/Product.js +13 -9
- package/package.json +1 -1
package/lib/models/Product.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export default class Product extends Base {
|
|
|
31
31
|
};
|
|
32
32
|
toObjForTextTranslation(): TranslatableAttributes;
|
|
33
33
|
toObjForTypesense(isCanonicalMerchant?: boolean): TypesenseProductObj;
|
|
34
|
-
private
|
|
34
|
+
private deriveStockTimestampsFromSystemTags;
|
|
35
35
|
buildUpdatedFieldsForSalesChannel(): {
|
|
36
36
|
title: string;
|
|
37
37
|
description: string;
|
package/lib/models/Product.js
CHANGED
|
@@ -579,9 +579,19 @@ class Product extends Base_1.default {
|
|
|
579
579
|
stockTakeLatestTimestamp: null,
|
|
580
580
|
stockTakeFirstTimestamp: null,
|
|
581
581
|
};
|
|
582
|
-
const stockDerivations = this.
|
|
583
|
-
stagedObj.stockStatus = stockDerivations.stockStatus;
|
|
582
|
+
const stockDerivations = this.deriveStockTimestampsFromSystemTags();
|
|
584
583
|
stagedObj.stockStatusTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockStatusTimestamp);
|
|
584
|
+
// Derive stockStatus string from timestamps (no mutation performed inside derive)
|
|
585
|
+
if (stagedObj.stockStatusTimestamp &&
|
|
586
|
+
stagedObj.stockStatusTimestamp === stockDerivations.stockTakeLatestTimestamp) {
|
|
587
|
+
stagedObj.stockStatus = 'In stock';
|
|
588
|
+
}
|
|
589
|
+
else if (stagedObj.stockStatusTimestamp) {
|
|
590
|
+
stagedObj.stockStatus = 'In transit';
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
stagedObj.stockStatus = '';
|
|
594
|
+
}
|
|
585
595
|
stagedObj.stockTakeFirstTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockTakeFirstTimestamp);
|
|
586
596
|
stagedObj.stockTakeLatestTimestamp = this.utilities.sanitizeMillisTimeStamp(stockDerivations.stockTakeLatestTimestamp);
|
|
587
597
|
if (((_a = this.consignmentAttributes) === null || _a === void 0 ? void 0 : _a.inventoryLocations) &&
|
|
@@ -600,7 +610,7 @@ class Product extends Base_1.default {
|
|
|
600
610
|
});
|
|
601
611
|
return stagedObj;
|
|
602
612
|
}
|
|
603
|
-
|
|
613
|
+
deriveStockTimestampsFromSystemTags() {
|
|
604
614
|
const systemTags = Array.isArray(this.filterAttributes.systemTags) ? this.filterAttributes.systemTags : [];
|
|
605
615
|
const stockTakeTags = systemTags.filter((t) => typeof t === 'string' && t.startsWith('stock-take|'));
|
|
606
616
|
const inTransitTags = systemTags.filter((t) => typeof t === 'string' && t.startsWith('in-transit|'));
|
|
@@ -633,28 +643,22 @@ class Product extends Base_1.default {
|
|
|
633
643
|
const stockTakeLatestSan = stockTakeLatest ? this.utilities.sanitizeMillisTimeStamp(stockTakeLatest) : null;
|
|
634
644
|
const stockTakeFirstRaw = stockTakeTags.length ? parseLatestAndFirstTs(stockTakeTags).first : 0;
|
|
635
645
|
const stockTakeFirstSan = stockTakeFirstRaw ? this.utilities.sanitizeMillisTimeStamp(stockTakeFirstRaw) : null;
|
|
636
|
-
let stockStatus = '';
|
|
637
646
|
let stockStatusTimestamp = null;
|
|
638
647
|
if (stockTakeLatest === 0 && inTransitLatest === 0) {
|
|
639
|
-
stockStatus = '';
|
|
640
648
|
stockStatusTimestamp = null;
|
|
641
649
|
}
|
|
642
650
|
else if (stockTakeLatest >= inTransitLatest) {
|
|
643
|
-
stockStatus = 'In stock';
|
|
644
651
|
stockStatusTimestamp = stockTakeLatestSan;
|
|
645
652
|
}
|
|
646
653
|
else {
|
|
647
|
-
stockStatus = 'In transit';
|
|
648
654
|
stockStatusTimestamp = this.utilities.sanitizeMillisTimeStamp(inTransitLatest);
|
|
649
655
|
}
|
|
650
|
-
this.filterAttributes.stockStatus = stockStatus;
|
|
651
656
|
this.timestampAttributes.stockStatusTimestamp = stockStatusTimestamp;
|
|
652
657
|
this.timestampAttributes.stockTakeFirstTimestamp = stockTakeFirstSan;
|
|
653
658
|
this.timestampAttributes.stockTakeLatestTimestamp = stockTakeLatestSan;
|
|
654
659
|
return {
|
|
655
660
|
stockTakeFirstTimestamp: stockTakeFirstSan,
|
|
656
661
|
stockTakeLatestTimestamp: stockTakeLatestSan,
|
|
657
|
-
stockStatus,
|
|
658
662
|
stockStatusTimestamp,
|
|
659
663
|
};
|
|
660
664
|
}
|