@things-factory/warehouse-base 4.3.824 → 4.3.827

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.
Files changed (33) hide show
  1. package/dist-server/controllers/ecommerce/powrup-controller.js +1 -1
  2. package/dist-server/controllers/ecommerce/powrup-controller.js.map +1 -1
  3. package/dist-server/controllers/ecommerce/webspert-controller.js +1 -1
  4. package/dist-server/index.js +3 -1
  5. package/dist-server/index.js.map +1 -1
  6. package/dist-server/service/inventory/inventory-query.js +3 -4
  7. package/dist-server/service/inventory/inventory-query.js.map +1 -1
  8. package/dist-server/service/location/location-mutation.js +39 -9
  9. package/dist-server/service/location/location-mutation.js.map +1 -1
  10. package/dist-server/service/location/location-types.js +32 -0
  11. package/dist-server/service/location/location-types.js.map +1 -1
  12. package/dist-server/service/location/location.js +25 -0
  13. package/dist-server/service/location/location.js.map +1 -1
  14. package/dist-server/service/product-detail-stock/product-detail-stock-mutation.js +23 -1
  15. package/dist-server/service/product-detail-stock/product-detail-stock-mutation.js.map +1 -1
  16. package/dist-server/service/product-detail-stock/product-detail-stock.js +31 -4
  17. package/dist-server/service/product-detail-stock/product-detail-stock.js.map +1 -1
  18. package/dist-server/utils/index.js +1 -0
  19. package/dist-server/utils/index.js.map +1 -1
  20. package/dist-server/utils/recommendation-utils.js +51 -0
  21. package/dist-server/utils/recommendation-utils.js.map +1 -0
  22. package/package.json +2 -2
  23. package/server/controllers/ecommerce/powrup-controller.ts +1 -1
  24. package/server/controllers/ecommerce/webspert-controller.ts +1 -1
  25. package/server/index.ts +2 -0
  26. package/server/service/inventory/inventory-query.ts +3 -4
  27. package/server/service/location/location-mutation.ts +48 -7
  28. package/server/service/location/location-types.ts +24 -0
  29. package/server/service/location/location.ts +21 -1
  30. package/server/service/product-detail-stock/product-detail-stock-mutation.ts +33 -1
  31. package/server/service/product-detail-stock/product-detail-stock.ts +23 -4
  32. package/server/utils/index.ts +1 -0
  33. package/server/utils/recommendation-utils.ts +54 -0
@@ -1 +1 @@
1
- {"version":3,"file":"product-detail-stock-mutation.js","sourceRoot":"","sources":["../../../server/service/product-detail-stock/product-detail-stock-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAA2C;AAC3C,iEAA2D;AAC3D,6EAA6F;AAGtF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG/B,AAAN,KAAK,CAAC,wBAAwB,CACD,kBAAyC,EAC7D,OAAY;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,yCAAkB,CAAC,CAAC,IAAI,iCACjD,kBAAkB,KACrB,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,wBAAwB,CACjB,EAAU,EACP,KAA8B,EACrC,OAAY;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,yCAAkB,CAAC,CAAA;QACvD,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAClD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SACtB,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,kBAAkB,GAClB,KAAK,KACR,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,gCAAgC,CACe,OAAkC,EAC9E,OAAY;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,C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,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,yCAAkB,CAAC,EAAE,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;IAE/G,WAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,oDAAuB,CAAC,CAAC,CAAA;IACjD,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;kFAwCP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC9C,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0EAK3D;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IACvD,WAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EASlF;AAxGU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,yCAAkB,CAAC;GAChB,0BAA0B,CAyGtC;AAzGY,gEAA0B"}
1
+ {"version":3,"file":"product-detail-stock-mutation.js","sourceRoot":"","sources":["../../../server/service/product-detail-stock/product-detail-stock-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAA0D;AAC1D,iEAA2D;AAC3D,6EAA6F;AAGtF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG/B,AAAN,KAAK,CAAC,wBAAwB,CACD,kBAAyC,EAC7D,OAAY;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EA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O,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC9C,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;0EAK3D;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IACvD,WAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EASlF;AAxGU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,yCAAkB,CAAC;GAChB,0BAA0B,CAyGtC;AAzGY,gEAA0B;AA2GhC,KAAK,UAAU,kCAAkC,CACtD,EAAiB,EACjB,eAAuB,EACvB,iBAAyB,EACzB,UAAkB,EAClB,UAAkB,EAClB,eAAuB;IAEvB,MAAM,EAAE,CAAC,KAAK,CACZ;;;;;;;;;;;;;;;;;;KAkBC,EACD,CAAC,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,CAAC,CAC9E,CAAA;AACH,CAAC;AA9BD,gFA8BC"}
@@ -8,11 +8,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var _a, _b;
11
+ var _a, _b, _c, _d;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.ProductDetailStock = exports.ProductDetailStockStatus = void 0;
14
14
  const typeorm_1 = require("typeorm");
15
15
  const type_graphql_1 = require("type-graphql");
16
+ const biz_base_1 = require("@things-factory/biz-base");
16
17
  const product_base_1 = require("@things-factory/product-base");
17
18
  const shell_1 = require("@things-factory/shell");
18
19
  var ProductDetailStockStatus;
@@ -32,11 +33,32 @@ __decorate([
32
33
  __metadata("design:type", String)
33
34
  ], ProductDetailStock.prototype, "id", void 0);
34
35
  __decorate([
35
- (0, typeorm_1.OneToOne)(type => product_base_1.ProductDetail, { nullable: true }),
36
- (0, typeorm_1.JoinColumn)(),
36
+ (0, typeorm_1.ManyToOne)(type => product_base_1.ProductDetail, { nullable: true }),
37
37
  (0, type_graphql_1.Field)(type => product_base_1.ProductDetail, { nullable: true }),
38
38
  __metadata("design:type", typeof (_a = typeof product_base_1.ProductDetail !== "undefined" && product_base_1.ProductDetail) === "function" ? _a : Object)
39
39
  ], ProductDetailStock.prototype, "productDetail", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.RelationId)((productDetailStock) => productDetailStock.productDetail),
42
+ __metadata("design:type", String)
43
+ ], ProductDetailStock.prototype, "productDetailId", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain, { nullable: true }),
46
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true }),
47
+ __metadata("design:type", typeof (_b = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _b : Object)
48
+ ], ProductDetailStock.prototype, "warehouseDomain", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.RelationId)((productDetailStock) => productDetailStock.warehouseDomain),
51
+ __metadata("design:type", String)
52
+ ], ProductDetailStock.prototype, "warehouseDomainId", void 0);
53
+ __decorate([
54
+ (0, typeorm_1.ManyToOne)(type => biz_base_1.Bizplace, { nullable: true }),
55
+ (0, type_graphql_1.Field)(type => biz_base_1.Bizplace, { nullable: true }),
56
+ __metadata("design:type", typeof (_c = typeof biz_base_1.Bizplace !== "undefined" && biz_base_1.Bizplace) === "function" ? _c : Object)
57
+ ], ProductDetailStock.prototype, "bizplace", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.RelationId)((productDetailStock) => productDetailStock.bizplace),
60
+ __metadata("design:type", String)
61
+ ], ProductDetailStock.prototype, "bizplaceId", void 0);
40
62
  __decorate([
41
63
  (0, typeorm_1.Column)('float'),
42
64
  (0, type_graphql_1.Field)({ nullable: true }),
@@ -70,7 +92,7 @@ __decorate([
70
92
  __decorate([
71
93
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
72
94
  (0, type_graphql_1.Field)({ nullable: true }),
73
- __metadata("design:type", typeof (_b = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _b : Object)
95
+ __metadata("design:type", typeof (_d = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _d : Object)
74
96
  ], ProductDetailStock.prototype, "domain", void 0);
75
97
  __decorate([
76
98
  (0, typeorm_1.RelationId)((productDetailStock) => productDetailStock.domain),
@@ -81,6 +103,11 @@ __decorate([
81
103
  (0, type_graphql_1.Field)({ nullable: true }),
82
104
  __metadata("design:type", Date)
83
105
  ], ProductDetailStock.prototype, "updatedAt", void 0);
106
+ __decorate([
107
+ (0, typeorm_1.CreateDateColumn)(),
108
+ (0, type_graphql_1.Field)({ nullable: true }),
109
+ __metadata("design:type", Date)
110
+ ], ProductDetailStock.prototype, "createdAt", void 0);
84
111
  ProductDetailStock = __decorate([
85
112
  (0, typeorm_1.Entity)(),
86
113
  (0, typeorm_1.Index)('ix_product_detail_stock_0', (productDetailStock) => [productDetailStock.domain, productDetailStock.id], { unique: true }),
@@ -1 +1 @@
1
- {"version":3,"file":"product-detail-stock.js","sourceRoot":"","sources":["../../../server/service/product-detail-stock/product-detail-stock.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAWgB;AAChB,+CAA2E;AAE3E,+DAA4D;AAC5D,iDAA8C;AAE9C,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,iDAAqB,CAAA;IACrB,iDAAqB,CAAA;AACvB,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAGnC;AAED,IAAA,+BAAgB,EAAC,wBAAwB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DACJ;AAEtB;IAAC,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACnC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8DACA;AAE1B;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACjB,cAAM,oBAAN,cAAM;kDAAA;AAEf;IAAC,IAAA,oBAAU,EAAC,CAAC,kBAAsC,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC;;oDACjE;AAEjB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACd,IAAI;qDAAA;AA3CL,kBAAkB;IAP9B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,2BAA2B,EAC3B,CAAC,kBAAsC,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAC9F,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;GAChD,kBAAkB,CA4C9B;AA5CY,gDAAkB"}
1
+ {"version":3,"file":"product-detail-stock.js","sourceRoot":"","sources":["../../../server/service/product-detail-stock/product-detail-stock.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCASgB;AAChB,+CAA2E;AAE3E,uDAAmD;AACnD,+DAA4D;AAC5D,iDAA8C;AAE9C,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,iDAAqB,CAAA;IACrB,iDAAqB,CAAA;AACvB,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAGnC;AAED,IAAA,+BAAgB,EAAC,wBAAwB,EAAE;IACzC,IAAI,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,EAAE,IAAI,EAAE,CAAC;8BACd,IAAI;qDAAA;AAEhB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACd,IAAI;qDAAA;AA/DL,kBAAkB;IAP9B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,2BAA2B,EAC3B,CAAC,kBAAsC,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAC9F,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;GAChD,kBAAkB,CAgE9B;AAhEY,gDAAkB"}
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./inventory-no-generator"), exports);
18
18
  __exportStar(require("./inventory-util"), exports);
19
19
  __exportStar(require("./datetime-util"), exports);
20
+ __exportStar(require("./recommendation-utils"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,mDAAgC;AAChC,kDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,mDAAgC;AAChC,kDAA+B;AAC/B,yDAAsC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildProductDetailLabel = exports.calcVolumeInM3 = exports.toMeters = void 0;
4
+ /**
5
+ * @description Convert a value from a given length unit to meters
6
+ * @param {number} value - The numeric value to convert
7
+ * @param {string} lengthUnit - The unit of the value (mm, cm, m, inch, ft)
8
+ * @param {string} productLabel - Optional label for error context
9
+ * @returns {number} The value converted to meters
10
+ */
11
+ function toMeters(value, lengthUnit, productLabel) {
12
+ switch (lengthUnit === null || lengthUnit === void 0 ? void 0 : lengthUnit.toLowerCase()) {
13
+ case 'mm': return value / 1000;
14
+ case 'cm': return value / 100;
15
+ case 'm': return value;
16
+ case 'inch': return value * 0.0254;
17
+ case 'ft': return value * 0.3048;
18
+ default: throw new Error(`Unsupported length unit: ${lengthUnit}. Supported units are: mm, cm, m, inch, ft` +
19
+ (productLabel ? ` (${productLabel})` : ''));
20
+ }
21
+ }
22
+ exports.toMeters = toMeters;
23
+ /**
24
+ * @description Calculate the volume of a physical object in cubic meters (m³)
25
+ * @description If a pre-calculated volume is provided it will be converted using the length unit.
26
+ * Otherwise volume is derived from width × depth × height.
27
+ * @param {PhysicalDimensions} pd - Object containing dimension fields and length unit
28
+ * @param {string} productLabel - Optional label for error context
29
+ * @returns {number} Volume in cubic meters, rounded to 6 decimal places
30
+ */
31
+ function calcVolumeInM3(pd, productLabel) {
32
+ var _a, _b, _c;
33
+ const factor = toMeters(1, pd.lengthUnit, productLabel);
34
+ if (pd.volume != null)
35
+ return pd.volume * factor * factor * factor;
36
+ const w = toMeters((_a = pd.width) !== null && _a !== void 0 ? _a : 0, pd.lengthUnit, productLabel);
37
+ const d = toMeters((_b = pd.depth) !== null && _b !== void 0 ? _b : 0, pd.lengthUnit, productLabel);
38
+ const h = toMeters((_c = pd.height) !== null && _c !== void 0 ? _c : 0, pd.lengthUnit, productLabel);
39
+ return w * d * h;
40
+ }
41
+ exports.calcVolumeInM3 = calcVolumeInM3;
42
+ /**
43
+ * @description Build a product detail label string from refCode or packingType for use in error messages
44
+ * @param {any} pd - Product detail object containing refCode and/or packingType
45
+ * @returns {string} A label string e.g. 'RefCode: ABC' or 'Packing Type: BOX' or ''
46
+ */
47
+ function buildProductDetailLabel(pd) {
48
+ return (pd === null || pd === void 0 ? void 0 : pd.refCode) ? `RefCode: ${pd.refCode}` : (pd === null || pd === void 0 ? void 0 : pd.packingType) ? `Packing Type: ${pd.packingType}` : '';
49
+ }
50
+ exports.buildProductDetailLabel = buildProductDetailLabel;
51
+ //# sourceMappingURL=recommendation-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommendation-utils.js","sourceRoot":"","sources":["../../server/utils/recommendation-utils.ts"],"names":[],"mappings":";;;AAQA;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,KAAa,EAAE,UAAkB,EAAE,YAAqB;IAC/E,QAAQ,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,EAAE,EAAE;QACjC,KAAK,IAAI,CAAC,CAAC,OAAO,KAAK,GAAG,IAAI,CAAA;QAC9B,KAAK,IAAI,CAAC,CAAC,OAAO,KAAK,GAAG,GAAG,CAAA;QAC7B,KAAK,GAAG,CAAC,CAAC,OAAO,KAAK,CAAA;QACtB,KAAK,MAAM,CAAC,CAAC,OAAO,KAAK,GAAG,MAAM,CAAA;QAClC,KAAK,IAAI,CAAC,CAAC,OAAO,KAAK,GAAG,MAAM,CAAA;QAChC,OAAO,CAAC,CAAC,MAAM,IAAI,KAAK,CACtB,4BAA4B,UAAU,4CAA4C;YAClF,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3C,CAAA;KACF;AACH,CAAC;AAZD,4BAYC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,EAAsB,EAAE,YAAqB;;IAC1E,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;IACvD,IAAI,EAAE,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IAClE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAA,EAAE,CAAC,KAAK,mCAAI,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;IAC9D,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAA,EAAE,CAAC,KAAK,mCAAI,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;IAC9D,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAA,EAAE,CAAC,MAAM,mCAAI,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;IAC/D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC;AAPD,wCAOC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,EAAO;IAC7C,OAAO,CAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,OAAO,EAAC,CAAC,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,WAAW,EAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AAC1G,CAAC;AAFD,0DAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/warehouse-base",
3
- "version": "4.3.824",
3
+ "version": "4.3.827",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -32,5 +32,5 @@
32
32
  "@things-factory/product-base": "^4.3.824",
33
33
  "@things-factory/setting-base": "^4.3.815"
34
34
  },
35
- "gitHead": "7c6aa626b0ce0ce8ab988710b0e8fc2ed0bba5c2"
35
+ "gitHead": "a55ddfb0530459b1dbb45d55ec748368d322b89d"
36
36
  }
@@ -94,7 +94,7 @@ export class PowrupController {
94
94
 
95
95
  const productDetailStock: ProductDetailStock = await trxMgr
96
96
  .getRepository(ProductDetailStock)
97
- .findOne({ productDetail })
97
+ .findOne({ productDetail, warehouseDomain: { id: warehouseDomainId }, bizplace: { id: powrupPartner.bizplace.id } })
98
98
 
99
99
  const powrupInvs: any[] = [
100
100
  {
@@ -82,7 +82,7 @@ export class WebspertController {
82
82
  from inventories i
83
83
  inner join locations loc on loc.id = i.location_id
84
84
  inner join product_details pd on pd.id = i.product_detail_id
85
- left join product_detail_stocks pds on pds.product_detail_id = pd.id
85
+ left join product_detail_stocks pds on pds.product_detail_id = pd.id and pds.warehouse_domain_id = i.domain_id and pds.bizplace_id = i.bizplace_id
86
86
  left join products p on p.id = pd.product_id
87
87
  where
88
88
  loc."type" not in ('QUARANTINE', 'RESERVED') and
package/server/index.ts CHANGED
@@ -15,3 +15,5 @@ export {
15
15
  approveInventoryChanges,
16
16
  submitInventoryChangesService
17
17
  } from './service/inventory-change/inventory-change-mutation'
18
+
19
+ export { upsertProductDetailStockUnassigned } from './service/product-detail-stock/product-detail-stock-mutation'
@@ -509,11 +509,10 @@ export class InventoryQuery {
509
509
  inner join companies c on c.id = bz.company_id
510
510
  inner join bizplaces bz2 on bz2.domain_id = c.domain_id
511
511
  inner join products p on (p.bizplace_id = b.bizplace_id::uuid or p.bizplace_id = bz2.id)
512
- inner join product_details pd on pd.product_id = p.id and pd.is_default
512
+ inner join product_details pd on pd.product_id = p.id
513
513
  left join product_detail_bizplace_settings pdbs on pdbs.product_detail_id = pd.id
514
- left join inventories i on i.bizplace_id =b.bizplace_id and i.product_id = p.id and i.qty >= 0 and i.status <> 'MISSING' and i.status <> 'PUTTING_AWAY' and
514
+ left join inventories i on i.bizplace_id =b.bizplace_id and i.product_id = p.id and i.product_detail_id = pd.id and i.qty >= 0 and i.status <> 'MISSING' and i.status <> 'PUTTING_AWAY' and
515
515
  i.domain_id = $1
516
- left join product_detail_stocks pds on pds.product_detail_id = pd.id and pds.domain_id = i.domain_id
517
516
  left join bizplaces inv_bz on inv_bz.id = i.bizplace_id
518
517
  left join locations inv_loc on inv_loc.id = i.location_id
519
518
  where 1 = 1
@@ -569,7 +568,7 @@ export class InventoryQuery {
569
568
  WHERE i.status = 'PUTTING_AWAY' and i.domain_id = $1
570
569
  GROUP BY i.product_id, i.packing_type, i.packing_size, i.uom
571
570
  ) AS "putawayinv" ON "tih"."id" = "putawayinv"."product_id" AND "tih"."packingType" = "putawayinv"."packing_type"
572
- LEFT JOIN "product_detail_stocks" pds on pds.product_detail_id = "tih"."productDetailId"
571
+ LEFT JOIN "product_detail_stocks" pds on pds.product_detail_id = "tih"."productDetailId" AND pds.warehouse_domain_id = $1 AND pds.bizplace_id = "tih"."bizplaceId"
573
572
  GROUP BY "tih"."id", "sku", "brand", "name", "description", "packingType", "bizplaceId", "bizplaceName", "opd"."total_release_qty","putawayinv"."putaway_qty",
574
573
  "auxUnit1", "auxValue1", "auxUnit2", "auxValue2", "auxUnit3", "auxValue3", "auxUnit4", "auxValue4", "auxUnit5", "auxValue5", pds.unassigned_qty, "uomValue"
575
574
  HAVING 1 = 1
@@ -2,6 +2,7 @@ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
2
  import { EntityManager, Repository } from 'typeorm'
3
3
 
4
4
  import { User } from '@things-factory/auth-base'
5
+ import { Setting } from '@things-factory/setting-base'
5
6
  import { Domain } from '@things-factory/shell'
6
7
 
7
8
  import { Location } from '../location/location'
@@ -15,7 +16,9 @@ export class LocationMutation {
15
16
  @Directive('@transaction')
16
17
  @Mutation(returns => Location)
17
18
  async createLocation(@Arg('location') location: NewLocation, @Ctx() context: any): Promise<Location> {
18
- return await createLocation(location, context)
19
+ const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
20
+ const isLevel4 = await getIsRecommendationLvl4(domain, tx)
21
+ return await createLocation(location, context, isLevel4)
19
22
  }
20
23
 
21
24
  @Directive('@privilege(category: "warehouse", privilege: "mutation")')
@@ -25,6 +28,9 @@ export class LocationMutation {
25
28
  @Arg('patches', type => [LocationPatch]) patches: LocationPatch[],
26
29
  @Ctx() context: any
27
30
  ): Promise<Location[]> {
31
+ const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
32
+ const isLevel4 = await getIsRecommendationLvl4(domain, tx)
33
+
28
34
  let results = []
29
35
  const _createRecords = patches
30
36
  .filter((patch: any) => patch.cuFlag === '+')
@@ -36,7 +42,7 @@ export class LocationMutation {
36
42
  if (_createRecords.length > 0) {
37
43
  for (let i = 0; i < _createRecords.length; i++) {
38
44
  const patch = _createRecords[i]
39
- const result = await createLocation(patch as NewLocation, context)
45
+ const result = await createLocation(patch as NewLocation, context, isLevel4)
40
46
  results.push({ ...result, cuFlag: '+' })
41
47
  }
42
48
  }
@@ -52,7 +58,9 @@ export class LocationMutation {
52
58
  @Arg('patch') patch: LocationPatch,
53
59
  @Ctx() context: any
54
60
  ): Promise<Location> {
55
- return await updateLocation(id, patch, context.state.user)
61
+ const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
62
+ const isLevel4 = await getIsRecommendationLvl4(domain, tx)
63
+ return await updateLocation(id, patch, context, isLevel4)
56
64
  }
57
65
 
58
66
  @Directive('@privilege(category: "warehouse", privilege: "mutation")')
@@ -62,6 +70,9 @@ export class LocationMutation {
62
70
  @Arg('patches', type => [LocationPatch]) patches: LocationPatch[],
63
71
  @Ctx() context: any
64
72
  ): Promise<Location[]> {
73
+ const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
74
+ const isLevel4 = await getIsRecommendationLvl4(domain, tx)
75
+
65
76
  let results = []
66
77
  const _createRecords = patches.filter((patch: any) => patch.cuFlag === '+')
67
78
  const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
@@ -69,7 +80,7 @@ export class LocationMutation {
69
80
  if (_createRecords.length > 0) {
70
81
  for (let i = 0; i < _createRecords.length; i++) {
71
82
  const patch = _createRecords[i]
72
- const result = await createLocation(patch as NewLocation, context)
83
+ const result = await createLocation(patch as NewLocation, context, isLevel4)
73
84
  results.push({ ...result, cuFlag: '+' })
74
85
  }
75
86
  }
@@ -77,7 +88,7 @@ export class LocationMutation {
77
88
  if (_updateRecords.length > 0) {
78
89
  for (let i = 0; i < _updateRecords.length; i++) {
79
90
  const patch: LocationPatch = _updateRecords[i]
80
- const result = await updateLocation(patch.id, patch, context)
91
+ const result = await updateLocation(patch.id, patch, context, isLevel4)
81
92
  results.push({ ...result, cuFlag: 'M' })
82
93
  }
83
94
  }
@@ -125,7 +136,12 @@ export class LocationMutation {
125
136
  }
126
137
  }
127
138
 
128
- export async function createLocation(location: NewLocation, context: any) {
139
+ async function getIsRecommendationLvl4(domain: Domain, tx: EntityManager): Promise<boolean> {
140
+ const setting: Setting = await tx.getRepository(Setting).findOne({ where: { domain, name: 'location-recommendation-level' } })
141
+ return setting?.value?.toLowerCase() === 'level 4'
142
+ }
143
+
144
+ export async function createLocation(location: NewLocation, context: any, isLevel4 = false) {
129
145
  const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
130
146
 
131
147
  const locationRepository: Repository<Location> = tx.getRepository(Location)
@@ -164,8 +180,19 @@ export async function createLocation(location: NewLocation, context: any) {
164
180
  throw new Error(`Existing location found: ${foundLocation.name}`)
165
181
  }
166
182
 
183
+ const { length, width, height } = location
184
+ if (isLevel4 && (!length || !width || !height)) {
185
+ throw new Error('Length, width, and height are required when location recommendation level is set to level 4')
186
+ }
187
+
188
+ const volume =
189
+ length > 0 && width > 0 && height > 0
190
+ ? parseFloat((length * width * height).toFixed(2))
191
+ : null
192
+
167
193
  return await locationRepository.save({
168
194
  ...location,
195
+ volume,
169
196
  warehouse: await warehouseRepository.findOne(location.warehouse.id),
170
197
  domain,
171
198
  creator: user,
@@ -173,7 +200,7 @@ export async function createLocation(location: NewLocation, context: any) {
173
200
  })
174
201
  }
175
202
 
176
- export async function updateLocation(id: string, patch: LocationPatch, context: any) {
203
+ export async function updateLocation(id: string, patch: LocationPatch, context: any, isLevel4 = false) {
177
204
  const { user, domain, tx }: { user: User; domain: Domain; tx: EntityManager } = context.state
178
205
 
179
206
  const locationRepository: Repository<Location> = tx.getRepository(Location)
@@ -234,9 +261,23 @@ export async function updateLocation(id: string, patch: LocationPatch, context:
234
261
  }
235
262
  }
236
263
 
264
+ const updatedLength = patch.length !== undefined ? patch.length : location.length
265
+ const updatedWidth = patch.width !== undefined ? patch.width : location.width
266
+ const updatedHeight = patch.height !== undefined ? patch.height : location.height
267
+
268
+ if (isLevel4 && (!updatedLength || !updatedWidth || !updatedHeight)) {
269
+ throw new Error('Length, width, and height are required when location recommendation level is set to level 4')
270
+ }
271
+
272
+ const volume =
273
+ updatedLength > 0 && updatedWidth > 0 && updatedHeight > 0
274
+ ? parseFloat((updatedLength * updatedWidth * updatedHeight).toFixed(2))
275
+ : null
276
+
237
277
  return await locationRepository.save({
238
278
  ...location,
239
279
  ...patch,
280
+ volume,
240
281
  updater: user
241
282
  })
242
283
  }
@@ -150,6 +150,18 @@ export class LocationPatch {
150
150
  @Field({ nullable: true })
151
151
  status?: string
152
152
 
153
+ @Field(type => Float, { nullable: true })
154
+ length?: number
155
+
156
+ @Field(type => Float, { nullable: true })
157
+ width?: number
158
+
159
+ @Field(type => Float, { nullable: true })
160
+ height?: number
161
+
162
+ @Field({ nullable: true })
163
+ locationClass?: string
164
+
153
165
  @Field({ nullable: true })
154
166
  cuFlag?: string
155
167
  }
@@ -191,6 +203,18 @@ export class NewLocation {
191
203
 
192
204
  @Field()
193
205
  status: string
206
+
207
+ @Field(type => Float, { nullable: true })
208
+ length?: number
209
+
210
+ @Field(type => Float, { nullable: true })
211
+ width?: number
212
+
213
+ @Field(type => Float, { nullable: true })
214
+ height?: number
215
+
216
+ @Field({ nullable: true })
217
+ locationClass?: string
194
218
  }
195
219
 
196
220
  @InputType()
@@ -1,4 +1,4 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
1
+ import { Field, Float, ID, ObjectType } from 'type-graphql'
2
2
  import {
3
3
  Column,
4
4
  CreateDateColumn,
@@ -78,6 +78,26 @@ export class Location {
78
78
  @Field()
79
79
  status: string
80
80
 
81
+ @Column({ type: 'float', nullable: true })
82
+ @Field(type => Float, { nullable: true })
83
+ length: number
84
+
85
+ @Column({ type: 'float', nullable: true })
86
+ @Field(type => Float, { nullable: true })
87
+ width: number
88
+
89
+ @Column({ type: 'float', nullable: true })
90
+ @Field(type => Float, { nullable: true })
91
+ height: number
92
+
93
+ @Column({ type: 'float', nullable: true })
94
+ @Field(type => Float, { nullable: true })
95
+ volume: number
96
+
97
+ @Column({ nullable: true })
98
+ @Field({ nullable: true })
99
+ locationClass: string
100
+
81
101
  @ManyToOne(type => User, {
82
102
  nullable: true
83
103
  })
@@ -1,5 +1,5 @@
1
1
  import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
- import { getRepository, In } from 'typeorm'
2
+ import { EntityManager, getRepository, In } from 'typeorm'
3
3
  import { ProductDetailStock } from './product-detail-stock'
4
4
  import { NewProductDetailStock, ProductDetailStockPatch } from './product-detail-stock-types'
5
5
 
@@ -110,3 +110,35 @@ export class ProductDetailStockMutation {
110
110
  return true
111
111
  }
112
112
  }
113
+
114
+ export async function upsertProductDetailStockUnassigned(
115
+ tx: EntityManager,
116
+ productDetailId: string,
117
+ warehouseDomainId: string,
118
+ bizplaceId: string,
119
+ releaseQty: number,
120
+ releaseUomValue: number
121
+ ): Promise<void> {
122
+ await tx.query(
123
+ `
124
+ INSERT INTO product_detail_stocks (
125
+ id, product_detail_id, warehouse_domain_id, bizplace_id, domain_id,
126
+ qty, locked_qty, unassigned_qty,
127
+ uom_value, locked_uom_value, unassigned_uom_value,
128
+ updated_at, created_at
129
+ )
130
+ SELECT
131
+ gen_random_uuid(), pd.id, $1, $2, pd.domain_id,
132
+ 0, 0, $3,
133
+ 0, 0, $4,
134
+ NOW(), NOW()
135
+ FROM product_details pd
136
+ WHERE pd.id = $5
137
+ ON CONFLICT ON CONSTRAINT uq_pds_pd_warehouse DO UPDATE SET
138
+ unassigned_qty = GREATEST(product_detail_stocks.unassigned_qty + EXCLUDED.unassigned_qty, 0),
139
+ unassigned_uom_value = GREATEST(product_detail_stocks.unassigned_uom_value + EXCLUDED.unassigned_uom_value, 0),
140
+ updated_at = NOW()
141
+ `,
142
+ [warehouseDomainId, bizplaceId, releaseQty, releaseUomValue, productDetailId]
143
+ )
144
+ }
@@ -6,12 +6,11 @@ import {
6
6
  Column,
7
7
  RelationId,
8
8
  ManyToOne,
9
- OneToOne,
10
- JoinColumn,
11
9
  PrimaryGeneratedColumn
12
10
  } from 'typeorm'
13
11
  import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
14
12
 
13
+ import { Bizplace } from '@things-factory/biz-base'
15
14
  import { ProductDetail } from '@things-factory/product-base'
16
15
  import { Domain } from '@things-factory/shell'
17
16
 
@@ -37,11 +36,27 @@ export class ProductDetailStock {
37
36
  @Field(type => ID)
38
37
  readonly id: string
39
38
 
40
- @OneToOne(type => ProductDetail, { nullable: true })
41
- @JoinColumn()
39
+ @ManyToOne(type => ProductDetail, { nullable: true })
42
40
  @Field(type => ProductDetail, { nullable: true })
43
41
  productDetail: ProductDetail
44
42
 
43
+ @RelationId((productDetailStock: ProductDetailStock) => productDetailStock.productDetail)
44
+ productDetailId?: string
45
+
46
+ @ManyToOne(type => Domain, { nullable: true })
47
+ @Field(type => Domain, { nullable: true })
48
+ warehouseDomain?: Domain
49
+
50
+ @RelationId((productDetailStock: ProductDetailStock) => productDetailStock.warehouseDomain)
51
+ warehouseDomainId?: string
52
+
53
+ @ManyToOne(type => Bizplace, { nullable: true })
54
+ @Field(type => Bizplace, { nullable: true })
55
+ bizplace?: Bizplace
56
+
57
+ @RelationId((productDetailStock: ProductDetailStock) => productDetailStock.bizplace)
58
+ bizplaceId?: string
59
+
45
60
  @Column('float')
46
61
  @Field({ nullable: true })
47
62
  qty: number
@@ -76,4 +91,8 @@ export class ProductDetailStock {
76
91
  @UpdateDateColumn()
77
92
  @Field({ nullable: true })
78
93
  updatedAt?: Date
94
+
95
+ @CreateDateColumn()
96
+ @Field({ nullable: true })
97
+ createdAt?: Date
79
98
  }
@@ -1,3 +1,4 @@
1
1
  export * from './inventory-no-generator'
2
2
  export * from './inventory-util'
3
3
  export * from './datetime-util'
4
+ export * from './recommendation-utils'
@@ -0,0 +1,54 @@
1
+ export interface PhysicalDimensions {
2
+ lengthUnit: string
3
+ volume?: number
4
+ width?: number
5
+ depth?: number
6
+ height?: number
7
+ }
8
+
9
+ /**
10
+ * @description Convert a value from a given length unit to meters
11
+ * @param {number} value - The numeric value to convert
12
+ * @param {string} lengthUnit - The unit of the value (mm, cm, m, inch, ft)
13
+ * @param {string} productLabel - Optional label for error context
14
+ * @returns {number} The value converted to meters
15
+ */
16
+ export function toMeters(value: number, lengthUnit: string, productLabel?: string): number {
17
+ switch (lengthUnit?.toLowerCase()) {
18
+ case 'mm': return value / 1000
19
+ case 'cm': return value / 100
20
+ case 'm': return value
21
+ case 'inch': return value * 0.0254
22
+ case 'ft': return value * 0.3048
23
+ default: throw new Error(
24
+ `Unsupported length unit: ${lengthUnit}. Supported units are: mm, cm, m, inch, ft` +
25
+ (productLabel ? ` (${productLabel})` : '')
26
+ )
27
+ }
28
+ }
29
+
30
+ /**
31
+ * @description Calculate the volume of a physical object in cubic meters (m³)
32
+ * @description If a pre-calculated volume is provided it will be converted using the length unit.
33
+ * Otherwise volume is derived from width × depth × height.
34
+ * @param {PhysicalDimensions} pd - Object containing dimension fields and length unit
35
+ * @param {string} productLabel - Optional label for error context
36
+ * @returns {number} Volume in cubic meters, rounded to 6 decimal places
37
+ */
38
+ export function calcVolumeInM3(pd: PhysicalDimensions, productLabel?: string): number {
39
+ const factor = toMeters(1, pd.lengthUnit, productLabel)
40
+ if (pd.volume != null) return pd.volume * factor * factor * factor
41
+ const w = toMeters(pd.width ?? 0, pd.lengthUnit, productLabel)
42
+ const d = toMeters(pd.depth ?? 0, pd.lengthUnit, productLabel)
43
+ const h = toMeters(pd.height ?? 0, pd.lengthUnit, productLabel)
44
+ return w * d * h
45
+ }
46
+
47
+ /**
48
+ * @description Build a product detail label string from refCode or packingType for use in error messages
49
+ * @param {any} pd - Product detail object containing refCode and/or packingType
50
+ * @returns {string} A label string e.g. 'RefCode: ABC' or 'Packing Type: BOX' or ''
51
+ */
52
+ export function buildProductDetailLabel(pd: any): string {
53
+ return pd?.refCode ? `RefCode: ${pd.refCode}` : pd?.packingType ? `Packing Type: ${pd.packingType}` : ''
54
+ }