@things-factory/sales-base 4.3.639 → 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 (64) hide show
  1. package/dist-server/service/arrival-notice/arrival-notice-mutation.js +33 -2
  2. package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
  3. package/dist-server/service/arrival-notice/arrival-notice-query.js +10 -3
  4. package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
  5. package/dist-server/service/arrival-notice/arrival-notice-types.js +2 -2
  6. package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
  7. package/dist-server/service/draft-release-good/draft-release-good-query.js +32 -26
  8. package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
  9. package/dist-server/service/inventory-check-item/inventory-check-item-types.js +48 -12
  10. package/dist-server/service/inventory-check-item/inventory-check-item-types.js.map +1 -1
  11. package/dist-server/service/inventory-check-item/inventory-check-item.js +56 -4
  12. package/dist-server/service/inventory-check-item/inventory-check-item.js.map +1 -1
  13. package/dist-server/service/order-inventory/order-inventory-query.js +5 -1
  14. package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
  15. package/dist-server/service/order-inventory/order-inventory-types.js +12 -12
  16. package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
  17. package/dist-server/service/order-inventory/order-inventory.js +189 -13
  18. package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
  19. package/dist-server/service/order-package-item/order-package-item-types.js +14 -2
  20. package/dist-server/service/order-package-item/order-package-item-types.js.map +1 -1
  21. package/dist-server/service/order-package-item/order-package-item.js +28 -2
  22. package/dist-server/service/order-package-item/order-package-item.js.map +1 -1
  23. package/dist-server/service/order-product/order-product-types.js +18 -18
  24. package/dist-server/service/order-product/order-product-types.js.map +1 -1
  25. package/dist-server/service/order-product/order-product.js +104 -13
  26. package/dist-server/service/order-product/order-product.js.map +1 -1
  27. package/dist-server/service/order-tote-item/order-tote-item-types.js +2 -2
  28. package/dist-server/service/order-tote-item/order-tote-item-types.js.map +1 -1
  29. package/dist-server/service/order-tote-item/order-tote-item.js +15 -1
  30. package/dist-server/service/order-tote-item/order-tote-item.js.map +1 -1
  31. package/dist-server/service/others/other-query.js +4 -4
  32. package/dist-server/service/others/other-query.js.map +1 -1
  33. package/dist-server/service/others/other-types.js +8 -4
  34. package/dist-server/service/others/other-types.js.map +1 -1
  35. package/dist-server/service/release-good/release-good-mutation.js +35 -6
  36. package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
  37. package/dist-server/service/release-good/release-good-query.js +23 -11
  38. package/dist-server/service/release-good/release-good-query.js.map +1 -1
  39. package/dist-server/service/release-good/release-good-types.js +1 -1
  40. package/dist-server/service/release-good/release-good-types.js.map +1 -1
  41. package/dist-server/utils/inventory-util.js +18 -14
  42. package/dist-server/utils/inventory-util.js.map +1 -1
  43. package/package.json +8 -8
  44. package/server/service/arrival-notice/arrival-notice-mutation.ts +39 -2
  45. package/server/service/arrival-notice/arrival-notice-query.ts +40 -68
  46. package/server/service/arrival-notice/arrival-notice-types.ts +4 -4
  47. package/server/service/draft-release-good/draft-release-good-query.ts +49 -42
  48. package/server/service/inventory-check-item/inventory-check-item-types.ts +37 -10
  49. package/server/service/inventory-check-item/inventory-check-item.ts +52 -4
  50. package/server/service/order-inventory/order-inventory-query.ts +5 -0
  51. package/server/service/order-inventory/order-inventory-types.ts +12 -12
  52. package/server/service/order-inventory/order-inventory.ts +171 -13
  53. package/server/service/order-package-item/order-package-item-types.ts +12 -3
  54. package/server/service/order-package-item/order-package-item.ts +26 -2
  55. package/server/service/order-product/order-product-types.ts +18 -18
  56. package/server/service/order-product/order-product.ts +96 -12
  57. package/server/service/order-tote-item/order-tote-item-types.ts +3 -3
  58. package/server/service/order-tote-item/order-tote-item.ts +14 -1
  59. package/server/service/others/other-query.ts +8 -8
  60. package/server/service/others/other-types.ts +7 -4
  61. package/server/service/release-good/release-good-mutation.ts +51 -9
  62. package/server/service/release-good/release-good-query.ts +30 -14
  63. package/server/service/release-good/release-good-types.ts +1 -1
  64. package/server/utils/inventory-util.ts +50 -60
@@ -1,29 +1,10 @@
1
- import {
2
- EntityManager,
3
- Equal,
4
- getRepository,
5
- In,
6
- Not,
7
- Raw,
8
- Repository,
9
- SelectQueryBuilder
10
- } from 'typeorm'
1
+ import { EntityManager, Equal, getRepository, In, Not, Raw, Repository, SelectQueryBuilder } from 'typeorm'
11
2
 
12
3
  import { User } from '@things-factory/auth-base'
13
4
  import { Bizplace } from '@things-factory/biz-base'
14
- import {
15
- Product,
16
- ProductBundle,
17
- ProductDetail
18
- } from '@things-factory/product-base'
19
- import {
20
- PartnerSetting,
21
- Setting
22
- } from '@things-factory/setting-base'
23
- import {
24
- Domain,
25
- ListParam
26
- } from '@things-factory/shell'
5
+ import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
6
+ import { PartnerSetting, Setting } from '@things-factory/setting-base'
7
+ import { Domain, ListParam } from '@things-factory/shell'
27
8
  import {
28
9
  generateInventoryHistory,
29
10
  Inventory,
@@ -303,6 +284,7 @@ export const InventoryUtil = {
303
284
  COALESCE(p.sku, '') AS "productSKU",
304
285
  COALESCE(p.brand, '') AS "productBrand",
305
286
  p.id AS "productId",
287
+ p.is_inventory_decimal AS "isInventoryDecimal",
306
288
  i.product_detail_id AS "productDetailId",
307
289
  SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)) - SUM(COALESCE(pds.unassigned_qty, 0)) AS "remainQty",
308
290
  SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - SUM(COALESCE(pds.unassigned_uom_value, 0)) AS "remainUomValue",
@@ -330,8 +312,9 @@ export const InventoryUtil = {
330
312
  AND i.transfer_uom_value <= 0
331
313
  AND i.lock_inventory is not true
332
314
  AND CASE WHEN i.expiration_date IS NOT NULL AND p.min_outbound_shelf_life IS NOT NULL THEN CURRENT_DATE < i.expiration_date - p.min_outbound_shelf_life ELSE true END
333
- ${cycleCountFilter ?
334
- `AND i.id NOT IN (
315
+ ${
316
+ cycleCountFilter
317
+ ? `AND i.id NOT IN (
335
318
  SELECT DISTINCT(ici.inventory_id) FROM worksheets w
336
319
  INNER JOIN worksheet_details wd ON wd.worksheet_id = w.id
337
320
  INNER JOIN inventory_check_items ici ON wd.target_inventory_check_item_id = ici.id
@@ -339,8 +322,9 @@ export const InventoryUtil = {
339
322
  AND w.status != 'DONE'
340
323
  AND w.bizplace_id IN (${bizplaceIds})
341
324
  AND w.domain_id = '${domain.id}'
342
- )` :
343
- `AND true`}
325
+ )`
326
+ : `AND true`
327
+ }
344
328
  ${productWhereClause}
345
329
  GROUP BY
346
330
  i.product_detail_id,
@@ -361,6 +345,7 @@ export const InventoryUtil = {
361
345
  pb.sku AS "productSKU",
362
346
  'brand' AS "productBrand",
363
347
  id AS "productId",
348
+ false AS "isInventoryDecimal",
364
349
  pbs.product_detail_id AS "productDetailId",
365
350
  MIN(FLOOR(pbs."availableQty")) AS "remainQty",
366
351
  MIN(FLOOR(pbs."availableUomValue")) AS "remainUomValue",
@@ -430,7 +415,7 @@ export const InventoryUtil = {
430
415
  } OFFSET $1 LIMIT $2`,
431
416
  [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
432
417
  )
433
- }
418
+ }
434
419
 
435
420
  await trxMgr.query(`drop table temp_inventory_product_group`)
436
421
 
@@ -440,7 +425,12 @@ export const InventoryUtil = {
440
425
  }
441
426
  },
442
427
 
443
- async bizplaceInventoryProductGroupImport(bizplaces: Bizplace[], params: ListParam, context: any, trxMgr: EntityManager) {
428
+ async bizplaceInventoryProductGroupImport(
429
+ bizplaces: Bizplace[],
430
+ params: ListParam,
431
+ context: any,
432
+ trxMgr: EntityManager
433
+ ) {
444
434
  try {
445
435
  let filters = params.filters
446
436
  const { domain }: { domain: Domain } = context.state
@@ -463,12 +453,13 @@ export const InventoryUtil = {
463
453
  COALESCE(p.sku, '') AS "productSKU",
464
454
  COALESCE(p.brand, '') AS "productBrand",
465
455
  p.id AS "productId",
456
+ p.is_inventory_decimal AS "isInventoryDecimal",
466
457
  i.product_detail_id AS "productDetailId",
467
458
  p.picking_strategy AS "pickingStrategy",
468
459
  i.created_at AS "createdAt",
469
460
  i.expiration_date AS "expirationDate",
470
461
  i.manufacture_date AS "manufactureDate",
471
- l2.name AS "locationName",
462
+ l2.name AS "name",
472
463
  l2.zone AS "zone",
473
464
  l2.row AS "row",
474
465
  l2.column AS "column",
@@ -526,12 +517,13 @@ export const InventoryUtil = {
526
517
  pb.sku AS "productSKU",
527
518
  'brand' AS "productBrand",
528
519
  id AS "productId",
520
+ false AS "isInventoryDecimal",
529
521
  pbs.product_detail_id AS "productDetailId",
530
522
  NULL AS "pickingStrategy",
531
523
  NULL AS "createdAt",
532
524
  NULL AS "expirationDate",
533
525
  NULL AS "manufactureDate",
534
- NULL AS "locationName",
526
+ NULL AS "name",
535
527
  NULL AS "zone",
536
528
  NULL AS "row",
537
529
  NULL AS "column",
@@ -570,36 +562,37 @@ export const InventoryUtil = {
570
562
  })
571
563
 
572
564
  const getLocationSortingClause = (inventoryAssignmentSetting: any) => {
573
- let locationSortingRules: Array<{ name: string; desc: boolean }> = []
565
+ let locationSortingRules: Array<{ name: string; desc: boolean }> = []
574
566
 
575
- if (inventoryAssignmentSetting) {
576
- try {
577
- let locationSetting = JSON.parse(inventoryAssignmentSetting.value)
578
- for (const key in locationSetting) {
579
- locationSortingRules.push({ name: key, desc: locationSetting[key] !== 'ASC' })
567
+ if (inventoryAssignmentSetting) {
568
+ try {
569
+ let locationSetting = JSON.parse(inventoryAssignmentSetting.value)
570
+ for (const key in locationSetting) {
571
+ locationSortingRules.push({ name: key, desc: locationSetting[key] !== 'ASC' })
572
+ }
573
+ } catch (error) {
574
+ console.error('Invalid JSON in inventoryAssignmentSetting:', error)
580
575
  }
581
- } catch (error) {
582
- console.error("Invalid JSON in inventoryAssignmentSetting:", error)
583
576
  }
584
- }
585
577
 
586
- if (locationSortingRules.length) {
587
- return locationSortingRules
588
- .map(rule => `
578
+ if (locationSortingRules.length) {
579
+ return locationSortingRules
580
+ .map(
581
+ rule => `
589
582
  CASE
590
583
  WHEN "pickingStrategy" = 'LOCATION' THEN "${rule.name}"
591
584
  END ${rule.desc ? 'DESC' : 'ASC'}
592
- `)
593
- .join(',\n')
594
- }
595
-
596
- return `
597
- CASE
598
- WHEN "pickingStrategy" = 'LOCATION' THEN "locationName"
599
- END ASC
600
- `
601
- }
585
+ `
586
+ )
587
+ .join(',\n')
588
+ }
602
589
 
590
+ return `
591
+ CASE
592
+ WHEN "pickingStrategy" = 'LOCATION' THEN "name"
593
+ END ASC
594
+ `
595
+ }
603
596
 
604
597
  await trxMgr.query(queryStrings, [domain.id])
605
598
 
@@ -608,7 +601,6 @@ export const InventoryUtil = {
608
601
  let items: any[] = []
609
602
 
610
603
  if (!params?.pagination) {
611
-
612
604
  const orderByClause = `
613
605
  ORDER BY
614
606
  ${getLocationSortingClause(inventoryAssignmentSetting)},
@@ -629,9 +621,7 @@ export const InventoryUtil = {
629
621
  ELSE NULL
630
622
  END ASC
631
623
  `
632
- items = await trxMgr.query(
633
- `select * from temp_inventory_product_group ${orderByClause}`
634
- )
624
+ items = await trxMgr.query(`select * from temp_inventory_product_group ${orderByClause}`)
635
625
  }
636
626
 
637
627
  await trxMgr.query(`drop table temp_inventory_product_group`)
@@ -807,7 +797,7 @@ export const InventoryUtil = {
807
797
  )
808
798
 
809
799
  resultQb.forEach(itm => {
810
- if (itm.releaseQty > itm.availableQty) {
800
+ if (parseFloat(itm.releaseQty) > parseFloat(itm.availableQty)) {
811
801
  throw new ValidationError({
812
802
  ...ValidationError.ERROR_CODES.RELEASE_QTY_OVER_LIMIT,
813
803
  detail: { data: JSON.stringify(resultQb) }
@@ -1336,7 +1326,7 @@ export function _composeTargetInventories(
1336
1326
  let orderInventory: OrderInventory = new OrderInventory()
1337
1327
 
1338
1328
  if (inventory.remainQty > leftReleaseQty) {
1339
- const uomValuePerQty: number = Math.round((inventory.remainUomValue / inventory.remainQty) * 100) / 100
1329
+ const uomValuePerQty: number = Math.round((inventory.remainUomValue / inventory.remainQty) * 1000) / 1000
1340
1330
 
1341
1331
  compReleaseQty += leftReleaseQty
1342
1332
  compReleaseUomValue += leftReleaseUomValue
@@ -1344,7 +1334,7 @@ export function _composeTargetInventories(
1344
1334
  orderInventory = {
1345
1335
  ...orderInventory,
1346
1336
  releaseQty: leftReleaseQty,
1347
- releaseUomValue: Math.round(leftReleaseQty * uomValuePerQty * 100) / 100
1337
+ releaseUomValue: Math.round(leftReleaseQty * uomValuePerQty * 1000) / 1000
1348
1338
  }
1349
1339
  } else {
1350
1340
  compReleaseQty += inventory.remainQty