@things-factory/worksheet-base 3.6.46 → 3.6.50

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 (32) hide show
  1. package/dist-server/controllers/render-grn.js +8 -0
  2. package/dist-server/controllers/render-grn.js.map +1 -1
  3. package/dist-server/controllers/render-ro-do.js +18 -5
  4. package/dist-server/controllers/render-ro-do.js.map +1 -1
  5. package/dist-server/controllers/vas/vas-worksheet-controller.js +75 -14
  6. package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
  7. package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +8 -7
  8. package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
  9. package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js +302 -11
  10. package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js.map +1 -1
  11. package/dist-server/graphql/resolvers/worksheet/vas-transactions/interfaces/index.js.map +1 -1
  12. package/dist-server/graphql/resolvers/worksheet/vas-transactions/interfaces/repackaging.js.map +1 -1
  13. package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/complete-repackaging.js +137 -31
  14. package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/complete-repackaging.js.map +1 -1
  15. package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/repackaging.js +157 -42
  16. package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/repackaging.js.map +1 -1
  17. package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/undo-repackaging.js +35 -21
  18. package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/undo-repackaging.js.map +1 -1
  19. package/dist-server/utils/inventory-util.js +3 -2
  20. package/dist-server/utils/inventory-util.js.map +1 -1
  21. package/package.json +14 -14
  22. package/server/controllers/render-grn.ts +8 -0
  23. package/server/controllers/render-ro-do.ts +21 -6
  24. package/server/controllers/vas/vas-worksheet-controller.ts +104 -23
  25. package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +8 -13
  26. package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +452 -14
  27. package/server/graphql/resolvers/worksheet/vas-transactions/interfaces/index.ts +36 -1
  28. package/server/graphql/resolvers/worksheet/vas-transactions/interfaces/repackaging.ts +8 -2
  29. package/server/graphql/resolvers/worksheet/vas-transactions/repackaging/complete-repackaging.ts +185 -56
  30. package/server/graphql/resolvers/worksheet/vas-transactions/repackaging/repackaging.ts +210 -54
  31. package/server/graphql/resolvers/worksheet/vas-transactions/repackaging/undo-repackaging.ts +64 -32
  32. package/server/utils/inventory-util.ts +10 -5
@@ -1,20 +1,40 @@
1
+ import { EntityManager } from 'typeorm'
2
+
1
3
  import { User } from '@things-factory/auth-base'
2
4
  import { Bizplace } from '@things-factory/biz-base'
3
- import { Inventory } from '@things-factory/warehouse-base'
4
- import { OrderVas, VasOrder } from '@things-factory/sales-base'
5
+ import {
6
+ OrderVas,
7
+ VasOrder
8
+ } from '@things-factory/sales-base'
5
9
  import { Domain } from '@things-factory/shell'
6
- import { EntityManager } from 'typeorm'
7
- import { Worksheet, WorksheetDetail } from '../../../../../entities'
8
- import { dismissInventory, getWorksheetDetailByName, updateRelatedOrderVas } from '../common-utils'
10
+ import { Inventory } from '@things-factory/warehouse-base'
11
+
12
+ import {
13
+ Worksheet,
14
+ WorksheetDetail
15
+ } from '../../../../../entities'
9
16
  import {
17
+ getWorksheetDetailByName,
18
+ updateRelatedOrderVas
19
+ } from '../common-utils'
20
+ import {
21
+ FeaturedInventoryInterface,
10
22
  OperationGuideInterface,
11
23
  PackingUnits,
12
- PalletChangesInterface,
13
24
  RefOrderType,
14
25
  RepackagingGuide,
15
- RepackedInvInfo
26
+ RepackedInvInfo,
27
+ TemporaryPalletChangesInterface
16
28
  } from '../interfaces'
17
29
 
30
+ /** STEPS TO UNDO REPACKAGING
31
+ * 1. get the pallet id to undo (pallet id must be the LV one and not the parent)
32
+ * 2. revert the qty of repackedFrom into the original inventory and featuredInv (if applicable)
33
+ * 3. remove the repackedInv for undo item
34
+ * 4. update the requiredPkgQty
35
+ *
36
+ */
37
+
18
38
  export const undoRepackagingResolver = {
19
39
  async undoRepackaging(_: any, { worksheetDetailName, fromPalletId, toPalletId }, context: any) {
20
40
  /**
@@ -30,37 +50,49 @@ export const undoRepackagingResolver = {
30
50
  let operationGuide: OperationGuideInterface<RepackagingGuide> = JSON.parse(targetVas.operationGuide)
31
51
  let operationGuideData: RepackagingGuide = operationGuide.data
32
52
  let repackedInvs: RepackedInvInfo[] = operationGuideData.repackedInvs
53
+ let featuredInvs: FeaturedInventoryInterface[] = operationGuideData.featuredInvs
33
54
  let undoInventory: RepackedInvInfo = repackedInvs.find((ri: RepackedInvInfo) => ri.palletId === toPalletId)
34
55
  if (!undoInventory) throw new Error(`Couldn't find pallet, using pallet id (${toPalletId})`)
35
56
 
36
57
  const packingUnit: string = operationGuideData.packingUnit
37
58
  const stdAmount: number = operationGuideData.stdAmount
38
59
 
39
- undoInventory.repackedFrom = undoInventory.repackedFrom.filter(
40
- (rf: PalletChangesInterface) => rf.fromPalletId !== fromPalletId
41
- )
60
+ // undoInventory.repackedFrom = undoInventory.repackedFrom.filter(
61
+ // (rf: TemporaryPalletChangesInterface) => rf.fromPalletId !== fromPalletId
62
+ // )
42
63
 
43
64
  // 완전히 Repacked 상태인 pallet count
44
- const repackedPkgQty: number =
45
- undoInventory.repackedFrom.reduce((totalAmount: number, rf: PalletChangesInterface) => {
46
- const amount: number = packingUnit === PackingUnits.QTY ? rf.reducedQty : rf.reducedUomValue
47
- totalAmount += amount
48
- return totalAmount
49
- }, 0) / stdAmount
65
+ // const repackedPkgQty: number =
66
+ // undoInventory.repackedFrom.reduce((totalAmount: number, rf: TemporaryPalletChangesInterface) => {
67
+ // const amount: number = packingUnit === PackingUnits.QTY ? rf.reducedUnitQty : rf.reducedUomValue
68
+ // totalAmount += amount
69
+ // return totalAmount
70
+ // }, 0) / stdAmount
50
71
 
51
72
  // Undo를 발생한 수량 차이를 계산
52
- undoInventory.repackedPkgQty = repackedPkgQty
53
-
54
- // Pallet 전체가 취소된 경우
55
- let updatedRepackedInvs: RepackedInvInfo[]
56
- if (!undoInventory.repackedFrom?.length) {
57
- updatedRepackedInvs = repackedInvs.filter((ri: RepackedInvInfo) => ri.palletId !== toPalletId)
58
- } else {
59
- updatedRepackedInvs = repackedInvs.map((ri: RepackedInvInfo) => {
60
- if (ri.palletId === toPalletId) ri = undoInventory
61
- return ri
62
- })
63
- }
73
+ // undoInventory.repackedPkgQty = repackedPkgQty
74
+
75
+ const updatedRepackedInvs: RepackedInvInfo[] = repackedInvs.filter(
76
+ (ri: RepackedInvInfo) => ri.palletId !== toPalletId
77
+ )
78
+
79
+ const updatedFeaturedInvs: FeaturedInventoryInterface[] = featuredInvs.reduce(
80
+ (inventories: FeaturedInventoryInterface[], currInv: FeaturedInventoryInterface) => {
81
+ undoInventory.repackedFrom.forEach(undoInv => {
82
+ if (undoInv.fromPalletId == currInv.palletId) {
83
+ if (packingUnit == PackingUnits.QTY) {
84
+ currInv.currentUnitQty += undoInv.reducedUnitQty
85
+ } else if (packingUnit == PackingUnits.UOM) {
86
+ currInv.currentUomValue += undoInv.reducedUomValue
87
+ }
88
+ }
89
+ })
90
+
91
+ inventories.push(currInv)
92
+ return inventories
93
+ },
94
+ []
95
+ )
64
96
 
65
97
  const requiredPackageQty: number = await getRequiredPackageQty(
66
98
  tx,
@@ -74,17 +106,17 @@ export const undoRepackagingResolver = {
74
106
  const repackedPackageQty: number = getRepackedPackageQty(updatedRepackedInvs)
75
107
 
76
108
  operationGuide.data.requiredPackageQty = requiredPackageQty - repackedPackageQty
109
+ operationGuide.data.featuredInvs = updatedFeaturedInvs
77
110
  operationGuide.data.repackedInvs = updatedRepackedInvs
78
111
 
79
112
  if (!(refOrder instanceof VasOrder)) {
80
- // const palletChanges: PalletChangesInterface[] = operationGuide.data.repackedInvs
113
+ // const palletChanges: TemporaryPalletChangesInterface[] = operationGuide.data.repackedInvs
81
114
  // .map((ri: RepackedInvInfo) => ri.repackedFrom)
82
115
  // .flat()
83
116
 
84
- const palletChanges: PalletChangesInterface[] = []
85
- await dismissInventory(tx, wsd, targetVas, palletChanges, fromPalletId)
117
+ const palletChanges: TemporaryPalletChangesInterface[] = []
118
+ // await dismissInventory(tx, wsd, targetVas, palletChanges, fromPalletId)
86
119
  }
87
-
88
120
  // Update every order vas to share same operation guide
89
121
  await updateRelatedOrderVas(tx, domain, bizplace, wsd, targetVas, operationGuide, user)
90
122
  }
@@ -1,18 +1,21 @@
1
+ import {
2
+ EntityManager,
3
+ getRepository,
4
+ Repository
5
+ } from 'typeorm'
6
+
1
7
  import { User } from '@things-factory/auth-base'
2
8
  import { Bizplace } from '@things-factory/biz-base'
3
9
  import { Product } from '@things-factory/product-base'
4
10
  import { Domain } from '@things-factory/shell'
5
11
  import {
6
12
  Inventory,
13
+ INVENTORY_STATUS,
7
14
  InventoryHistory,
8
15
  InventoryNoGenerator,
9
- INVENTORY_STATUS,
10
16
  Location,
11
17
  LOCATION_STATUS
12
18
  } from '@things-factory/warehouse-base'
13
- import { Setting } from '@things-factory/setting-base'
14
- import { EntityManager, getRepository, Repository } from 'typeorm'
15
- import { ORDER_NUMBER_SETTING_KEY } from '@things-factory/sales-base'
16
19
 
17
20
  /**
18
21
  * @description It will insert new record into inventory histories table.
@@ -25,7 +28,8 @@ export async function generateInventoryHistory(
25
28
  qty: number,
26
29
  uomValue: number,
27
30
  user: User,
28
- trxMgr?: EntityManager
31
+ trxMgr?: EntityManager,
32
+ targetInventory: Inventory = {}
29
33
  ): Promise<InventoryHistory> {
30
34
  const invHistoryRepo: Repository<InventoryHistory> =
31
35
  trxMgr?.getRepository(InventoryHistory) || getRepository(InventoryHistory)
@@ -77,6 +81,7 @@ export async function generateInventoryHistory(
77
81
  inventoryHistory.orderNo = refOrder?.name || null
78
82
  inventoryHistory.orderRefNo = refOrder?.refNo || null
79
83
  inventoryHistory.inventory = inventory
84
+ inventoryHistory.targetInventory = targetInventory
80
85
  inventoryHistory.product = inventory.product
81
86
  inventoryHistory.reusablePallet = inventory.reusablePallet
82
87
  inventoryHistory.zone = inventory.zone