@things-factory/operato-hub 4.3.32 → 4.3.33

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.
@@ -6,6 +6,9 @@ definitions:
6
6
  - 'name'
7
7
  - 'type'
8
8
  properties:
9
+ id:
10
+ type: 'uuid'
11
+ example: '4550ba8e-5702-4337-bfa6-5e2718468724'
9
12
  sku:
10
13
  type: 'string'
11
14
  example: 'LB-18'
@@ -30,6 +33,9 @@ definitions:
30
33
  example: 'COLGATE MINT'
31
34
  isRequiredCheckExpiry:
32
35
  type: 'boolean'
36
+ pickingStrategy:
37
+ type: 'string'
38
+ example: 'FIFO'
33
39
  expirationPeriod:
34
40
  type: 'integer'
35
41
  description: 'value should be in days (eg:300 and half day)'
@@ -213,9 +219,9 @@ paths:
213
219
  content:
214
220
  application/json:
215
221
  schema:
216
- type: 'array'
217
- items:
218
- $ref: '#/definitions/Product'
222
+ type: 'array'
223
+ items:
224
+ $ref: '#/definitions/Product'
219
225
  '400':
220
226
  description: 'Bad request is sent'
221
227
  '401':
@@ -6,6 +6,9 @@ definitions:
6
6
  - 'name'
7
7
  - 'type'
8
8
  properties:
9
+ id:
10
+ type: 'uuid'
11
+ example: '4550ba8e-5702-4337-bfa6-5e2718468724'
9
12
  sku:
10
13
  type: 'string'
11
14
  example: 'LB-18'
@@ -30,6 +33,9 @@ definitions:
30
33
  example: 'COLGATE MINT'
31
34
  isRequiredCheckExpiry:
32
35
  type: 'boolean'
36
+ pickingStrategy:
37
+ type: 'string'
38
+ example: 'FIFO'
33
39
  expirationPeriod:
34
40
  type: 'integer'
35
41
  description: 'value should be in days (eg:300 and half day)'
@@ -213,9 +219,9 @@ paths:
213
219
  content:
214
220
  application/json:
215
221
  schema:
216
- type: 'array'
217
- items:
218
- $ref: '#/definitions/Product'
222
+ type: 'array'
223
+ items:
224
+ $ref: '#/definitions/Product'
219
225
  '400':
220
226
  description: 'Bad request is sent'
221
227
  '401':
@@ -6,6 +6,9 @@ definitions:
6
6
  - 'name'
7
7
  - 'type'
8
8
  properties:
9
+ id:
10
+ type: 'uuid'
11
+ example: '4550ba8e-5702-4337-bfa6-5e2718468724'
9
12
  sku:
10
13
  type: 'string'
11
14
  example: 'LB-18'
@@ -30,6 +33,9 @@ definitions:
30
33
  example: 'COLGATE MINT'
31
34
  isRequiredCheckExpiry:
32
35
  type: 'boolean'
36
+ pickingStrategy:
37
+ type: 'string'
38
+ example: 'FIFO'
33
39
  expirationPeriod:
34
40
  type: 'integer'
35
41
  description: 'value should be in days (eg:300 and half day)'
@@ -213,9 +219,9 @@ paths:
213
219
  content:
214
220
  application/json:
215
221
  schema:
216
- type: 'array'
217
- items:
218
- $ref: '#/definitions/Product'
222
+ type: 'array'
223
+ items:
224
+ $ref: '#/definitions/Product'
219
225
  '400':
220
226
  description: 'Bad request is sent'
221
227
  '401':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-hub",
3
- "version": "4.3.32",
3
+ "version": "4.3.33",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -78,19 +78,19 @@
78
78
  "@things-factory/import-ui": "^4.3.32",
79
79
  "@things-factory/import-ui-excel": "^4.3.32",
80
80
  "@things-factory/integration-accounting": "^4.3.32",
81
- "@things-factory/integration-fulfillment": "^4.3.32",
81
+ "@things-factory/integration-fulfillment": "^4.3.33",
82
82
  "@things-factory/integration-lmd": "^4.3.32",
83
- "@things-factory/integration-marketplace": "^4.3.32",
83
+ "@things-factory/integration-marketplace": "^4.3.33",
84
84
  "@things-factory/integration-pos": "^4.3.32",
85
- "@things-factory/integration-sellercraft": "^4.3.32",
86
- "@things-factory/integration-sftp": "^4.3.32",
85
+ "@things-factory/integration-sellercraft": "^4.3.33",
86
+ "@things-factory/integration-sftp": "^4.3.33",
87
87
  "@things-factory/lite-menu": "^4.3.32",
88
88
  "@things-factory/more-ui": "^4.3.32",
89
89
  "@things-factory/notification": "^4.3.32",
90
90
  "@things-factory/pdf": "^4.3.32",
91
91
  "@things-factory/product-ui": "^4.3.32",
92
92
  "@things-factory/resource-ui": "^4.3.32",
93
- "@things-factory/sales-base": "^4.3.32",
93
+ "@things-factory/sales-base": "^4.3.33",
94
94
  "@things-factory/scene-data-transform": "^4.3.32",
95
95
  "@things-factory/scene-excel": "^4.3.32",
96
96
  "@things-factory/scene-firebase": "^4.3.32",
@@ -105,8 +105,8 @@
105
105
  "@things-factory/setting-ui": "^4.3.32",
106
106
  "@things-factory/shell": "^4.3.32",
107
107
  "@things-factory/system-ui": "^4.3.32",
108
- "@things-factory/warehouse-base": "^4.3.32",
109
- "@things-factory/worksheet-base": "^4.3.32",
108
+ "@things-factory/warehouse-base": "^4.3.33",
109
+ "@things-factory/worksheet-base": "^4.3.33",
110
110
  "koa2-swagger-ui": "^5.0.2",
111
111
  "swagger-jsdoc": "^5.0.0",
112
112
  "yamljs": "^0.3.0"
@@ -117,5 +117,5 @@
117
117
  "resolutions": {
118
118
  "core-js": "^3.16.0"
119
119
  },
120
- "gitHead": "0c5bd74405efd1db48838320c9afa68811c3e37a"
120
+ "gitHead": "e4f9100eef61d010cca0a9692f413f60be2e462c"
121
121
  }
@@ -29,6 +29,8 @@ router.post(
29
29
  await checkMandatoryKey(context, bodyReq)
30
30
  debug('post:/add-product request.body', bodyReq)
31
31
 
32
+ let products = checkProductDetails(bodyReq)
33
+
32
34
  context.body = {
33
35
  result: (
34
36
  await client.mutate({
@@ -39,7 +41,7 @@ router.post(
39
41
  }
40
42
  }
41
43
  `,
42
- variables: { products: bodyReq },
44
+ variables: { products },
43
45
  context: {
44
46
  ...context,
45
47
  state: {
@@ -66,23 +68,45 @@ export async function checkMandatoryKey(context, params) {
66
68
 
67
69
  if (param?.productDetails) {
68
70
  let noSubParams = []
69
- param.productDetails.forEach((subParam, key) => {
70
- if (!subParam.gtin) noSubParams.push('gtin')
71
-
72
- if (!subParam.packingType) noSubParams.push('packingType')
73
-
74
- if (!subParam.packingSize) noSubParams.push('packingSize')
75
-
76
- if (!subParam.uom) noSubParams.push('uom')
77
-
78
- if (!subParam.uomValue) noSubParams.push('uomValue')
79
-
80
- if (noSubParams?.length)
81
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
82
- })
71
+ if (param.productDetails.length == 0) {
72
+ context.throw(
73
+ 400,
74
+ context.t('error.required param {x} not found in productDetails', {
75
+ x: 'gtin, packingType, packingSize, uom, uomValue'
76
+ })
77
+ )
78
+ } else {
79
+ param.productDetails.forEach((subParam, key) => {
80
+ if (!subParam.gtin) noSubParams.push('gtin')
81
+
82
+ if (!subParam.packingType) noSubParams.push('packingType')
83
+
84
+ if (!subParam.packingSize) noSubParams.push('packingSize')
85
+
86
+ if (!subParam.uom) noSubParams.push('uom')
87
+
88
+ if (!subParam.uomValue) noSubParams.push('uomValue')
89
+
90
+ if (noSubParams?.length)
91
+ context.throw(
92
+ 400,
93
+ context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` })
94
+ )
95
+ })
96
+ }
83
97
  }
84
98
 
85
99
  if (noparams?.length)
86
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
100
+ context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }))
87
101
  })
88
102
  }
103
+
104
+ function checkProductDetails(params) {
105
+ params.forEach(param => {
106
+ if (!param?.productDetails.some(pd => pd.isDefault)) {
107
+ param.productDetails[0].isDefault = true
108
+ }
109
+ })
110
+
111
+ return params
112
+ }
@@ -172,22 +172,25 @@ router.post(
172
172
  let assignedOrderProducts = await assignToInventory(massagedData.orderProducts, customerBizplace, context, tx)
173
173
  console.timeEnd('assign')
174
174
 
175
+ const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({ domain: customerBizplace.domain })
176
+ if (sellercraft) {
177
+ try {
178
+ const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
179
+ let packageInfo = await sellercraftCtrl.packOrder(sellercraft, {
180
+ ...releaseGood,
181
+ orderProducts: assignedOrderProducts
182
+ })
183
+ releaseGood.packageId = packageInfo.packageId
184
+ } catch (error) {
185
+ logger.error(`add-release-order[packageId][refNo: ${releaseGood.refNo}, refNo2: ${releaseGood.refNo2}]: ${JSON.stringify(error)}`)
186
+ }
187
+ }
188
+
175
189
  // create order
176
190
  console.time('save')
177
191
  let result = await createReleaseGood(releaseGood, assignedOrderProducts, customerBizplace, context, tx)
178
192
  console.timeEnd('save')
179
193
 
180
- const sellercraft: Sellercraft = await tx
181
- .getRepository(Sellercraft)
182
- .findOne({ domain: customerBizplace.domain })
183
-
184
- if (sellercraft) {
185
- const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
186
- await sellercraftCtrl.packOrder(sellercraft, {
187
- ...result,
188
- orderProducts: result.orderProducts
189
- })
190
- }
191
194
 
192
195
  let addReleaseGood = {
193
196
  id: result.id,
@@ -424,7 +427,6 @@ async function createReleaseGood(
424
427
  })
425
428
 
426
429
  newReleaseGood = {
427
- ...newReleaseGood,
428
430
  name: roNoSetting
429
431
  ? await generateId({ domain, type: ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
430
432
  : OrderNoGenerator.releaseGood(),
@@ -467,6 +469,7 @@ async function createReleaseGood(
467
469
  storeId: releaseGood?.storeId,
468
470
  routeId: releaseGood?.routeId,
469
471
  stopId: releaseGood?.stopId,
472
+ packageId: releaseGood?.packageId || null,
470
473
  noOfItems: orderProducts.length,
471
474
  creator: user,
472
475
  updater: user,
@@ -909,8 +912,7 @@ async function assignToInventory(orderProducts: OrderProduct[], customerBizplace
909
912
  sum(qty - locked_qty - release_qty) over (order by sort_seq asc rows between unbounded preceding and current row) as lock_amount
910
913
  from (
911
914
  SELECT 0 as sort_seq, null as id, null as pallet_id, null as batch_id, null as batch_id_ref,
912
- null as unit, '${orderInventory.uom}' as uom, '${orderInventory.packingType}' as packing_type, '${
913
- orderInventory.packingSize
915
+ null as unit, '${orderInventory.uom}' as uom, '${orderInventory.packingType}' as packing_type, '${orderInventory.packingSize
914
916
  }' as packing_size,
915
917
  null as manufacture_year, null as carton_id, 0 as uom_value, 0 as locked_uom_value, 0 as qty, 0 as locked_qty, null as created_at,
916
918
  '${orderInventory.releaseQty}' as release_qty, '${orderInventory.releaseUomValue}' as release_uom_value
@@ -40,6 +40,7 @@ router.get(
40
40
  brandSku
41
41
  isRequiredCheckExpiry
42
42
  expirationPeriod
43
+ pickingStrategy
43
44
  auxUnit1
44
45
  auxValue1
45
46
  auxUnit2
@@ -29,6 +29,8 @@ router.post(
29
29
  await checkMandatoryKey(context, bodyReq)
30
30
  debug('post:/add-product request.body', bodyReq)
31
31
 
32
+ let products = checkProductDetails(bodyReq)
33
+
32
34
  context.body = {
33
35
  result: (
34
36
  await client.mutate({
@@ -39,7 +41,7 @@ router.post(
39
41
  }
40
42
  }
41
43
  `,
42
- variables: { products: bodyReq },
44
+ variables: { products },
43
45
  context: {
44
46
  ...context,
45
47
  state: {
@@ -66,23 +68,45 @@ export async function checkMandatoryKey(context, params) {
66
68
 
67
69
  if (param?.productDetails) {
68
70
  let noSubParams = []
69
- param.productDetails.forEach((subParam, key) => {
70
- if (!subParam.gtin) noSubParams.push('gtin')
71
-
72
- if (!subParam.packingType) noSubParams.push('packingType')
73
-
74
- if (!subParam.packingSize) noSubParams.push('packingSize')
75
-
76
- if (!subParam.uom) noSubParams.push('uom')
77
-
78
- if (!subParam.uomValue) noSubParams.push('uomValue')
79
-
80
- if (noSubParams?.length)
81
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
82
- })
71
+ if (param.productDetails.length == 0) {
72
+ context.throw(
73
+ 400,
74
+ context.t('error.required param {x} not found in productDetails', {
75
+ x: 'gtin, packingType, packingSize, uom, uomValue'
76
+ })
77
+ )
78
+ } else {
79
+ param.productDetails.forEach((subParam, key) => {
80
+ if (!subParam.gtin) noSubParams.push('gtin')
81
+
82
+ if (!subParam.packingType) noSubParams.push('packingType')
83
+
84
+ if (!subParam.packingSize) noSubParams.push('packingSize')
85
+
86
+ if (!subParam.uom) noSubParams.push('uom')
87
+
88
+ if (!subParam.uomValue) noSubParams.push('uomValue')
89
+
90
+ if (noSubParams?.length)
91
+ context.throw(
92
+ 400,
93
+ context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` })
94
+ )
95
+ })
96
+ }
83
97
  }
84
98
 
85
99
  if (noparams?.length)
86
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
100
+ context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }))
87
101
  })
88
102
  }
103
+
104
+ function checkProductDetails(params) {
105
+ params.forEach(param => {
106
+ if (!param?.productDetails.some(pd => pd.isDefault)) {
107
+ param.productDetails[0].isDefault = true
108
+ }
109
+ })
110
+
111
+ return params
112
+ }
@@ -40,6 +40,7 @@ router.get(
40
40
  brandSku
41
41
  isRequiredCheckExpiry
42
42
  expirationPeriod
43
+ pickingStrategy
43
44
  auxUnit1
44
45
  auxValue1
45
46
  auxUnit2
@@ -29,6 +29,8 @@ router.post(
29
29
  await checkMandatoryKey(context, bodyReq)
30
30
  debug('post:/add-product request.body', bodyReq)
31
31
 
32
+ let products = checkProductDetails(bodyReq)
33
+
32
34
  context.body = {
33
35
  result: (
34
36
  await client.mutate({
@@ -39,7 +41,7 @@ router.post(
39
41
  }
40
42
  }
41
43
  `,
42
- variables: { products: bodyReq },
44
+ variables: { products },
43
45
  context: {
44
46
  ...context,
45
47
  state: {
@@ -66,23 +68,45 @@ export async function checkMandatoryKey(context, params) {
66
68
 
67
69
  if (param?.productDetails) {
68
70
  let noSubParams = []
69
- param.productDetails.forEach((subParam, key) => {
70
- if (!subParam.gtin) noSubParams.push('gtin')
71
-
72
- if (!subParam.packingType) noSubParams.push('packingType')
73
-
74
- if (!subParam.packingSize) noSubParams.push('packingSize')
75
-
76
- if (!subParam.uom) noSubParams.push('uom')
77
-
78
- if (!subParam.uomValue) noSubParams.push('uomValue')
79
-
80
- if (noSubParams?.length)
81
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
82
- })
71
+ if (param.productDetails.length == 0) {
72
+ context.throw(
73
+ 400,
74
+ context.t('error.required param {x} not found in productDetails', {
75
+ x: 'gtin, packingType, packingSize, uom, uomValue'
76
+ })
77
+ )
78
+ } else {
79
+ param.productDetails.forEach((subParam, key) => {
80
+ if (!subParam.gtin) noSubParams.push('gtin')
81
+
82
+ if (!subParam.packingType) noSubParams.push('packingType')
83
+
84
+ if (!subParam.packingSize) noSubParams.push('packingSize')
85
+
86
+ if (!subParam.uom) noSubParams.push('uom')
87
+
88
+ if (!subParam.uomValue) noSubParams.push('uomValue')
89
+
90
+ if (noSubParams?.length)
91
+ context.throw(
92
+ 400,
93
+ context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` })
94
+ )
95
+ })
96
+ }
83
97
  }
84
98
 
85
99
  if (noparams?.length)
86
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
100
+ context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }))
87
101
  })
88
102
  }
103
+
104
+ function checkProductDetails(params) {
105
+ params.forEach(param => {
106
+ if (!param?.productDetails.some(pd => pd.isDefault)) {
107
+ param.productDetails[0].isDefault = true
108
+ }
109
+ })
110
+
111
+ return params
112
+ }
@@ -40,6 +40,7 @@ router.get(
40
40
  brandSku
41
41
  isRequiredCheckExpiry
42
42
  expirationPeriod
43
+ pickingStrategy
43
44
  auxUnit1
44
45
  auxValue1
45
46
  auxUnit2