@things-factory/worksheet-base 4.3.641 → 4.3.643

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 (39) hide show
  1. package/dist-server/controllers/inbound/unloading-worksheet-controller.js +14 -24
  2. package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
  3. package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +5 -1
  4. package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
  5. package/dist-server/controllers/outbound/packing-worksheet-controller.js +23 -10
  6. package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
  7. package/dist-server/controllers/outbound/picking-worksheet-controller.js +7 -6
  8. package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
  9. package/dist-server/controllers/outbound/returning-worksheet-controller.js +1 -1
  10. package/dist-server/controllers/outbound/returning-worksheet-controller.js.map +1 -1
  11. package/dist-server/controllers/outbound/sorting-worksheet-controller.js +7 -1
  12. package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
  13. package/dist-server/controllers/replenishment/replenishment-worksheet-controller.js +1 -1
  14. package/dist-server/controllers/replenishment/replenishment-worksheet-controller.js.map +1 -1
  15. package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +5 -2
  16. package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
  17. package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +6 -18
  18. package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
  19. package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +1 -1
  20. package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
  21. package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js +6 -6
  22. package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js.map +1 -1
  23. package/dist-server/graphql/types/worksheet/index.js +11 -11
  24. package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +7 -6
  25. package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
  26. package/package.json +12 -12
  27. package/server/controllers/inbound/unloading-worksheet-controller.ts +32 -47
  28. package/server/controllers/inspect/cycle-count-worksheet-controller.ts +6 -1
  29. package/server/controllers/outbound/packing-worksheet-controller.ts +30 -18
  30. package/server/controllers/outbound/picking-worksheet-controller.ts +10 -7
  31. package/server/controllers/outbound/returning-worksheet-controller.ts +1 -1
  32. package/server/controllers/outbound/sorting-worksheet-controller.ts +7 -1
  33. package/server/controllers/replenishment/replenishment-worksheet-controller.ts +1 -1
  34. package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +8 -14
  35. package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +6 -19
  36. package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +2 -1
  37. package/server/graphql/resolvers/worksheet/proceed-extra-products.ts +65 -59
  38. package/server/graphql/types/worksheet/index.ts +11 -11
  39. package/server/graphql/types/worksheet/worksheet-detail-info.ts +7 -6
@@ -21,12 +21,12 @@ exports.WorksheetDetailInfo = (0, apollo_server_koa_1.gql) `
21
21
  expirationDate: String
22
22
  palletQty: Int
23
23
  actualPalletQty: Int
24
- packQty: Int
25
- actualPackQty: Int
24
+ packQty: Float
25
+ actualPackQty: Float
26
26
  adjustedPalletQty: Int
27
27
  adjustedBatchId: String
28
28
  sku: String
29
- qty: Int
29
+ qty: Float
30
30
  uom: String
31
31
  uomValue: Float
32
32
  releaseQty: Float
@@ -35,13 +35,14 @@ exports.WorksheetDetailInfo = (0, apollo_server_koa_1.gql) `
35
35
  sortedQty: Float
36
36
  releaseUomValue: Float
37
37
  inspectedBatchNo: String
38
- originQty: Int
38
+ originQty: Float
39
39
  originUomValue: Float
40
40
  originExpirationDate: String
41
- inspectedQty: Int
41
+ inspectedQty: Float
42
42
  inspectedUomValue: Float
43
43
  inspectedExpirationDate: String
44
44
  inspectedLocation: Location
45
+ isInventoryDecimal: Boolean
45
46
  operationGuide: String
46
47
  set: Int
47
48
  targetType: String
@@ -67,7 +68,7 @@ exports.WorksheetDetailInfo = (0, apollo_server_koa_1.gql) `
67
68
  relatedInvCheckItem: InventoryCheckItem
68
69
  targetInventoryCheckItem: InventoryCheckItem
69
70
  releaseGood: ReleaseGood
70
- actualQty: Int
71
+ actualQty: Float
71
72
  actualUomValue: Float
72
73
  manufactureDate: String
73
74
  binRemarks: String
@@ -1 +1 @@
1
- {"version":3,"file":"worksheet-detail-info.js","sourceRoot":"","sources":["../../../../server/graphql/types/worksheet/worksheet-detail-info.ts"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,mBAAmB,GAAG,IAAA,uBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFrC,CAAA"}
1
+ {"version":3,"file":"worksheet-detail-info.js","sourceRoot":"","sources":["../../../../server/graphql/types/worksheet/worksheet-detail-info.ts"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,mBAAmB,GAAG,IAAA,uBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFrC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/worksheet-base",
3
- "version": "4.3.641",
3
+ "version": "4.3.643",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,24 +26,24 @@
26
26
  "@things-factory/auth-base": "^4.3.591",
27
27
  "@things-factory/biz-base": "^4.3.595",
28
28
  "@things-factory/document-template-base": "^4.3.591",
29
- "@things-factory/id-rule-base": "^4.3.638",
30
- "@things-factory/integration-accounting": "^4.3.639",
29
+ "@things-factory/id-rule-base": "^4.3.642",
30
+ "@things-factory/integration-accounting": "^4.3.642",
31
31
  "@things-factory/integration-base": "^4.3.616",
32
- "@things-factory/integration-lmd": "^4.3.639",
33
- "@things-factory/integration-marketplace": "^4.3.639",
34
- "@things-factory/integration-powrup": "^4.3.639",
35
- "@things-factory/integration-sellercraft": "^4.3.639",
36
- "@things-factory/integration-sftp": "^4.3.638",
37
- "@things-factory/marketplace-base": "^4.3.639",
32
+ "@things-factory/integration-lmd": "^4.3.642",
33
+ "@things-factory/integration-marketplace": "^4.3.642",
34
+ "@things-factory/integration-powrup": "^4.3.642",
35
+ "@things-factory/integration-sellercraft": "^4.3.642",
36
+ "@things-factory/integration-sftp": "^4.3.642",
37
+ "@things-factory/marketplace-base": "^4.3.642",
38
38
  "@things-factory/notification": "^4.3.609",
39
- "@things-factory/sales-base": "^4.3.639",
39
+ "@things-factory/sales-base": "^4.3.643",
40
40
  "@things-factory/setting-base": "^4.3.609",
41
41
  "@things-factory/shell": "^4.3.591",
42
42
  "@things-factory/transport-base": "^4.3.631",
43
- "@things-factory/warehouse-base": "^4.3.639",
43
+ "@things-factory/warehouse-base": "^4.3.642",
44
44
  "jspdf": "2.5.1",
45
45
  "puppeteer": "21.0.3",
46
46
  "uuid": "^9.0.0"
47
47
  },
48
- "gitHead": "e888b1da2aa27b44ba23004f657159d825c6d1c6"
48
+ "gitHead": "9b5f709abba1e4ef3c320848ea6e5c217410baef"
49
49
  }
@@ -122,9 +122,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
122
122
  let productDetail: ProductDetail = Boolean(arrivalNotice)
123
123
  ? targetProduct.productDetail
124
124
  : targetOrderInventory.productDetail
125
- let qty: number = inventory.qty
125
+ let qty: number = Number(inventory.qty)
126
126
  let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : originInventory.uom
127
127
 
128
+ if (isNaN(qty) || qty <= 0) {
129
+ throw new Error('Invalid quantity value')
130
+ }
131
+
128
132
  if (!inventory?.palletId) {
129
133
  if (!inventory?.cartonId) {
130
134
  throw new Error('missing carton Id')
@@ -158,7 +162,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
158
162
  zone: location.zone,
159
163
  location: location,
160
164
  expirationDate: inventory?.expirationDate ? new Date(inventory.expirationDate) : undefined,
161
- status: INVENTORY_STATUS.UNLOADED
165
+ status: INVENTORY_STATUS.UNLOADED,
166
+ qty: qty
162
167
  }
163
168
 
164
169
  if (inventory.reusablePallet?.id) {
@@ -191,10 +196,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
191
196
  (Boolean(arrivalNotice)
192
197
  ? targetProduct.uomValue
193
198
  : targetOrderInventory.returnUomValue / targetOrderInventory.returnQty) *
194
- 100
195
- ) / 100
199
+ 1000
200
+ ) / 1000
196
201
 
197
- // case 1: Arrival Notice -> Update Order Product
198
202
  if (arrivalNotice) {
199
203
  newInventory = {
200
204
  ...newInventory,
@@ -219,11 +223,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
219
223
  const updateOP = {
220
224
  id: targetProduct.id,
221
225
  actualPalletQty: ++targetProduct.actualPalletQty,
222
- actualPackQty: targetProduct.actualPackQty + qty,
226
+ actualPackQty: Number(targetProduct.actualPackQty || 0) + qty,
223
227
  status: ORDER_PRODUCT_STATUS.UNLOADED,
224
228
  productDetail: productDetail
225
229
  }
226
-
227
230
  // targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADED
228
231
  // targetProduct.productDetail = productDetail
229
232
  await this.updateOrderTargets([updateOP], OrderProduct)
@@ -388,8 +391,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
388
391
  (Boolean(arrivalNotice)
389
392
  ? targetProduct.uomValue
390
393
  : targetInventory.returnUomValue / targetInventory.returnQty) *
391
- 100
392
- ) / 100
394
+ 1000
395
+ ) / 1000
393
396
  newInventory.manufactureDate = manufactureDate
394
397
  newInventory.refOrderId = orderId
395
398
  newInventory.unitCost = unitCost
@@ -418,7 +421,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
418
421
  : qty
419
422
  }
420
423
  foundInventory = await this.trxMgr.getRepository(Inventory).save(newInventory)
421
-
424
+
422
425
  //refer to scanUnload
423
426
  newInventory = await this.transactionInventory(
424
427
  newInventory,
@@ -427,7 +430,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
427
430
  newInventory.uomValue,
428
431
  INVENTORY_TRANSACTION_TYPE.UNLOADING
429
432
  )
430
-
431
433
  } else {
432
434
  const updatedQty: number = foundInventory.qty + qty
433
435
  foundInventory.expirationDate = foundInventory.expirationDate ? new Date(foundInventory.expirationDate) : null
@@ -438,19 +440,18 @@ export class UnloadingWorksheetController extends VasWorksheetController {
438
440
  (Boolean(arrivalNotice)
439
441
  ? targetProduct.uomValue
440
442
  : targetInventory.returnUomValue / targetInventory.returnQty) *
441
- 100
442
- ) / 100
443
-
444
- //refer to scanUnload
445
- foundInventory = await this. transactionInventory(
446
- foundInventory,
447
- Boolean(arrivalNotice) ? arrivalNotice : returnOrder,
448
- foundInventory.qty,
449
- foundInventory.uomValue,
450
- INVENTORY_TRANSACTION_TYPE.UNLOADING
451
- )
443
+ 1000
444
+ ) / 1000
445
+
446
+ //refer to scanUnload
447
+ foundInventory = await this.transactionInventory(
448
+ foundInventory,
449
+ Boolean(arrivalNotice) ? arrivalNotice : returnOrder,
450
+ foundInventory.qty,
451
+ foundInventory.uomValue,
452
+ INVENTORY_TRANSACTION_TYPE.UNLOADING
453
+ )
452
454
 
453
-
454
455
  if (arrivalNotice) targetProduct.actualPackQty = targetProduct.actualPackQty + qty
455
456
  else if (returnOrder) targetInventory.actualPackQty = targetInventory.actualPackQty + qty
456
457
  foundInventory = await this.trxMgr.getRepository(Inventory).save(foundInventory)
@@ -618,8 +619,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
618
619
  (Boolean(arrivalNotice)
619
620
  ? targetProduct.uomValue
620
621
  : targetInventory.returnUomValue / targetInventory.returnQty) *
621
- 100
622
- ) / 100
622
+ 1000
623
+ ) / 1000
623
624
  newInventory.manufactureDate = manufactureDate
624
625
  newInventory.refOrderId = orderId
625
626
  newInventory.unitCost = unitCost
@@ -658,8 +659,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
658
659
  (Boolean(arrivalNotice)
659
660
  ? targetProduct.uomValue
660
661
  : targetInventory.returnUomValue / targetInventory.returnQty) *
661
- 100
662
- ) / 100
662
+ 1000
663
+ ) / 1000
663
664
  foundInventory.productDetail = productDetail
664
665
  if (arrivalNotice) targetProduct.actualPackQty = targetProduct.actualPackQty + qty
665
666
  else if (returnOrder) targetInventory.actualPackQty = targetInventory.actualPackQty + qty
@@ -802,7 +803,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
802
803
  targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADING
803
804
  } else {
804
805
  targetProduct.actualPackQty -= qty
805
- // targetProduct.actualPalletQty--
806
806
  }
807
807
  targetProduct.updater = this.user
808
808
  await this.updateOrderTargets([targetProduct])
@@ -828,7 +828,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
828
828
  targetInventory.status = ORDER_PRODUCT_STATUS.UNLOADING
829
829
  } else {
830
830
  targetInventory.actualPackQty--
831
- // targetInventory.actualPalletQty--
832
831
  }
833
832
  targetInventory.updater = this.user
834
833
  await this.updateOrderTargets([targetInventory])
@@ -846,8 +845,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
846
845
  (Boolean(orderType === ORDER_TYPES.ARRIVAL_NOTICE)
847
846
  ? targetProduct.uomValue
848
847
  : targetInventory.returnUomValue) *
849
- 100
850
- ) / 100
848
+ 1000
849
+ ) / 1000
851
850
  inventory.updater = this.user
852
851
  await this.trxMgr.getRepository(Inventory).save(inventory)
853
852
 
@@ -933,8 +932,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
933
932
  (Boolean(arrivalNotice)
934
933
  ? targetProduct.uomValue
935
934
  : targetInventory.returnUomValue / targetInventory.returnQty) *
936
- 100
937
- ) / 100
935
+ 1000
936
+ ) / 1000
938
937
  await this.trxMgr
939
938
  .getRepository(Inventory)
940
939
  .update({ id: inventory.id }, { qty: inventory.qty, uomValue: inventory.uomValue })
@@ -988,20 +987,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
988
987
  .getRepository(OrderProduct)
989
988
  .update({ id: In(targetProductsId) }, { status: ORDER_PRODUCT_STATUS.UNLOADING, updater: this.user })
990
989
 
991
- // const targetProducts: OrderProduct[] = worksheetDetails.map((wsd: WorksheetDetail) => {
992
- // let targetProduct: OrderProduct = wsd.targetProduct
993
-
994
- // if (!targetProduct.palletQty) {
995
- // const { palletQty }: { palletQty: number } = this.findMatchedWSD(wsd.name, unloadingWorksheetDetails)
996
- // targetProduct.palletQty = palletQty
997
- // }
998
- // targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADING
999
- // targetProduct.updater = this.user
1000
-
1001
- // return targetProduct
1002
- // })
1003
- // await this.updateOrderTargets(targetProducts)
1004
-
1005
990
  arrivalNotice.status = ORDER_STATUS.PROCESSING
1006
991
  arrivalNotice.updater = this.user
1007
992
  this.updateRefOrder(arrivalNotice)
@@ -800,7 +800,7 @@ export class CycleCountWorksheetController extends WorksheetController {
800
800
 
801
801
  await this.trxMgr.getRepository(InventoryCheckItem).update(checkItem.id, {
802
802
  inspectedQty: checkItem.inspectedQty,
803
- inspectedUomValue: checkItem.inspectedUomValue,
803
+ inspectedUomValue: checkItem.inspectedQty * productDetail.uomValue,
804
804
  inspectedBatchNo: checkItem.inspectedBatchNo,
805
805
  inspectedExpirationDate: checkItem.inspectedExpirationDate,
806
806
  inspectedLocation: checkItem.inspectedLocation,
@@ -1021,6 +1021,11 @@ export class CycleCountWorksheetController extends WorksheetController {
1021
1021
  where: { id: productId }
1022
1022
  })
1023
1023
 
1024
+ // Check if quantity has decimals and validate against product settings
1025
+ if (inspectedQty % 1 !== 0 && !product.isInventoryDecimal) {
1026
+ throw new Error('Decimal quantities are not allowed for this product')
1027
+ }
1028
+
1024
1029
  const total = await this.trxMgr.getRepository(Inventory).count({
1025
1030
  createdAt: MoreThan(new Date(year, month, date))
1026
1031
  })
@@ -368,15 +368,19 @@ export class PackingWorksheetController extends VasWorksheetController {
368
368
  const inventory: Inventory = orderInventory.inventory
369
369
  const releaseQty: number = orderInventory.releaseQty
370
370
 
371
- const matchingProduct = await this.getDirectQty(
372
- {
373
- ...productDetail,
374
- product: product
375
- },
376
- productBarcode,
377
- packedQty
378
- )
379
- packedQty = matchingProduct.qty
371
+ if (product.isInventoryDecimal) {
372
+ packedQty = orderInventory.releaseQty
373
+ } else {
374
+ const matchingProduct = await this.getDirectQty(
375
+ {
376
+ ...productDetail,
377
+ product: product
378
+ },
379
+ productBarcode,
380
+ packedQty
381
+ )
382
+ packedQty = matchingProduct.qty
383
+ }
380
384
 
381
385
  // Validation: PackQty cannot be more than ReleaseQty
382
386
  if (packedQty + orderInventory.packedQty > orderInventory.releaseQty) {
@@ -448,15 +452,23 @@ export class PackingWorksheetController extends VasWorksheetController {
448
452
  let updateOrderPackageItem = (
449
453
  await this.trxMgr.getRepository(OrderPackageItem).query(
450
454
  `
451
- update order_package_items tgt set
452
- packed_qty = coalesce(tgt.packed_qty,0) + 1,
453
- updated_at = $2,
454
- updater_id = $3,
455
- status = case when coalesce(tgt.packed_qty,0) + 1 = release_qty then 'DONE' else tgt.status end
456
- where id= $1
457
- returning *;
458
- `,
459
- [orderPackageItem.id, updateDateTime, this.user.id]
455
+ UPDATE order_package_items tgt
456
+ SET
457
+ packed_qty = CASE
458
+ WHEN $5 = true THEN $4
459
+ ELSE coalesce(tgt.packed_qty, 0) + 1
460
+ END,
461
+ updated_at = $2,
462
+ updater_id = $3,
463
+ status = CASE
464
+ WHEN $5 = true AND $4 = release_qty THEN 'DONE'
465
+ WHEN $5 = false AND coalesce(tgt.packed_qty, 0) + 1 = release_qty THEN 'DONE'
466
+ ELSE tgt.status
467
+ END
468
+ WHERE id = $1
469
+ RETURNING *;
470
+ `,
471
+ [orderPackageItem.id, updateDateTime, this.user.id, packedQty, product.isInventoryDecimal]
460
472
  )
461
473
  )[0][0]
462
474
 
@@ -1114,7 +1114,7 @@ export class PickingWorksheetController extends VasWorksheetController {
1114
1114
  .where('id = :id', { id: worksheetDetailInfos.worksheetDetailId })
1115
1115
  .execute()
1116
1116
 
1117
- let releaseUomValue = Math.round((pickedUomValue / pickedQty) * releaseQty * 100) / 100
1117
+ let releaseUomValue = Math.trunc((pickedUomValue / pickedQty) * releaseQty * 1000) / 1000
1118
1118
 
1119
1119
  let updateInvObj = {
1120
1120
  qty: () => `"qty" - ${releaseQty}`,
@@ -1586,9 +1586,12 @@ export class PickingWorksheetController extends VasWorksheetController {
1586
1586
 
1587
1587
  pickedQty = matchingProduct.qty
1588
1588
 
1589
- const sumOfReleaseQty: number = targetInventories
1590
- .map((oi: OrderInventory) => oi.releaseQty)
1591
- .reduce((a, b) => a + b, 0)
1589
+ const sumOfReleaseQty: number = parseFloat(
1590
+ targetInventories
1591
+ .map((oi: OrderInventory) => oi.releaseQty)
1592
+ .reduce((a, b) => a + b, 0)
1593
+ .toFixed(3)
1594
+ )
1592
1595
 
1593
1596
  const sumOfPickedQty: number =
1594
1597
  targetInventories.map((oi: OrderInventory) => oi.pickedQty).reduce((a, b) => a + b, 0) + pickedQty
@@ -1631,8 +1634,8 @@ export class PickingWorksheetController extends VasWorksheetController {
1631
1634
  targetReleaseQty > targetPickedQty &&
1632
1635
  pickedQty > 0
1633
1636
  ) {
1634
- let remainingAssignedQty: number = pickedQty - (targetReleaseQty - targetPickedQty) // -1, 0, 1
1635
- const gapQtyRemaining: number = targetReleaseQty - targetPickedQty // > 0
1637
+ let remainingAssignedQty: number = Math.round((pickedQty - (targetReleaseQty - targetPickedQty)) * 1000) / 1000 // -1, 0, 1
1638
+ const gapQtyRemaining: number = Math.round((targetReleaseQty - targetPickedQty) * 1000) / 1000 // > 0
1636
1639
 
1637
1640
  if (binLocationName && !targetInventory?.binLocation) {
1638
1641
  const binLocation: Location = await this.trxMgr.getRepository(Location).findOne({
@@ -1701,7 +1704,7 @@ export class PickingWorksheetController extends VasWorksheetController {
1701
1704
  } else {
1702
1705
  await this.updateOrderTargets([targetInventory])
1703
1706
  }
1704
- pickedQty = pickedQty - (targetReleaseQty - targetPickedQty)
1707
+ pickedQty = Math.round((pickedQty - (targetReleaseQty - targetPickedQty)) * 1000) / 1000
1705
1708
  }
1706
1709
  }
1707
1710
  } catch (error) {
@@ -235,7 +235,7 @@ export class ReturningWorksheetController extends VasWorksheetController {
235
235
  const releaseGood: ReleaseGood = await this.findRefOrder(ReleaseGood, {
236
236
  domain: this.domain,
237
237
  name: releaseGoodNo,
238
- status: In([ORDER_STATUS.PARTIAL_RETURN, ORDER_STATUS.PROCESSING, ORDER_STATUS.PARTIAL_PROCESSING])
238
+ status: In([ORDER_STATUS.PARTIAL_RETURN, ORDER_STATUS.LOADING, ORDER_STATUS.DONE, ORDER_STATUS.PROCESSING, ORDER_STATUS.PARTIAL_PROCESSING])
239
239
  })
240
240
 
241
241
  const worksheet: Worksheet = await this.findWorksheetByRefOrder(releaseGood, WORKSHEET_TYPE.WAREHOUSE_RETURN, [
@@ -244,7 +244,13 @@ export class SortingWorksheetController extends VasWorksheetController {
244
244
  // validate matching product details based on scanned barcode
245
245
  if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
246
246
 
247
- let sortedQty: number = matchingProduct.qty
247
+ let sortedQty: number = 1
248
+ if (targetOrderInventory.product.isInventoryDecimal) {
249
+ sortedQty = targetOrderInventory.pickedQty
250
+ } else {
251
+ sortedQty = matchingProduct.qty
252
+ }
253
+
248
254
  const releaseGood: ReleaseGood =
249
255
  orderInventories.length > 1
250
256
  ? orderInventories.find(item => item.productId === scanProductBarcode.productId)?.releaseGood
@@ -457,7 +457,7 @@ export class ReplenishmentWorksheetController extends WorksheetController {
457
457
  let targetInventory: OrderInventory = worksheetDetail.targetInventory
458
458
  let inventory: Inventory = targetInventory.inventory
459
459
 
460
- if (productBarcode) {
460
+ if (productBarcode && !inventory.product.isInventoryDecimal) {
461
461
  let matchingProduct = await this.getDirectQty(
462
462
  {
463
463
  ...inventory.productDetail,
@@ -1,20 +1,11 @@
1
- import {
2
- getRepository,
3
- SelectQueryBuilder
4
- } from 'typeorm'
1
+ import { getRepository, SelectQueryBuilder } from 'typeorm'
5
2
 
6
3
  import { ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
7
4
  import { Domain } from '@things-factory/shell'
8
5
  import { InventoryChange } from '@things-factory/warehouse-base'
9
6
 
10
- import {
11
- WORKSHEET_STATUS,
12
- WORKSHEET_TYPE
13
- } from '../../../constants'
14
- import {
15
- Worksheet,
16
- WorksheetDetail
17
- } from '../../../entities'
7
+ import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
8
+ import { Worksheet, WorksheetDetail } from '../../../entities'
18
9
 
19
10
  export const batchPickingWorksheetResolver = {
20
11
  async batchPickingWorksheet(_: any, { taskNo, locationSortingRules }, context: any) {
@@ -43,6 +34,7 @@ export const batchPickingWorksheetResolver = {
43
34
  .addSelect('"PROD".name', 'productName')
44
35
  .addSelect('"PROD".sku', 'productSku')
45
36
  .addSelect('"PROD".description', 'productDescription')
37
+ .addSelect('"PROD".is_inventory_decimal', 'isInventoryDecimal')
46
38
  .addSelect('"PROD_DET".id', 'productDetailId')
47
39
  .addSelect('"INV".qty', 'qty')
48
40
  .addSelect('"INV".packing_type', 'packingType')
@@ -116,7 +108,8 @@ export const batchPickingWorksheetResolver = {
116
108
  id: item?.productId,
117
109
  name: item?.productName,
118
110
  description: item?.productDescription,
119
- sku: item?.productSku
111
+ sku: item?.productSku,
112
+ isInventoryDecimal: item?.isInventoryDecimal
120
113
  },
121
114
  qty: item?.qty,
122
115
  releaseQty: item.releaseQty,
@@ -135,7 +128,8 @@ export const batchPickingWorksheetResolver = {
135
128
  id: item?.productId,
136
129
  name: item?.productName,
137
130
  description: item?.productDescription,
138
- sku: item?.productSku
131
+ sku: item?.productSku,
132
+ isInventoryDecimal: item?.isInventoryDecimal
139
133
  },
140
134
  productDetail: {
141
135
  id: item?.productDetailId
@@ -72,8 +72,8 @@ export const confirmCancellationReleaseOrder = {
72
72
  .createQueryBuilder()
73
73
  .update(Inventory)
74
74
  .set({
75
- qty: () => `COALESCE("qty", 0) + ${orderInventory.releaseQty}`,
76
- uomValue: () => `COALESCE("uom_value", 0) + ${orderInventory.releaseUomValue}`,
75
+ qty: () => `COALESCE("qty", 0) + ${orderInventory.releaseQty}::numeric`,
76
+ uomValue: () => `COALESCE("uom_value", 0) + ${orderInventory.releaseUomValue}::numeric`,
77
77
  status: INVENTORY_STATUS.STORED,
78
78
  updater: user
79
79
  })
@@ -111,25 +111,12 @@ export const confirmCancellationReleaseOrder = {
111
111
  .createQueryBuilder()
112
112
  .update(Inventory)
113
113
  .set({
114
- lockedQty: () => `COALESCE("locked_qty", 0) - ${orderInventory.releaseQty}`,
115
- lockedUomValue: () => `COALESCE("locked_uom_value", 0) - ${orderInventory.releaseUomValue}`,
114
+ lockedQty: () => `COALESCE("locked_qty", 0) - ${orderInventory.releaseQty}::numeric`,
115
+ lockedUomValue: () => `COALESCE("locked_uom_value", 0) - ${orderInventory.releaseUomValue}::numeric`,
116
116
  updater: user
117
117
  })
118
118
  .where('id = :id', { id: inventory.id })
119
119
  .execute()
120
-
121
- // @ChrisLim-git commented for further review as it causes qty to add into inventory
122
- // await tx
123
- // .createQueryBuilder()
124
- // .update(Inventory)
125
- // .set({
126
- // qty: () => `COALESCE("qty", 0) + ${orderInventory.releaseQty}`,
127
- // uomValue: () => `COALESCE("uom_value", 0) + ${orderInventory.releaseUomValue}`,
128
- // status: INVENTORY_STATUS.STORED,
129
- // updater: user
130
- // })
131
- // .where('id = :id', { id: inventory.id })
132
- // .execute()
133
120
  }
134
121
 
135
122
  return orderInventory
@@ -271,8 +258,8 @@ export const confirmCancellationReleaseOrder = {
271
258
  .createQueryBuilder()
272
259
  .update(ProductDetailStock)
273
260
  .set({
274
- unassignedQty: () => `"unassigned_qty" - ${op.releaseQty}`,
275
- unassignedUomValue: () => `"unassigned_uom_value" - ${op.releaseUomValue}`
261
+ unassignedQty: () => `"unassigned_qty" - ${op.releaseQty}::numeric`,
262
+ unassignedUomValue: () => `"unassigned_uom_value" - ${op.releaseUomValue}::numeric`
276
263
  })
277
264
  .where({ productDetail: op.productDetail.id })
278
265
  .execute()
@@ -180,7 +180,8 @@ export const inventoriesByPalletResolver = {
180
180
  productSKU: item.product.sku,
181
181
  productBrand: item.product.brand,
182
182
  productId: item.product.id,
183
- productDetailId: item.productDetail.id
183
+ productDetailId: item.productDetail.id,
184
+ isInventoryDecimal: item.product.isInventoryDecimal,
184
185
  }
185
186
  })
186
187
  )