@things-factory/worksheet-base 3.7.1 → 3.7.6
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.
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +3 -3
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +48 -25
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +4 -0
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +121 -67
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +27 -2
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js +27 -2
- package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +26 -0
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +27 -5
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js +72 -0
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/picking/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/picking/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/picking.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +86 -57
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return-worksheet.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/unloading-return-worksheet.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +5 -1
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +29 -2
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +16 -16
- package/server/controllers/ecommerce/sellercraft-controller.ts +3 -3
- package/server/controllers/inbound/unloading-worksheet-controller.ts +67 -30
- package/server/controllers/outbound/loading-worksheet-controller.ts +20 -0
- package/server/controllers/outbound/picking-worksheet-controller.ts +148 -83
- package/server/controllers/worksheet-controller.ts +40 -2
- package/server/graphql/resolvers/worksheet/loading-worksheet.ts +33 -4
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +31 -3
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +37 -5
- package/server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.ts +78 -0
- package/server/graphql/resolvers/worksheet/picking/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/picking/picking.ts +5 -4
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +102 -62
- package/server/graphql/resolvers/worksheet/unloading-return-worksheet.ts +6 -4
- package/server/graphql/types/worksheet/index.ts +5 -1
- package/server/utils/inventory-util.ts +31 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityManager, In, SelectQueryBuilder } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import { ORDER_INVENTORY_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
4
4
|
import { Domain } from '@things-factory/shell'
|
|
5
|
-
import { Inventory } from '@things-factory/warehouse-base'
|
|
5
|
+
import { Inventory, Location } from '@things-factory/warehouse-base'
|
|
6
6
|
|
|
7
7
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
8
8
|
import { WorksheetDetail } from '../../../entities'
|
|
@@ -10,71 +10,111 @@ import { fetchExecutingWorksheet } from '../../../utils'
|
|
|
10
10
|
|
|
11
11
|
export const pickingWorksheetResolver = {
|
|
12
12
|
async pickingWorksheet(_: any, { releaseGoodNo, locationSortingRules }, context: any) {
|
|
13
|
-
const { domain }: { domain: Domain } = context.state
|
|
14
|
-
const releaseGood: ReleaseGood = await getRepository(ReleaseGood).findOne({
|
|
15
|
-
where: { domain, name: releaseGoodNo /*status: ORDER_STATUS.PICKING*/ },
|
|
16
|
-
relations: ['bizplace', 'bizplace.domain']
|
|
17
|
-
})
|
|
18
|
-
if (!releaseGood) throw new Error(`Couldn't find picking worksheet by order no (${releaseGoodNo})`)
|
|
19
|
-
|
|
20
|
-
const worksheet = await fetchExecutingWorksheet(
|
|
21
|
-
domain,
|
|
22
|
-
releaseGood.bizplace,
|
|
23
|
-
['bizplace'],
|
|
24
|
-
WORKSHEET_TYPE.PICKING,
|
|
25
|
-
releaseGood
|
|
26
|
-
)
|
|
13
|
+
const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
32
|
-
.leftJoinAndSelect('INV.location', 'LOC')
|
|
15
|
+
return await pickingWorksheet(domain, releaseGoodNo, locationSortingRules, tx)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
33
18
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
export async function pickingWorksheet(
|
|
20
|
+
domain: Domain,
|
|
21
|
+
releaseGoodNo: String,
|
|
22
|
+
locationSortingRules: any,
|
|
23
|
+
tx: EntityManager
|
|
24
|
+
) {
|
|
25
|
+
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
26
|
+
where: { domain, name: releaseGoodNo /*status: ORDER_STATUS.PICKING*/ },
|
|
27
|
+
relations: ['bizplace', 'bizplace.domain']
|
|
28
|
+
})
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
// Find Release Order based on Bin
|
|
31
|
+
if (!releaseGood) {
|
|
32
|
+
const binLocation: Location = await tx.getRepository(Location).findOne({
|
|
33
|
+
where: { domain, name: releaseGoodNo }
|
|
34
|
+
})
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
const orderInventoryByBin: OrderInventory = await tx.getRepository(OrderInventory).findOne({
|
|
37
|
+
where: {
|
|
38
|
+
domain,
|
|
39
|
+
binLocation,
|
|
40
|
+
status: In([ORDER_INVENTORY_STATUS.PICKING, ORDER_INVENTORY_STATUS.PICKED])
|
|
41
|
+
},
|
|
42
|
+
order: {
|
|
43
|
+
createdAt: 'ASC'
|
|
54
44
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
cartonId: inventory?.cartonId,
|
|
62
|
-
batchId: inventory?.batchId,
|
|
63
|
-
batchIdRef: inventory?.batchIdRef,
|
|
64
|
-
product: inventory?.product,
|
|
65
|
-
qty: inventory?.qty,
|
|
66
|
-
releaseQty: targetInventory.releaseQty,
|
|
67
|
-
pickedQty: targetInventory.pickedQty,
|
|
68
|
-
status: pickingWSD.status,
|
|
69
|
-
description: pickingWSD.description,
|
|
70
|
-
targetName: targetInventory.name,
|
|
71
|
-
packingType: inventory?.packingType,
|
|
72
|
-
packingSize: inventory?.packingSize,
|
|
73
|
-
expirationDate: inventory?.expirationDate,
|
|
74
|
-
location: inventory?.location,
|
|
75
|
-
relatedOrderInv: targetInventory
|
|
76
|
-
}
|
|
77
|
-
})
|
|
45
|
+
relations: ['releaseGood', 'releaseGood.bizplace', 'releaseGood.bizplace.domain']
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
if (orderInventoryByBin?.releaseGood) {
|
|
49
|
+
releaseGoodNo = orderInventoryByBin.releaseGood.name
|
|
50
|
+
releaseGood = orderInventoryByBin.releaseGood
|
|
78
51
|
}
|
|
79
52
|
}
|
|
53
|
+
|
|
54
|
+
if (!releaseGood) throw new Error(`Couldn't find picking worksheet by order no (${releaseGoodNo})`)
|
|
55
|
+
|
|
56
|
+
const worksheet = await fetchExecutingWorksheet(
|
|
57
|
+
domain,
|
|
58
|
+
releaseGood.bizplace,
|
|
59
|
+
['bizplace'],
|
|
60
|
+
WORKSHEET_TYPE.PICKING,
|
|
61
|
+
releaseGood,
|
|
62
|
+
tx
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const qb: SelectQueryBuilder<WorksheetDetail> = tx.createQueryBuilder(WorksheetDetail, 'WSD')
|
|
66
|
+
qb.leftJoinAndSelect('WSD.targetInventory', 'T_INV')
|
|
67
|
+
.leftJoinAndSelect('T_INV.binLocation', 'BIN_LOC')
|
|
68
|
+
.leftJoinAndSelect('T_INV.inventory', 'INV')
|
|
69
|
+
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
70
|
+
.leftJoinAndSelect('INV.location', 'LOC')
|
|
71
|
+
|
|
72
|
+
if (locationSortingRules?.length > 0) {
|
|
73
|
+
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
74
|
+
qb.addOrderBy(`LOC.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
qb.addOrderBy(`PROD.name`, 'ASC')
|
|
79
|
+
|
|
80
|
+
const worksheetDetails: WorksheetDetail[] = await qb
|
|
81
|
+
.where('"WSD"."worksheet_id" = :worksheetId', { worksheetId: worksheet.id })
|
|
82
|
+
.andWhere('"WSD"."status" != :status', { status: WORKSHEET_STATUS.REPLACED })
|
|
83
|
+
.andWhere('"T_INV"."status" != :t_invstatus', { t_invstatus: ORDER_INVENTORY_STATUS.CANCELLED })
|
|
84
|
+
.getMany()
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
worksheetInfo: {
|
|
88
|
+
bizplaceName: releaseGood.bizplace.name,
|
|
89
|
+
partnerDomainId: releaseGood.bizplace?.domain.id,
|
|
90
|
+
startedAt: worksheet.startedAt,
|
|
91
|
+
refNo: releaseGood.refNo,
|
|
92
|
+
refNo2: releaseGood.refNo2,
|
|
93
|
+
releaseGood
|
|
94
|
+
},
|
|
95
|
+
worksheetDetailInfos: worksheetDetails.map(async (pickingWSD: WorksheetDetail) => {
|
|
96
|
+
const targetInventory: OrderInventory = pickingWSD.targetInventory
|
|
97
|
+
const inventory: Inventory = targetInventory.inventory
|
|
98
|
+
return {
|
|
99
|
+
name: pickingWSD.name,
|
|
100
|
+
palletId: inventory?.palletId,
|
|
101
|
+
cartonId: inventory?.cartonId,
|
|
102
|
+
batchId: inventory?.batchId,
|
|
103
|
+
batchIdRef: inventory?.batchIdRef,
|
|
104
|
+
product: inventory?.product,
|
|
105
|
+
qty: inventory?.qty,
|
|
106
|
+
binLocation: targetInventory?.binLocation || '',
|
|
107
|
+
releaseQty: targetInventory.releaseQty,
|
|
108
|
+
pickedQty: targetInventory.pickedQty,
|
|
109
|
+
status: pickingWSD.status,
|
|
110
|
+
description: pickingWSD.description,
|
|
111
|
+
targetName: targetInventory.name,
|
|
112
|
+
packingType: inventory?.packingType,
|
|
113
|
+
packingSize: inventory?.packingSize,
|
|
114
|
+
expirationDate: inventory?.expirationDate,
|
|
115
|
+
location: inventory?.location,
|
|
116
|
+
relatedOrderInv: targetInventory
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
80
120
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { Bizplace } from '@things-factory/biz-base'
|
|
4
|
+
import { OrderInventory, ReturnOrder } from '@things-factory/sales-base'
|
|
2
5
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { fetchExecutingWorksheet } from '../../../utils'
|
|
5
|
-
import { ReturnOrder, OrderInventory } from '@things-factory/sales-base'
|
|
6
|
+
|
|
6
7
|
import { WORKSHEET_TYPE } from '../../../constants'
|
|
7
8
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
9
|
+
import { fetchExecutingWorksheet } from '../../../utils'
|
|
8
10
|
|
|
9
11
|
export const unloadingReturnWorksheetResolver = {
|
|
10
12
|
async unloadingReturnWorksheet(_: any, { returnOrderNo }, context: any) {
|
|
@@ -59,7 +61,7 @@ export const unloadingReturnWorksheetResolver = {
|
|
|
59
61
|
description: productWSD.description,
|
|
60
62
|
targetName: targetInventory.name,
|
|
61
63
|
packingType: targetInventory.packingType,
|
|
62
|
-
packingSize: targetInventory.packingSize,
|
|
64
|
+
packingSize: targetInventory.inventory.packingSize,
|
|
63
65
|
palletQty: targetInventory.palletQty,
|
|
64
66
|
actualPalletQty: targetInventory.actualPalletQty,
|
|
65
67
|
packQty: targetInventory.returnQty,
|
|
@@ -290,6 +290,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
290
290
|
cartonId: String
|
|
291
291
|
locationName: String!
|
|
292
292
|
releaseQty: Int!
|
|
293
|
+
binLocation: String
|
|
293
294
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
294
295
|
|
|
295
296
|
scanProductPicking (
|
|
@@ -515,6 +516,9 @@ export const Mutation = /* GraphQL */ `
|
|
|
515
516
|
worksheetId: String!
|
|
516
517
|
userId: String!
|
|
517
518
|
): Boolean @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
519
|
+
|
|
520
|
+
fetchAndAssignPickingTask
|
|
521
|
+
: ExecutingWorksheet @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
518
522
|
|
|
519
523
|
palletizingPallets (
|
|
520
524
|
refOrderNo: String!
|
|
@@ -588,7 +592,7 @@ export const Query = /* GraphQL */ `
|
|
|
588
592
|
|
|
589
593
|
pickingWorksheet (
|
|
590
594
|
releaseGoodNo: String!, locationSortingRules: [Sorting]
|
|
591
|
-
): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query")
|
|
595
|
+
): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query") @transaction
|
|
592
596
|
|
|
593
597
|
sortingWorksheet (
|
|
594
598
|
releaseGoodNo: String!
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EntityManager,
|
|
3
|
-
getRepository,
|
|
4
|
-
Repository
|
|
5
|
-
} from 'typeorm'
|
|
1
|
+
import { EntityManager, getRepository, Repository } from 'typeorm'
|
|
6
2
|
|
|
7
3
|
import { User } from '@things-factory/auth-base'
|
|
8
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
@@ -63,10 +59,36 @@ export async function generateInventoryHistory(
|
|
|
63
59
|
palletId: inventory.palletId,
|
|
64
60
|
seq: seq - 1
|
|
65
61
|
})
|
|
62
|
+
|
|
66
63
|
openingQty = lastInvHistory.openingQty + lastInvHistory.qty
|
|
67
64
|
openingUomValue = lastInvHistory.openingUomValue + lastInvHistory.uomValue
|
|
68
65
|
}
|
|
69
66
|
|
|
67
|
+
if (transactionType == 'PICKING' || transactionType == 'UNLOADING') {
|
|
68
|
+
const [findSameOrderHistory, total]: InventoryHistory = await invHistoryRepo.findAndCount({
|
|
69
|
+
domain: inventory.domain,
|
|
70
|
+
palletId: inventory.palletId,
|
|
71
|
+
refOrderId: refOrder.id
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
if (findSameOrderHistory) {
|
|
75
|
+
let prevTotalQty = 0
|
|
76
|
+
let prevTotalUomValue = 0
|
|
77
|
+
for (let oh of findSameOrderHistory) {
|
|
78
|
+
prevTotalQty += oh.qty
|
|
79
|
+
prevTotalUomValue += oh.uomValue
|
|
80
|
+
}
|
|
81
|
+
qty -= prevTotalQty
|
|
82
|
+
uomValue -= prevTotalUomValue
|
|
83
|
+
}
|
|
84
|
+
} else if (transactionType == 'UNDO_UNLOADING' || transactionType == 'RETURN') {
|
|
85
|
+
qty = qty
|
|
86
|
+
uomValue = uomValue
|
|
87
|
+
} else {
|
|
88
|
+
qty = 0
|
|
89
|
+
uomValue = 0
|
|
90
|
+
}
|
|
91
|
+
|
|
70
92
|
let inventoryHistory: InventoryHistory = new InventoryHistory()
|
|
71
93
|
inventoryHistory.name = InventoryNoGenerator.inventoryHistoryName()
|
|
72
94
|
inventoryHistory.description = inventory.description
|
|
@@ -221,7 +243,7 @@ export async function checkPalletIdenticallity(
|
|
|
221
243
|
* @param trxMgr
|
|
222
244
|
*/
|
|
223
245
|
export async function inventoriesByStrategy(
|
|
224
|
-
{ worksheetId, batchId, bizplaceId, productId, packingType, packingSize, pickingStrategy, locationSortingRules },
|
|
246
|
+
{ worksheetId, batchId, bizplaceId, productId, packingType, packingSize, uom, pickingStrategy, locationSortingRules },
|
|
225
247
|
domain: Domain,
|
|
226
248
|
trxMgr: EntityManager
|
|
227
249
|
) {
|
|
@@ -248,12 +270,14 @@ export async function inventoriesByStrategy(
|
|
|
248
270
|
.andWhere('"PROD"."id" = :productId')
|
|
249
271
|
.andWhere('"INV"."packing_type" = :packingType')
|
|
250
272
|
.andWhere('"INV"."packing_size" = :packingSize')
|
|
273
|
+
.andWhere('"INV"."uom" = :uom')
|
|
251
274
|
.andWhere('"INV"."status" = :status', { status: 'STORED' })
|
|
252
275
|
.setParameters({
|
|
253
276
|
domainId: domain.id,
|
|
254
277
|
productId,
|
|
255
278
|
packingType,
|
|
256
|
-
packingSize
|
|
279
|
+
packingSize,
|
|
280
|
+
uom
|
|
257
281
|
})
|
|
258
282
|
|
|
259
283
|
if (batchId !== '') {
|