@things-factory/worksheet-base 4.3.186 → 4.3.188
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/constants/worksheet.js +3 -1
- package/dist-server/constants/worksheet.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +14 -3
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +6 -2
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/replenishment/index.js +18 -0
- package/dist-server/controllers/replenishment/index.js.map +1 -0
- package/dist-server/controllers/replenishment/replenishment-worksheet-controller.js +455 -0
- package/dist-server/controllers/replenishment/replenishment-worksheet-controller.js.map +1 -0
- package/dist-server/controllers/worksheet-controller.js +32 -9
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +10 -2
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +15 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/entities/warehouse-inventory-assignment-ranking.js +37 -0
- package/dist-server/entities/warehouse-inventory-assignment-ranking.js.map +1 -0
- package/dist-server/entities/worksheet.js +13 -9
- package/dist-server/entities/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cancel-replenishment.js +57 -0
- package/dist-server/graphql/resolvers/worksheet/cancel-replenishment.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet.js +7 -1
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-replenishement-worksheet.js +19 -0
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-replenishement-worksheet.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/index.js +5 -2
- package/dist-server/graphql/resolvers/worksheet/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +284 -270
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- 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/replenishment-picking.js +12 -0
- package/dist-server/graphql/resolvers/worksheet/picking/replenishment-picking.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +142 -78
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-replenishment-putaway.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-replenishment-putaway.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/putaway/index.js +4 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/replenishment-putaway.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/putaway/replenishment-putaway.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/putaway/undo-replenishment-putaway.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/putaway/undo-replenishment-putaway.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/putaway-replenishment-worksheet.js +81 -0
- package/dist-server/graphql/resolvers/worksheet/putaway-replenishment-worksheet.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/replenishment/activate-picking-replenishment.js +17 -0
- package/dist-server/graphql/resolvers/worksheet/replenishment/activate-picking-replenishment.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/replenishment/index.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/replenishment/index.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +1 -0
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheets.js +28 -2
- package/dist-server/graphql/resolvers/worksheet/worksheets.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +42 -1
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/replenish-inventory-patch.js +11 -0
- package/dist-server/graphql/types/worksheet/replenish-inventory-patch.js.map +1 -0
- package/dist-server/graphql/types/worksheet/worksheet-info.js +1 -0
- package/dist-server/graphql/types/worksheet/worksheet-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet.js +1 -0
- package/dist-server/graphql/types/worksheet/worksheet.js.map +1 -1
- package/dist-server/utils/datetime-util.js +13 -1
- package/dist-server/utils/datetime-util.js.map +1 -1
- package/dist-server/utils/inventory-util.js +2 -0
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/dist-server/utils/worksheet-no-generator.js +21 -1
- package/dist-server/utils/worksheet-no-generator.js.map +1 -1
- package/dist-server/utils/worksheet-util.js +3 -0
- package/dist-server/utils/worksheet-util.js.map +1 -1
- package/package.json +5 -5
- package/server/constants/worksheet.ts +3 -1
- package/server/controllers/ecommerce/sellercraft-controller.ts +25 -6
- package/server/controllers/index.ts +1 -1
- package/server/controllers/outbound/picking-worksheet-controller.ts +12 -3
- package/server/controllers/replenishment/index.ts +1 -0
- package/server/controllers/replenishment/replenishment-worksheet-controller.ts +632 -0
- package/server/controllers/worksheet-controller.ts +47 -13
- package/server/entities/index.ts +15 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +13 -1
- package/server/entities/warehouse-inventory-assignment-ranking.ts +19 -0
- package/server/entities/worksheet.ts +5 -1
- package/server/graphql/resolvers/worksheet/cancel-replenishment.ts +69 -0
- package/server/graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet.ts +6 -1
- package/server/graphql/resolvers/worksheet/generate-worksheet/generate-replenishement-worksheet.ts +30 -0
- package/server/graphql/resolvers/worksheet/generate-worksheet/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/index.ts +8 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +4 -2
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +342 -310
- package/server/graphql/resolvers/worksheet/picking/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/picking/replenishment-picking.ts +27 -0
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +177 -95
- package/server/graphql/resolvers/worksheet/putaway/complete-replenishment-putaway.ts +25 -0
- package/server/graphql/resolvers/worksheet/putaway/index.ts +7 -1
- package/server/graphql/resolvers/worksheet/putaway/replenishment-putaway.ts +23 -0
- package/server/graphql/resolvers/worksheet/putaway/undo-replenishment-putaway.ts +22 -0
- package/server/graphql/resolvers/worksheet/putaway-replenishment-worksheet.ts +95 -0
- package/server/graphql/resolvers/worksheet/replenishment/activate-picking-replenishment.ts +26 -0
- package/server/graphql/resolvers/worksheet/replenishment/index.ts +5 -0
- package/server/graphql/resolvers/worksheet/worksheet.ts +1 -0
- package/server/graphql/resolvers/worksheet/worksheets.ts +38 -3
- package/server/graphql/types/worksheet/index.ts +42 -1
- package/server/graphql/types/worksheet/replenish-inventory-patch.ts +8 -0
- package/server/graphql/types/worksheet/worksheet-info.ts +1 -0
- package/server/graphql/types/worksheet/worksheet.ts +1 -0
- package/server/utils/datetime-util.ts +14 -0
- package/server/utils/inventory-util.ts +3 -0
- package/server/utils/worksheet-no-generator.ts +29 -1
- package/server/utils/worksheet-util.ts +4 -2
|
@@ -12,6 +12,7 @@ import { scanProductBatchPickingResolver } from './scan-product-batch-picking'
|
|
|
12
12
|
import { undoPickingAssigmentResolver } from './undo-picking-assignment'
|
|
13
13
|
import { undoSerialNumberPickingResolver } from './undo-serial-number-picking'
|
|
14
14
|
import { sealToteResolver } from './seal-tote'
|
|
15
|
+
import { replenishmentPickingResolver } from './replenishment-picking'
|
|
15
16
|
|
|
16
17
|
export const Mutations = {
|
|
17
18
|
...assignPickingInventoriesResolver,
|
|
@@ -27,5 +28,6 @@ export const Mutations = {
|
|
|
27
28
|
...assignPickingWorkerResolver,
|
|
28
29
|
...fetchAndAssignPickingTaskResolver,
|
|
29
30
|
...undoSerialNumberPickingResolver,
|
|
30
|
-
...sealToteResolver
|
|
31
|
+
...sealToteResolver,
|
|
32
|
+
...replenishmentPickingResolver
|
|
31
33
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base'
|
|
2
|
+
import { Domain } from '@things-factory/shell'
|
|
3
|
+
import { EntityManager } from 'typeorm'
|
|
4
|
+
import { ReplenishmentWorksheetController } from '../../../../controllers'
|
|
5
|
+
|
|
6
|
+
import { pickingWorksheet } from '../picking-worksheet'
|
|
7
|
+
|
|
8
|
+
export const replenishmentPickingResolver = {
|
|
9
|
+
async replenishmentPicking(
|
|
10
|
+
_: any,
|
|
11
|
+
{ worksheetDetailName, worksheetType, productBarcode, cartonId, binLocation, serialNumber, pickingQty },
|
|
12
|
+
context: any
|
|
13
|
+
) {
|
|
14
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
15
|
+
|
|
16
|
+
const worksheetController: ReplenishmentWorksheetController = new ReplenishmentWorksheetController(tx, domain, user)
|
|
17
|
+
let ws = await worksheetController.replenishmentPicking(
|
|
18
|
+
worksheetDetailName,
|
|
19
|
+
worksheetType,
|
|
20
|
+
productBarcode,
|
|
21
|
+
cartonId,
|
|
22
|
+
binLocation,
|
|
23
|
+
serialNumber,
|
|
24
|
+
pickingQty
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { EntityManager, In, SelectQueryBuilder } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ORDER_INVENTORY_STATUS,
|
|
5
|
+
OrderInventory,
|
|
6
|
+
ReleaseGood,
|
|
7
|
+
ShippingOrder,
|
|
8
|
+
Replenishment
|
|
9
|
+
} from '@things-factory/sales-base'
|
|
4
10
|
import { Domain } from '@things-factory/shell'
|
|
5
11
|
import { Inventory, Location, InventoryChange } from '@things-factory/warehouse-base'
|
|
6
12
|
|
|
@@ -8,30 +14,26 @@ import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
|
8
14
|
import { WorksheetDetail } from '../../../entities'
|
|
9
15
|
import { fetchExecutingWorksheet } from '../../../utils'
|
|
10
16
|
import { VasOrderWorksheet } from 'server/graphql/types/worksheet/vas-order-worksheet'
|
|
17
|
+
import { ReplenishmentWorksheetController } from 'server/controllers'
|
|
11
18
|
|
|
12
19
|
export const pickingWorksheetResolver = {
|
|
13
|
-
async pickingWorksheet(_: any, {
|
|
20
|
+
async pickingWorksheet(_: any, { orderNo, locationSortingRules }, context: any) {
|
|
14
21
|
const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
|
|
15
22
|
|
|
16
|
-
return await pickingWorksheet(domain,
|
|
23
|
+
return await pickingWorksheet(domain, orderNo, locationSortingRules, tx)
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
export async function pickingWorksheet(
|
|
21
|
-
domain: Domain,
|
|
22
|
-
releaseGoodNo: String,
|
|
23
|
-
locationSortingRules: any,
|
|
24
|
-
tx: EntityManager
|
|
25
|
-
) {
|
|
27
|
+
export async function pickingWorksheet(domain: Domain, orderNo: String, locationSortingRules: any, tx: EntityManager) {
|
|
26
28
|
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
27
|
-
where: { domain, name:
|
|
29
|
+
where: { domain, name: orderNo /*status: ORDER_STATUS.PICKING*/ },
|
|
28
30
|
relations: ['bizplace', 'bizplace.domain']
|
|
29
31
|
})
|
|
30
32
|
|
|
31
33
|
// Find Release Order based on Bin
|
|
32
34
|
if (!releaseGood) {
|
|
33
35
|
const binLocation: Location = await tx.getRepository(Location).findOne({
|
|
34
|
-
where: { domain, name:
|
|
36
|
+
where: { domain, name: orderNo }
|
|
35
37
|
})
|
|
36
38
|
|
|
37
39
|
const orderInventoryByBin: OrderInventory = await tx.getRepository(OrderInventory).findOne({
|
|
@@ -47,101 +49,181 @@ export async function pickingWorksheet(
|
|
|
47
49
|
})
|
|
48
50
|
|
|
49
51
|
if (orderInventoryByBin?.releaseGood) {
|
|
50
|
-
|
|
52
|
+
orderNo = orderInventoryByBin.releaseGood.name
|
|
51
53
|
releaseGood = orderInventoryByBin.releaseGood
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
if (!releaseGood)
|
|
57
|
+
if (!releaseGood) {
|
|
58
|
+
const replenishment = await replenishmentWorksheet(orderNo)
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if (!replenishment) {
|
|
61
|
+
throw new Error(`Couldn't find picking worksheet by order no (${orderNo})`)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return replenishment
|
|
65
|
+
} else {
|
|
66
|
+
if (releaseGood.exportOption) {
|
|
67
|
+
var shippingOrder: ShippingOrder = await tx.getRepository(ShippingOrder).findOne({
|
|
68
|
+
where: {
|
|
69
|
+
id: releaseGood?.shippingOrderId
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const worksheet = await fetchExecutingWorksheet(
|
|
75
|
+
domain,
|
|
76
|
+
releaseGood.bizplace,
|
|
77
|
+
['bizplace'],
|
|
78
|
+
WORKSHEET_TYPE.PICKING,
|
|
79
|
+
releaseGood,
|
|
80
|
+
tx
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const qb: SelectQueryBuilder<WorksheetDetail> = tx.createQueryBuilder(WorksheetDetail, 'WSD')
|
|
84
|
+
qb.leftJoinAndSelect('WSD.targetInventory', 'T_INV')
|
|
85
|
+
.leftJoinAndSelect('T_INV.binLocation', 'BIN_LOC')
|
|
86
|
+
.leftJoinAndSelect('T_INV.inventory', 'INV')
|
|
87
|
+
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
88
|
+
.leftJoinAndSelect('T_INV.productDetail', 'PROD_DET')
|
|
89
|
+
.leftJoinAndSelect('INV.location', 'LOC')
|
|
90
|
+
|
|
91
|
+
if (locationSortingRules?.length > 0) {
|
|
92
|
+
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
93
|
+
qb.addOrderBy(`LOC.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
qb.addOrderBy(`PROD.name`, 'ASC')
|
|
98
|
+
|
|
99
|
+
const worksheetDetails: WorksheetDetail[] = await qb
|
|
100
|
+
.where('"WSD"."worksheet_id" = :worksheetId', { worksheetId: worksheet.id })
|
|
101
|
+
.andWhere('"WSD"."status" != :status', { status: WORKSHEET_STATUS.REPLACED })
|
|
102
|
+
.andWhere('"T_INV"."status" != :t_invstatus', { t_invstatus: ORDER_INVENTORY_STATUS.CANCELLED })
|
|
103
|
+
.getMany()
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
worksheetInfo: {
|
|
107
|
+
bizplaceName: releaseGood.bizplace.name,
|
|
108
|
+
partnerDomainId: releaseGood.bizplace?.domain.id,
|
|
109
|
+
startedAt: worksheet.startedAt,
|
|
110
|
+
refNo: releaseGood.refNo,
|
|
111
|
+
refNo2: releaseGood.refNo2,
|
|
112
|
+
refNo3: releaseGood.refNo3,
|
|
113
|
+
type: releaseGood.type,
|
|
114
|
+
containerNo: shippingOrder?.containerNo,
|
|
115
|
+
marketplaceStatus: releaseGood.marketplaceOrderStatus,
|
|
116
|
+
shippingProvider: releaseGood.transporter,
|
|
117
|
+
trackingNo: releaseGood.trackingNo,
|
|
118
|
+
releaseGood
|
|
119
|
+
},
|
|
120
|
+
worksheetDetailInfos: worksheetDetails.map(async (pickingWSD: WorksheetDetail) => {
|
|
121
|
+
const targetInventory: OrderInventory = pickingWSD.targetInventory
|
|
122
|
+
const inventory: Inventory = targetInventory.inventory
|
|
123
|
+
|
|
124
|
+
const inventoryChangesCount: number = await tx.getRepository(InventoryChange).count({
|
|
125
|
+
where: {
|
|
126
|
+
inventory: inventory.id,
|
|
127
|
+
status: 'PENDING',
|
|
128
|
+
transactionType: 'MISSING'
|
|
129
|
+
},
|
|
130
|
+
relations: ['inventory', 'product']
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
name: pickingWSD.name,
|
|
135
|
+
palletId: inventory?.palletId,
|
|
136
|
+
cartonId: inventory?.cartonId,
|
|
137
|
+
batchId: inventory?.batchId,
|
|
138
|
+
batchIdRef: inventory?.batchIdRef,
|
|
139
|
+
product: inventory?.product,
|
|
140
|
+
qty: inventory?.qty,
|
|
141
|
+
binLocation: targetInventory?.binLocation || '',
|
|
142
|
+
releaseQty: targetInventory.releaseQty,
|
|
143
|
+
pickedQty: targetInventory.pickedQty,
|
|
144
|
+
status: pickingWSD.status,
|
|
145
|
+
description: pickingWSD.description,
|
|
146
|
+
targetName: targetInventory.name,
|
|
147
|
+
packingType: inventory?.packingType,
|
|
148
|
+
packingSize: inventory?.packingSize,
|
|
149
|
+
expirationDate: inventory?.expirationDate,
|
|
150
|
+
location: inventory?.location,
|
|
151
|
+
relatedOrderInv: targetInventory,
|
|
152
|
+
hasMissingInventoryChanges: inventoryChangesCount > 0 ? true : false
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
63
156
|
}
|
|
64
157
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
['bizplace'],
|
|
69
|
-
WORKSHEET_TYPE.PICKING,
|
|
70
|
-
releaseGood,
|
|
71
|
-
tx
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
const qb: SelectQueryBuilder<WorksheetDetail> = tx.createQueryBuilder(WorksheetDetail, 'WSD')
|
|
75
|
-
qb.leftJoinAndSelect('WSD.targetInventory', 'T_INV')
|
|
76
|
-
.leftJoinAndSelect('T_INV.binLocation', 'BIN_LOC')
|
|
77
|
-
.leftJoinAndSelect('T_INV.inventory', 'INV')
|
|
78
|
-
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
79
|
-
.leftJoinAndSelect('T_INV.productDetail', 'PROD_DET')
|
|
80
|
-
.leftJoinAndSelect('INV.location', 'LOC')
|
|
81
|
-
|
|
82
|
-
if (locationSortingRules?.length > 0) {
|
|
83
|
-
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
84
|
-
qb.addOrderBy(`LOC.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
158
|
+
async function replenishmentWorksheet(orderNo: String) {
|
|
159
|
+
let replenishment: Replenishment = await tx.getRepository(Replenishment).findOne({
|
|
160
|
+
where: { domain, name: orderNo }
|
|
85
161
|
})
|
|
86
|
-
}
|
|
87
162
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
transactionType: 'MISSING'
|
|
120
|
-
},
|
|
121
|
-
relations: ['inventory', 'product']
|
|
122
|
-
})
|
|
163
|
+
if (replenishment) {
|
|
164
|
+
const worksheet = await fetchExecutingWorksheet(
|
|
165
|
+
domain,
|
|
166
|
+
null,
|
|
167
|
+
[],
|
|
168
|
+
WORKSHEET_TYPE.PICKING_REPLENISHMENT,
|
|
169
|
+
replenishment,
|
|
170
|
+
tx
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
const qb: SelectQueryBuilder<WorksheetDetail> = tx.createQueryBuilder(WorksheetDetail, 'WSD')
|
|
174
|
+
qb.leftJoinAndSelect('WSD.targetInventory', 'T_INV')
|
|
175
|
+
.leftJoinAndSelect('T_INV.binLocation', 'BIN_LOC')
|
|
176
|
+
.leftJoinAndSelect('T_INV.inventory', 'INV')
|
|
177
|
+
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
178
|
+
.leftJoinAndSelect('T_INV.productDetail', 'PROD_DET')
|
|
179
|
+
.leftJoinAndSelect('INV.location', 'LOC')
|
|
180
|
+
|
|
181
|
+
if (locationSortingRules?.length > 0) {
|
|
182
|
+
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
183
|
+
qb.addOrderBy(`LOC.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
qb.addOrderBy(`PROD.name`, 'ASC')
|
|
188
|
+
|
|
189
|
+
const worksheetDetails: WorksheetDetail[] = await qb
|
|
190
|
+
.where('"WSD"."worksheet_id" = :worksheetId', { worksheetId: worksheet.id })
|
|
191
|
+
.andWhere('"WSD"."status" != :status', { status: WORKSHEET_STATUS.REPLACED })
|
|
192
|
+
.andWhere('"T_INV"."status" != :t_invstatus', { t_invstatus: ORDER_INVENTORY_STATUS.CANCELLED })
|
|
193
|
+
.getMany()
|
|
123
194
|
|
|
124
195
|
return {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
196
|
+
worksheetInfo: {
|
|
197
|
+
startedAt: worksheet.startedAt,
|
|
198
|
+
replenishment
|
|
199
|
+
},
|
|
200
|
+
worksheetDetailInfos: worksheetDetails.map(async (pickingWSD: WorksheetDetail) => {
|
|
201
|
+
const targetInventory: OrderInventory = pickingWSD.targetInventory
|
|
202
|
+
const inventory: Inventory = targetInventory.inventory
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
name: pickingWSD.name,
|
|
206
|
+
palletId: inventory?.palletId,
|
|
207
|
+
cartonId: inventory?.cartonId,
|
|
208
|
+
batchId: inventory?.batchId,
|
|
209
|
+
batchIdRef: inventory?.batchIdRef,
|
|
210
|
+
product: inventory?.product,
|
|
211
|
+
qty: inventory?.qty,
|
|
212
|
+
binLocation: targetInventory?.binLocation || '',
|
|
213
|
+
releaseQty: targetInventory.releaseQty,
|
|
214
|
+
pickedQty: targetInventory.pickedQty,
|
|
215
|
+
status: pickingWSD.status,
|
|
216
|
+
description: pickingWSD.description,
|
|
217
|
+
targetName: targetInventory.name,
|
|
218
|
+
packingType: inventory?.packingType,
|
|
219
|
+
packingSize: inventory?.packingSize,
|
|
220
|
+
expirationDate: inventory?.expirationDate,
|
|
221
|
+
location: inventory?.location,
|
|
222
|
+
relatedOrderInv: targetInventory
|
|
223
|
+
}
|
|
224
|
+
})
|
|
144
225
|
}
|
|
145
|
-
}
|
|
226
|
+
}
|
|
227
|
+
return replenishment
|
|
146
228
|
}
|
|
147
229
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Replenishment } from '@things-factory/sales-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { ReplenishmentWorksheetController } from '../../../../controllers'
|
|
8
|
+
import { Worksheet } from '../../../../entities'
|
|
9
|
+
|
|
10
|
+
export const completeReplenishmentPutawayResolver = {
|
|
11
|
+
async completeReplenishmentPutaway(_: any, { replenishmentNo }, context: any) {
|
|
12
|
+
const { tx, user, domain }: { tx: EntityManager; user: User; domain: Domain } = context.state
|
|
13
|
+
await completeReplenishmentPutaway(tx, domain, user, replenishmentNo)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function completeReplenishmentPutaway(
|
|
18
|
+
tx: EntityManager,
|
|
19
|
+
domain: Domain,
|
|
20
|
+
user: User,
|
|
21
|
+
replenishmentNo: string
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
const worksheetController: ReplenishmentWorksheetController = new ReplenishmentWorksheetController(tx, domain, user)
|
|
24
|
+
let worksheet: Worksheet = await worksheetController.completeReplenishmentPutaway(replenishmentNo)
|
|
25
|
+
}
|
|
@@ -2,10 +2,16 @@ import { activatePutawayResolver } from './activate-putaway'
|
|
|
2
2
|
import { completePutawayResolver } from './complete-putaway'
|
|
3
3
|
import { putawayResolver } from './putaway'
|
|
4
4
|
import { undoPutawayResolver } from './undo-putaway'
|
|
5
|
+
import { replenishmentPutawayResolver } from './replenishment-putaway'
|
|
6
|
+
import { completeReplenishmentPutawayResolver } from './complete-replenishment-putaway'
|
|
7
|
+
import { undoReplenishmentPutawayResolver } from './undo-replenishment-putaway'
|
|
5
8
|
|
|
6
9
|
export const Mutations = {
|
|
7
10
|
...activatePutawayResolver,
|
|
8
11
|
...putawayResolver,
|
|
9
12
|
...undoPutawayResolver,
|
|
10
|
-
...completePutawayResolver
|
|
13
|
+
...completePutawayResolver,
|
|
14
|
+
...replenishmentPutawayResolver,
|
|
15
|
+
...completeReplenishmentPutawayResolver,
|
|
16
|
+
...undoReplenishmentPutawayResolver
|
|
11
17
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base'
|
|
2
|
+
import { Domain } from '@things-factory/shell'
|
|
3
|
+
import { EntityManager } from 'typeorm'
|
|
4
|
+
import { ReplenishmentWorksheetController } from '../../../../controllers'
|
|
5
|
+
|
|
6
|
+
export const replenishmentPutawayResolver = {
|
|
7
|
+
async replenishmentPutaway(_: any, { worksheetDetailName, cartonId, toLocation }, context: any) {
|
|
8
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
9
|
+
await replenishmentPutaway(tx, domain, user, worksheetDetailName, cartonId, toLocation)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function replenishmentPutaway(
|
|
14
|
+
tx: EntityManager,
|
|
15
|
+
domain: Domain,
|
|
16
|
+
user: User,
|
|
17
|
+
worksheetDetailName: [string],
|
|
18
|
+
cartonId: string,
|
|
19
|
+
locationName: string
|
|
20
|
+
) {
|
|
21
|
+
const worksheetController: ReplenishmentWorksheetController = new ReplenishmentWorksheetController(tx, domain, user)
|
|
22
|
+
await worksheetController.replenishmentPutaway(worksheetDetailName, cartonId, locationName)
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base'
|
|
2
|
+
import { Domain } from '@things-factory/shell'
|
|
3
|
+
import { EntityManager } from 'typeorm'
|
|
4
|
+
import { ReplenishmentWorksheetController } from '../../../../controllers'
|
|
5
|
+
|
|
6
|
+
export const undoReplenishmentPutawayResolver = {
|
|
7
|
+
async undoReplenishmentPutaway(_: any, { worksheetDetailName, cartonId }, context: any) {
|
|
8
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
9
|
+
await undoReplenishmentPutaway(tx, domain, user, worksheetDetailName, cartonId)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function undoReplenishmentPutaway(
|
|
14
|
+
tx: EntityManager,
|
|
15
|
+
domain: Domain,
|
|
16
|
+
user: User,
|
|
17
|
+
worksheetDetailName: [string],
|
|
18
|
+
cartonId: string
|
|
19
|
+
): Promise<void> {
|
|
20
|
+
const worksheetController: ReplenishmentWorksheetController = new ReplenishmentWorksheetController(tx, domain, user)
|
|
21
|
+
await worksheetController.undoReplenishmentPutaway(worksheetDetailName, cartonId)
|
|
22
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { getRepository, SelectQueryBuilder } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { Bizplace } from '@things-factory/biz-base'
|
|
4
|
+
import { Replenishment, OrderInventory, ORDER_INVENTORY_STATUS, ORDER_STATUS } from '@things-factory/sales-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
|
+
import { Inventory, Location } from '@things-factory/warehouse-base'
|
|
7
|
+
|
|
8
|
+
import { WORKSHEET_TYPE } from '../../../constants'
|
|
9
|
+
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
10
|
+
import { fetchExecutingWorksheet } from '../../../utils'
|
|
11
|
+
|
|
12
|
+
export const putawayReplenishmentWorksheetResolver = {
|
|
13
|
+
async putawayReplenishmentWorksheet(_: any, { replenishmentNo }, context: any) {
|
|
14
|
+
const { domain }: { domain: Domain } = context.state
|
|
15
|
+
let replenishment: Replenishment = await getRepository(Replenishment).findOne({
|
|
16
|
+
where: {
|
|
17
|
+
domain,
|
|
18
|
+
name: replenishmentNo
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
if (!replenishment) {
|
|
23
|
+
const binLocation: Location = await getRepository(Location).findOne({
|
|
24
|
+
where: { domain, name: replenishmentNo }
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
if (!binLocation) throw new Error(`Replenishment dosen't exist.`)
|
|
28
|
+
|
|
29
|
+
const qb: SelectQueryBuilder<OrderInventory> = getRepository(OrderInventory).createQueryBuilder('orderInventory')
|
|
30
|
+
qb.innerJoinAndSelect('orderInventory.replenishment', 'replenishment')
|
|
31
|
+
.where('orderInventory.domain_id = :domainId', { domainId: domain.id })
|
|
32
|
+
.andWhere('orderInventory.status IN (:...orderInventoryStatus)', {
|
|
33
|
+
orderInventoryStatus: [ORDER_INVENTORY_STATUS.PUTTING_AWAY]
|
|
34
|
+
})
|
|
35
|
+
.andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
|
|
36
|
+
.andWhere('replenishment.status = :status', { status: ORDER_STATUS.PUTTING_AWAY })
|
|
37
|
+
|
|
38
|
+
const orderInventoryByBin = await qb.getOne()
|
|
39
|
+
|
|
40
|
+
if (orderInventoryByBin?.replenishment) {
|
|
41
|
+
replenishmentNo = orderInventoryByBin.replenishment.name
|
|
42
|
+
replenishment = orderInventoryByBin.replenishment
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!replenishment) throw new Error(`Replenishment dosen't exist.`)
|
|
47
|
+
|
|
48
|
+
const worksheet: Worksheet = await fetchExecutingWorksheet(
|
|
49
|
+
domain,
|
|
50
|
+
null,
|
|
51
|
+
[
|
|
52
|
+
'bizplace',
|
|
53
|
+
'replenishment',
|
|
54
|
+
'worksheetDetails',
|
|
55
|
+
'worksheetDetails.targetInventory',
|
|
56
|
+
'worksheetDetails.targetInventory.inventory',
|
|
57
|
+
'worksheetDetails.targetInventory.inventory.location',
|
|
58
|
+
'worksheetDetails.targetInventory.inventory.product',
|
|
59
|
+
'worksheetDetails.toLocation'
|
|
60
|
+
],
|
|
61
|
+
WORKSHEET_TYPE.PUTAWAY_REPLENISHMENT,
|
|
62
|
+
replenishment
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
worksheetInfo: {
|
|
67
|
+
status: worksheet.status,
|
|
68
|
+
replenishment: {
|
|
69
|
+
name: replenishment.name
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
worksheetDetailInfos: worksheet.worksheetDetails.map(async (putawayWSD: WorksheetDetail) => {
|
|
73
|
+
const targetInventory: OrderInventory = putawayWSD.targetInventory
|
|
74
|
+
const inventory: Inventory = targetInventory.inventory
|
|
75
|
+
return {
|
|
76
|
+
name: putawayWSD.name,
|
|
77
|
+
palletId: inventory.palletId,
|
|
78
|
+
cartonId: inventory.cartonId,
|
|
79
|
+
batchId: inventory.batchId,
|
|
80
|
+
expirationDate: inventory.expirationDate,
|
|
81
|
+
batchIdRef: inventory.batchIdRef,
|
|
82
|
+
product: inventory.product,
|
|
83
|
+
qty: targetInventory.releaseQty,
|
|
84
|
+
status: putawayWSD.status,
|
|
85
|
+
description: putawayWSD.description,
|
|
86
|
+
targetName: targetInventory.name,
|
|
87
|
+
packingType: inventory.packingType,
|
|
88
|
+
packingSize: inventory.packingSize,
|
|
89
|
+
location: inventory.location,
|
|
90
|
+
reusablePallet: inventory.reusablePallet
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Domain } from '@things-factory/shell'
|
|
5
|
+
|
|
6
|
+
import { ReplenishmentWorksheetController } from '../../../../controllers'
|
|
7
|
+
import { Worksheet } from '../../../../entities'
|
|
8
|
+
|
|
9
|
+
export const activatePickingReplenishmentResolver = {
|
|
10
|
+
async activatePickingReplenishment(_: any, { worksheetNo }, context: any) {
|
|
11
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
12
|
+
return await activatePickingReplenishment(tx, domain, user, worksheetNo)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function activatePickingReplenishment(
|
|
17
|
+
tx: EntityManager,
|
|
18
|
+
domain: Domain,
|
|
19
|
+
user: User,
|
|
20
|
+
worksheetNo: string
|
|
21
|
+
): Promise<Worksheet> {
|
|
22
|
+
const worksheetController: ReplenishmentWorksheetController = new ReplenishmentWorksheetController(tx, domain, user)
|
|
23
|
+
const worksheet = await worksheetController.activatePickingReplenishment(worksheetNo)
|
|
24
|
+
|
|
25
|
+
return worksheet
|
|
26
|
+
}
|