@things-factory/operato-wms 4.3.593 → 4.3.596
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/client/pages/components/list-view/product-list-view.js +378 -0
- package/client/pages/constants/picking-standard.js +1 -0
- package/client/pages/constants/worksheet.js +12 -0
- package/client/pages/order/release-order/b2b/b2b-order-list.js +91 -39
- package/client/pages/outbound/generate-worksheet-popup.js +188 -25
- package/client/pages/outbound/loading-v2/delivery-order-info.js +205 -0
- package/client/pages/outbound/loading-v2/load-by-qty.js +151 -0
- package/client/pages/outbound/loading-v2/loading-execution-base.js +514 -0
- package/client/pages/outbound/loading-v2/loading-execution.js +392 -0
- package/client/pages/outbound/loading-v2/loading.js +419 -0
- package/client/pages/outbound/loading-v2/release-good-info.js +93 -0
- package/client/pages/outbound/loading-v2/show-my-loading-worksheet-list-popup.js +93 -0
- package/client/pages/outbound/loading-v2/warehouse-return-popup.js +194 -0
- package/client/pages/outbound/picking-v2/issue-details-popup.js +163 -0
- package/client/pages/outbound/picking-v2/picking-execution-base.js +482 -0
- package/client/pages/outbound/picking-v2/picking-execution.js +379 -0
- package/client/pages/outbound/picking-v2/picking.js +387 -0
- package/client/pages/outbound/picking-v2/report-issue-popup.js +139 -0
- package/client/pages/outbound/picking-v2/scan-bin-no-popup.js +126 -0
- package/client/pages/outbound/picking-v2/worksheet-info.js +200 -0
- package/client/pages/outbound/select-operator-popup.js +6 -3
- package/client/pages/outbound/show-my-worksheet-list-popup.js +6 -2
- package/client/pages/outbound/worksheet-zone-picking.js +507 -0
- package/client/pages/outbound/zone-worksheet.js +574 -0
- package/client/route.js +15 -0
- package/dist-server/graphql/resolvers/index.js +11 -2
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/resolvers/outbound/complete-load.js +96 -0
- package/dist-server/graphql/resolvers/outbound/complete-load.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/find-loadable-release-good.js +58 -0
- package/dist-server/graphql/resolvers/outbound/find-loadable-release-good.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/get-delivery-orders.js +29 -0
- package/dist-server/graphql/resolvers/outbound/get-delivery-orders.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/get-loading-task.js +86 -0
- package/dist-server/graphql/resolvers/outbound/get-loading-task.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/index.js +16 -0
- package/dist-server/graphql/resolvers/outbound/index.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/load-by-qty.js +112 -0
- package/dist-server/graphql/resolvers/outbound/load-by-qty.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/loading-worksheet-v2.js +122 -0
- package/dist-server/graphql/resolvers/outbound/loading-worksheet-v2.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/my-loading-assignment-status.js +32 -0
- package/dist-server/graphql/resolvers/outbound/my-loading-assignment-status.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/sort-item.js +65 -0
- package/dist-server/graphql/resolvers/outbound/sort-item.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/undo-load.js +72 -0
- package/dist-server/graphql/resolvers/outbound/undo-load.js.map +1 -0
- package/dist-server/graphql/resolvers/outbound/warehouse-return.js +101 -0
- package/dist-server/graphql/resolvers/outbound/warehouse-return.js.map +1 -0
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js +53 -25
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/zone-worksheet/activate-zone-worksheet.js +91 -0
- package/dist-server/graphql/resolvers/zone-worksheet/activate-zone-worksheet.js.map +1 -0
- package/dist-server/graphql/resolvers/zone-worksheet/assign-sorter.js +36 -0
- package/dist-server/graphql/resolvers/zone-worksheet/assign-sorter.js.map +1 -0
- package/dist-server/graphql/resolvers/zone-worksheet/generate-zone-worksheet.js +103 -0
- package/dist-server/graphql/resolvers/zone-worksheet/generate-zone-worksheet.js.map +1 -0
- package/dist-server/graphql/resolvers/zone-worksheet/get-zone-picking-task.js +98 -0
- package/dist-server/graphql/resolvers/zone-worksheet/get-zone-picking-task.js.map +1 -0
- package/dist-server/graphql/resolvers/zone-worksheet/index.js +12 -0
- package/dist-server/graphql/resolvers/zone-worksheet/index.js.map +1 -0
- package/dist-server/graphql/resolvers/zone-worksheet/zone-picking.js +327 -0
- package/dist-server/graphql/resolvers/zone-worksheet/zone-picking.js.map +1 -0
- package/dist-server/graphql/resolvers/zone-worksheet/zone-worksheet.js +146 -0
- package/dist-server/graphql/resolvers/zone-worksheet/zone-worksheet.js.map +1 -0
- package/dist-server/graphql/types/index.js +11 -3
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/outbound/delivery-order-info-list.js +14 -0
- package/dist-server/graphql/types/outbound/delivery-order-info-list.js.map +1 -0
- package/dist-server/graphql/types/outbound/index.js +23 -0
- package/dist-server/graphql/types/outbound/index.js.map +1 -0
- package/dist-server/graphql/types/outbound/loading-assignment.js +15 -0
- package/dist-server/graphql/types/outbound/loading-assignment.js.map +1 -0
- package/dist-server/graphql/types/outbound/loading-worksheet-type.js +25 -0
- package/dist-server/graphql/types/outbound/loading-worksheet-type.js.map +1 -0
- package/dist-server/graphql/types/zone-worksheet/index.js +22 -0
- package/dist-server/graphql/types/zone-worksheet/index.js.map +1 -0
- package/dist-server/graphql/types/zone-worksheet/zone-picking-worksheet.js +18 -0
- package/dist-server/graphql/types/zone-worksheet/zone-picking-worksheet.js.map +1 -0
- package/dist-server/graphql/types/zone-worksheet/zone-worksheet-overview-list.js +13 -0
- package/dist-server/graphql/types/zone-worksheet/zone-worksheet-overview-list.js.map +1 -0
- package/dist-server/graphql/types/zone-worksheet/zone-worksheet-overview.js +16 -0
- package/dist-server/graphql/types/zone-worksheet/zone-worksheet-overview.js.map +1 -0
- package/package.json +8 -8
- package/server/graphql/resolvers/index.ts +11 -2
- package/server/graphql/resolvers/outbound/complete-load.ts +126 -0
- package/server/graphql/resolvers/outbound/find-loadable-release-good.ts +61 -0
- package/server/graphql/resolvers/outbound/get-delivery-orders.ts +32 -0
- package/server/graphql/resolvers/outbound/get-loading-task.ts +105 -0
- package/server/graphql/resolvers/outbound/index.ts +26 -0
- package/server/graphql/resolvers/outbound/load-by-qty.ts +176 -0
- package/server/graphql/resolvers/outbound/loading-worksheet-v2.ts +131 -0
- package/server/graphql/resolvers/outbound/my-loading-assignment-status.ts +35 -0
- package/server/graphql/resolvers/outbound/sort-item.ts +81 -0
- package/server/graphql/resolvers/outbound/undo-load.ts +83 -0
- package/server/graphql/resolvers/outbound/warehouse-return.ts +129 -0
- package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +77 -35
- package/server/graphql/resolvers/zone-worksheet/activate-zone-worksheet.ts +124 -0
- package/server/graphql/resolvers/zone-worksheet/assign-sorter.ts +49 -0
- package/server/graphql/resolvers/zone-worksheet/generate-zone-worksheet.ts +133 -0
- package/server/graphql/resolvers/zone-worksheet/get-zone-picking-task.ts +118 -0
- package/server/graphql/resolvers/zone-worksheet/index.ts +20 -0
- package/server/graphql/resolvers/zone-worksheet/zone-picking.ts +458 -0
- package/server/graphql/resolvers/zone-worksheet/zone-worksheet.ts +183 -0
- package/server/graphql/types/index.ts +11 -3
- package/server/graphql/types/outbound/delivery-order-info-list.ts +8 -0
- package/server/graphql/types/outbound/index.ts +22 -0
- package/server/graphql/types/outbound/loading-assignment.ts +9 -0
- package/server/graphql/types/outbound/loading-worksheet-type.ts +20 -0
- package/server/graphql/types/zone-worksheet/index.ts +21 -0
- package/server/graphql/types/zone-worksheet/zone-picking-worksheet.ts +12 -0
- package/server/graphql/types/zone-worksheet/zone-worksheet-overview-list.ts +7 -0
- package/server/graphql/types/zone-worksheet/zone-worksheet-overview.ts +10 -0
- package/things-factory.config.js +16 -0
- package/translations/en.json +30 -1
- package/translations/ko.json +27 -0
- package/translations/ms.json +29 -2
- package/translations/zh.json +27 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getLoadingTask } from './get-loading-task'
|
|
2
|
+
import { sortItem } from './sort-item'
|
|
3
|
+
import { findLoadableReleaseGood } from './find-loadable-release-good'
|
|
4
|
+
import { loadingWorksheetv2 } from './loading-worksheet-v2'
|
|
5
|
+
import { loadByQty } from './load-by-qty'
|
|
6
|
+
import { myLoadingAssignmentStatus } from './my-loading-assignment-status'
|
|
7
|
+
import { getDeliveryOrders } from './get-delivery-orders'
|
|
8
|
+
import { undoLoad } from './undo-load'
|
|
9
|
+
import { warehouseReturn } from './warehouse-return'
|
|
10
|
+
import { completeLoad } from './complete-load'
|
|
11
|
+
|
|
12
|
+
export const Query = {
|
|
13
|
+
...findLoadableReleaseGood,
|
|
14
|
+
...loadingWorksheetv2,
|
|
15
|
+
...myLoadingAssignmentStatus,
|
|
16
|
+
...getDeliveryOrders
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Mutation = {
|
|
20
|
+
...getLoadingTask,
|
|
21
|
+
...sortItem,
|
|
22
|
+
...loadByQty,
|
|
23
|
+
...undoLoad,
|
|
24
|
+
...warehouseReturn,
|
|
25
|
+
...completeLoad
|
|
26
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { EntityManager, In } from 'typeorm'
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
3
|
+
|
|
4
|
+
import { Domain } from '@things-factory/shell'
|
|
5
|
+
import { User } from '@things-factory/auth-base'
|
|
6
|
+
import {
|
|
7
|
+
ReleaseGood,
|
|
8
|
+
DeliveryOrderPatch,
|
|
9
|
+
generateDeliveryOrder,
|
|
10
|
+
OrderInventory,
|
|
11
|
+
ORDER_INVENTORY_STATUS,
|
|
12
|
+
OrderNoGenerator,
|
|
13
|
+
WorksheetDetailInfo
|
|
14
|
+
} from '@things-factory/sales-base'
|
|
15
|
+
import { Worksheet, WorksheetDetail, WORKSHEET_TYPE, WORKSHEET_STATUS } from '@things-factory/worksheet-base'
|
|
16
|
+
import { generateInventoryHistory, Inventory, INVENTORY_TRANSACTION_TYPE } from '@things-factory/warehouse-base'
|
|
17
|
+
|
|
18
|
+
export const loadByQty = {
|
|
19
|
+
async loadByQty(_: any, { worksheetDetailPatch }, context: any) {
|
|
20
|
+
try {
|
|
21
|
+
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
22
|
+
console.time('load')
|
|
23
|
+
const updatedWorksheetDetails = worksheetDetailPatch.orderInventories
|
|
24
|
+
const releaseGoodNo = worksheetDetailPatch.releaseGoodNo
|
|
25
|
+
const releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
26
|
+
where: { domain, name: releaseGoodNo },
|
|
27
|
+
relations: ['bizplace', 'orderInventories']
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (!releaseGood) {
|
|
31
|
+
throw new Error('Release good not found')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const worksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
35
|
+
where: {
|
|
36
|
+
domain,
|
|
37
|
+
releaseGood,
|
|
38
|
+
type: WORKSHEET_TYPE.LOADING,
|
|
39
|
+
status: WORKSHEET_STATUS.EXECUTING
|
|
40
|
+
},
|
|
41
|
+
relations: ['worksheetDetails', 'worksheetDetails.targetInventory', 'worksheetDetails.domain']
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
if (!worksheet) {
|
|
45
|
+
throw new Error('No loading worksheet found for order ' + releaseGoodNo)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const oiIds = worksheet.worksheetDetails.map((wsd: WorksheetDetail) => wsd.targetInventory.id)
|
|
49
|
+
const orderInventories: OrderInventory[] = await tx.getRepository(OrderInventory).find({
|
|
50
|
+
where: { id: In(oiIds) },
|
|
51
|
+
relations: ['inventory', 'domain', 'bizplace', 'releaseGood', 'product', 'productDetail', 'binLocation', 'orderProduct']
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const updatedOrderInventories: OrderInventory[] = []
|
|
55
|
+
for (const wsd of updatedWorksheetDetails) {
|
|
56
|
+
//find the respective wsd and oi to update
|
|
57
|
+
const foundWorksheetDetail: WorksheetDetail = worksheet.worksheetDetails.find(
|
|
58
|
+
foundWsd => foundWsd.name === wsd.name
|
|
59
|
+
)
|
|
60
|
+
let orderInventory = orderInventories.find(oi => oi.id === foundWorksheetDetail.targetInventory.id)
|
|
61
|
+
|
|
62
|
+
//validate oi status and do is not yet generated
|
|
63
|
+
if (orderInventory.status === ORDER_INVENTORY_STATUS.LOADED || orderInventory.deliveryOrderId !== null) {
|
|
64
|
+
continue
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// compare with sort qty
|
|
68
|
+
if (wsd.loadedQty > orderInventory.sortedQty) {
|
|
69
|
+
throw new Error('Load qty is more than sorted qty for sku ' + wsd.productSku)
|
|
70
|
+
} else if (wsd.loadedQty > orderInventory.pickedQty) {
|
|
71
|
+
throw new Error('Load qty is more than picked qty for sku ' + wsd.productSku)
|
|
72
|
+
} else if (wsd.loadedQty == orderInventory.releaseQty) {
|
|
73
|
+
//compare load qty to release, if order is partially picked, has to split oi
|
|
74
|
+
|
|
75
|
+
//update oi
|
|
76
|
+
orderInventory = {
|
|
77
|
+
...orderInventory,
|
|
78
|
+
status: ORDER_INVENTORY_STATUS.LOADED,
|
|
79
|
+
updater: user,
|
|
80
|
+
updatedAt: new Date()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//update wsd
|
|
84
|
+
await tx.getRepository(WorksheetDetail).update(foundWorksheetDetail.id, {
|
|
85
|
+
status: WORKSHEET_STATUS.DONE,
|
|
86
|
+
updater: user,
|
|
87
|
+
updatedAt: new Date()
|
|
88
|
+
})
|
|
89
|
+
} else if (wsd.loadedQty < orderInventory.releaseQty) {
|
|
90
|
+
//split oi
|
|
91
|
+
//create new order inventory with remaining quantity
|
|
92
|
+
const remainingQty = orderInventory.releaseQty - wsd.loadedQty
|
|
93
|
+
const newOrderInventory = tx.getRepository(OrderInventory).create({
|
|
94
|
+
...orderInventory,
|
|
95
|
+
id: undefined,
|
|
96
|
+
name: OrderNoGenerator.orderInventory(),
|
|
97
|
+
releaseQty: remainingQty,
|
|
98
|
+
releaseUomValue: (orderInventory.releaseUomValue / orderInventory.releaseQty) * remainingQty,
|
|
99
|
+
pickedQty: orderInventory.pickedQty - wsd.loadedQty,
|
|
100
|
+
sortedQty: orderInventory.sortedQty - wsd.loadedQty,
|
|
101
|
+
status: ORDER_INVENTORY_STATUS.LOADING,
|
|
102
|
+
updater: user,
|
|
103
|
+
updatedAt: new Date()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
await tx.getRepository(OrderInventory).save(newOrderInventory)
|
|
107
|
+
|
|
108
|
+
//create new worksheet detail for the new order inventory
|
|
109
|
+
const newWorksheetDetail = tx.getRepository(WorksheetDetail).create({
|
|
110
|
+
...foundWorksheetDetail,
|
|
111
|
+
id: undefined,
|
|
112
|
+
name: `LOAD-DETAIL-` + uuidv4(),
|
|
113
|
+
worksheet: worksheet,
|
|
114
|
+
targetInventory: newOrderInventory,
|
|
115
|
+
status: WORKSHEET_STATUS.EXECUTING,
|
|
116
|
+
updater: user,
|
|
117
|
+
updatedAt: new Date()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
await tx.getRepository(WorksheetDetail).save(newWorksheetDetail)
|
|
121
|
+
|
|
122
|
+
//update current order inventory to loaded with loaded quantity
|
|
123
|
+
orderInventory = {
|
|
124
|
+
...orderInventory,
|
|
125
|
+
status: ORDER_INVENTORY_STATUS.LOADED,
|
|
126
|
+
releaseUomValue: (orderInventory.releaseUomValue / orderInventory.releaseQty) * wsd.loadedQty,
|
|
127
|
+
releaseQty: wsd.loadedQty,
|
|
128
|
+
pickedQty: wsd.loadedQty,
|
|
129
|
+
sortedQty: wsd.loadedQty,
|
|
130
|
+
updater: user,
|
|
131
|
+
updatedAt: new Date()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//update current wsd
|
|
135
|
+
await tx.getRepository(WorksheetDetail).update(foundWorksheetDetail.id, {
|
|
136
|
+
status: WORKSHEET_STATUS.DONE,
|
|
137
|
+
updater: user,
|
|
138
|
+
updatedAt: new Date()
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const inventory = await tx.getRepository(Inventory).findOne({
|
|
143
|
+
where: { id: orderInventory.inventoryId }
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
// generate inventory history
|
|
147
|
+
await generateInventoryHistory(inventory, releaseGood, INVENTORY_TRANSACTION_TYPE.LOADING, 0, 0, user, tx)
|
|
148
|
+
updatedOrderInventories.push(orderInventory)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (updatedOrderInventories.length < 1) {
|
|
152
|
+
return false
|
|
153
|
+
} else {
|
|
154
|
+
const deliveryOrder: DeliveryOrderPatch = {
|
|
155
|
+
truckNo: worksheetDetailPatch?.vehicleNo,
|
|
156
|
+
ownCollection: worksheetDetailPatch?.ownCollection,
|
|
157
|
+
totalPalletQty: worksheetDetailPatch?.palletQty,
|
|
158
|
+
contactPointRefId: releaseGood.deliverTo?.id || null
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const createdDo = await generateDeliveryOrder(
|
|
162
|
+
deliveryOrder,
|
|
163
|
+
updatedOrderInventories,
|
|
164
|
+
releaseGood.bizplace,
|
|
165
|
+
releaseGood,
|
|
166
|
+
domain,
|
|
167
|
+
user,
|
|
168
|
+
tx
|
|
169
|
+
)
|
|
170
|
+
return true
|
|
171
|
+
}
|
|
172
|
+
} catch (e) {
|
|
173
|
+
throw e
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { EntityManager, getRepository, Not, Equal } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { Domain } from '@things-factory/shell'
|
|
4
|
+
import { ReleaseGood, ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
|
|
5
|
+
import { Worksheet, WorksheetDetail, WORKSHEET_TYPE, WORKSHEET_STATUS } from '@things-factory/worksheet-base'
|
|
6
|
+
import { User } from '@things-factory/auth-base'
|
|
7
|
+
|
|
8
|
+
export const loadingWorksheetv2 = {
|
|
9
|
+
async loadingWorksheetv2(_: any, { orderNo, filter = null }, context: any) {
|
|
10
|
+
const { domain, tx, user }: { domain: Domain; tx: EntityManager; user: User } = context.state
|
|
11
|
+
|
|
12
|
+
if (process.env.NODE_ENV == 'development') {
|
|
13
|
+
console.time('loadingWorksheetv2')
|
|
14
|
+
}
|
|
15
|
+
const releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
16
|
+
where: { domain, name: orderNo }
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
if (!releaseGood) throw new Error('Release good not found')
|
|
20
|
+
|
|
21
|
+
const worksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
22
|
+
where: {
|
|
23
|
+
domain,
|
|
24
|
+
releaseGood,
|
|
25
|
+
type: WORKSHEET_TYPE.LOADING,
|
|
26
|
+
status: 'EXECUTING'
|
|
27
|
+
},
|
|
28
|
+
relations: ['bizplace']
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
if (!worksheet) throw new Error('No loading worksheet found for order ' + orderNo)
|
|
32
|
+
|
|
33
|
+
const qb = tx
|
|
34
|
+
.getRepository(WorksheetDetail)
|
|
35
|
+
.createQueryBuilder('worksheetDetail')
|
|
36
|
+
.leftJoinAndSelect('worksheetDetail.targetInventory', 'targetInventory')
|
|
37
|
+
.leftJoinAndSelect('targetInventory.binLocation', 'binLocation')
|
|
38
|
+
.leftJoinAndSelect('targetInventory.product', 'product')
|
|
39
|
+
.leftJoinAndSelect('targetInventory.productDetail', 'productDetail')
|
|
40
|
+
.leftJoin('targetInventory.inventory', 'inventory')
|
|
41
|
+
.addSelect('inventory.expirationDate')
|
|
42
|
+
.where('worksheetDetail.domain_id = :domainId', { domainId: domain.id })
|
|
43
|
+
.andWhere('worksheetDetail.worksheet_id = :worksheetId', { worksheetId: worksheet.id })
|
|
44
|
+
|
|
45
|
+
const allWorksheetDetails: WorksheetDetail[] = await qb.getMany()
|
|
46
|
+
if (allWorksheetDetails.every(wsd => wsd.status == WORKSHEET_STATUS.DEACTIVATED)) {
|
|
47
|
+
throw new Error('Item in this RO is not ready to be loaded')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
qb.andWhere('targetInventory.status NOT IN (:...excludeStatuses)', {
|
|
51
|
+
excludeStatuses: [ORDER_INVENTORY_STATUS.TERMINATED, ORDER_INVENTORY_STATUS.RETURNING]
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
qb.andWhere('worksheetDetail.status IN (:...wsdStatus)', {
|
|
55
|
+
wsdStatus: [WORKSHEET_STATUS.EXECUTING]
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
if (filter && filter == 'qc') {
|
|
59
|
+
qb.andWhere('targetInventory.status = :loadingStatus', { loadingStatus: ORDER_INVENTORY_STATUS.LOADING })
|
|
60
|
+
qb.andWhere('targetInventory.sortedQty <> targetInventory.pickedQty')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (filter && filter == 'loading') {
|
|
64
|
+
qb.andWhere('targetInventory.sortedQty > 0')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
qb.orderBy('product.name', 'ASC')
|
|
68
|
+
|
|
69
|
+
const worksheetDetails = await qb.getMany()
|
|
70
|
+
console.timeEnd('loadingWorksheetv2')
|
|
71
|
+
return await mapdata(worksheet, worksheetDetails, releaseGood)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function mapdata(worksheet, worksheetDetails, releaseGood) {
|
|
76
|
+
const worksheetInfo = {
|
|
77
|
+
worksheet: {
|
|
78
|
+
id: worksheet.id,
|
|
79
|
+
name: worksheet.name,
|
|
80
|
+
type: worksheet.type,
|
|
81
|
+
status: worksheet.status
|
|
82
|
+
},
|
|
83
|
+
bizplaceName: worksheet.bizplace?.name,
|
|
84
|
+
startedAt: worksheet.startedAt ? new Date(worksheet.startedAt).toISOString().slice(0, 19).replace('T', ' ') : null,
|
|
85
|
+
releaseGood: {
|
|
86
|
+
id: releaseGood.id,
|
|
87
|
+
name: releaseGood.name,
|
|
88
|
+
status: releaseGood.status,
|
|
89
|
+
attentionCompany: releaseGood?.attentionCompany,
|
|
90
|
+
refNo: releaseGood?.refNo,
|
|
91
|
+
refNo2: releaseGood?.refNo2,
|
|
92
|
+
refNo3: releaseGood?.refNo3
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const worksheetDetailInfos = worksheetDetails.map(wsd => ({
|
|
96
|
+
id: wsd.id,
|
|
97
|
+
name: wsd.name,
|
|
98
|
+
batchId: wsd.targetInventory.batchId || '-',
|
|
99
|
+
releaseQty: wsd.targetInventory.releaseQty,
|
|
100
|
+
pickedQty: wsd.targetInventory.pickedQty,
|
|
101
|
+
sortedQty: wsd.targetInventory.sortedQty,
|
|
102
|
+
loadedQty: wsd.targetInventory.loadedQty,
|
|
103
|
+
status: wsd.status,
|
|
104
|
+
packingType: wsd.targetInventory.packingType,
|
|
105
|
+
packingSize: wsd.targetInventory.packingSize,
|
|
106
|
+
expirationDate: wsd.targetInventory?.inventory?.expirationDate,
|
|
107
|
+
binLocation: {
|
|
108
|
+
name: wsd.targetInventory.binLocation?.name
|
|
109
|
+
},
|
|
110
|
+
productName: wsd.targetInventory?.product?.name,
|
|
111
|
+
productSku: wsd.targetInventory?.product?.sku,
|
|
112
|
+
relatedOrderInv: {
|
|
113
|
+
id: wsd.targetInventory?.id,
|
|
114
|
+
batchId: wsd.targetInventory?.batchId || '-',
|
|
115
|
+
packingType: wsd.targetInventory?.packingType,
|
|
116
|
+
product: {
|
|
117
|
+
id: wsd.targetInventory?.product?.id,
|
|
118
|
+
sku: wsd.targetInventory?.product?.sku,
|
|
119
|
+
name: wsd.targetInventory?.product?.name
|
|
120
|
+
},
|
|
121
|
+
productDetail: {
|
|
122
|
+
id: wsd.targetInventory?.productDetail?.id
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}))
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
worksheetInfo,
|
|
129
|
+
worksheetDetailInfos
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getRepository, In } from 'typeorm'
|
|
2
|
+
import { User } from '@things-factory/auth-base'
|
|
3
|
+
import { Domain } from '@things-factory/shell'
|
|
4
|
+
import { Worksheet, WORKSHEET_STATUS, WORKSHEET_TYPE } from '@things-factory/worksheet-base'
|
|
5
|
+
import { ReleaseGood } from '@things-factory/sales-base'
|
|
6
|
+
|
|
7
|
+
export const myLoadingAssignmentStatus = {
|
|
8
|
+
async myLoadingAssignmentStatus(_parentObj: void, _params: void, context: any) {
|
|
9
|
+
const { domain, user }: { domain: Domain; user: User } = context.state
|
|
10
|
+
|
|
11
|
+
// Fetch Release Orders where sorter id = user id
|
|
12
|
+
const releaseOrders: ReleaseGood[] = await getRepository(ReleaseGood).find({
|
|
13
|
+
where: { domain, sortedBy: user }
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// Fetch Worksheets where type = loading and release good id is in the fetched release orders
|
|
17
|
+
const loadingWorksheets: Worksheet[] = await getRepository(Worksheet).find({
|
|
18
|
+
where: {
|
|
19
|
+
domain,
|
|
20
|
+
type: WORKSHEET_TYPE.LOADING,
|
|
21
|
+
releaseGood: In(releaseOrders.map(ro => ro.id)),
|
|
22
|
+
status: In([WORKSHEET_STATUS.DEACTIVATED, WORKSHEET_STATUS.EXECUTING])
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return (loadingWorksheets || []).reduce(
|
|
27
|
+
(assignmentStatus, worksheet: Worksheet) => {
|
|
28
|
+
if (worksheet.status === WORKSHEET_STATUS.DEACTIVATED) assignmentStatus.pending.push(worksheet)
|
|
29
|
+
if (worksheet.status === WORKSHEET_STATUS.EXECUTING) assignmentStatus.loading.push(worksheet)
|
|
30
|
+
return assignmentStatus
|
|
31
|
+
},
|
|
32
|
+
{ userId: user.id, pending: [], loading: [] }
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Domain } from '@things-factory/shell'
|
|
5
|
+
import { ORDER_INVENTORY_STATUS, ORDER_STATUS, ReleaseGood, OrderInventory } from '@things-factory/sales-base'
|
|
6
|
+
import { ProductDetail, ProductBarcode } from '@things-factory/product-base'
|
|
7
|
+
import { WorksheetController } from '@things-factory/worksheet-base'
|
|
8
|
+
|
|
9
|
+
export const sortItem = {
|
|
10
|
+
async sortItem(_: any, { releaseGoodNo, productBarcode, qty, worksheetDetails }, context: any) {
|
|
11
|
+
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
12
|
+
|
|
13
|
+
const releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
14
|
+
where: { domain, name: releaseGoodNo },
|
|
15
|
+
relations: ['orderInventories']
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
if (!releaseGood) {
|
|
19
|
+
throw new Error('Release good not found')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const orderInventories: OrderInventory[] = releaseGood.orderInventories
|
|
23
|
+
|
|
24
|
+
//fetch product, product detail
|
|
25
|
+
const productDetail: ProductDetail = await tx
|
|
26
|
+
.getRepository(ProductDetail)
|
|
27
|
+
.createQueryBuilder('pd')
|
|
28
|
+
.innerJoinAndSelect('pd.productBarcodes', 'pb')
|
|
29
|
+
.innerJoinAndSelect('pd.product', 'p')
|
|
30
|
+
.where('p.id In(:...productId)', { productId: orderInventories.map(oi => oi.productId) })
|
|
31
|
+
.andWhere('pd.id In(:...productDetailId)', { productDetailId: orderInventories.map(oi => oi.productDetailId) })
|
|
32
|
+
.andWhere('pb.gtin = :productBarcode', { productBarcode: productBarcode })
|
|
33
|
+
.getOne()
|
|
34
|
+
|
|
35
|
+
if (!productDetail) throw new Error('Product not found')
|
|
36
|
+
|
|
37
|
+
const product = productDetail.product
|
|
38
|
+
let matchedOrderInventories
|
|
39
|
+
|
|
40
|
+
if (worksheetDetails?.length > 0) {
|
|
41
|
+
//find the respective oi from item that user selected
|
|
42
|
+
let selectedOrderInventories = worksheetDetails.map(wsd => wsd.relatedOrderInv)
|
|
43
|
+
let id = selectedOrderInventories.map(oi => oi.id)
|
|
44
|
+
let foundOrderInventories = orderInventories.filter(oi => id.includes(oi.id))
|
|
45
|
+
matchedOrderInventories = foundOrderInventories.filter(
|
|
46
|
+
oi => oi.productId === product.id && oi.productDetailId === productDetail.id
|
|
47
|
+
)
|
|
48
|
+
} else {
|
|
49
|
+
matchedOrderInventories = orderInventories.filter(
|
|
50
|
+
oi => oi.productId === product.id && oi.productDetailId === productDetail.id
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (matchedOrderInventories.length > 1 && !worksheetDetails) {
|
|
55
|
+
throw new Error('Please select item to sort')
|
|
56
|
+
} else if (matchedOrderInventories.length > 1) {
|
|
57
|
+
throw new Error('This barcode matched multiple item')
|
|
58
|
+
} else if (matchedOrderInventories.length === 0) {
|
|
59
|
+
throw new Error('No matching item found')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let matchedOrderInventory = matchedOrderInventories[0]
|
|
63
|
+
|
|
64
|
+
let newSortQty = matchedOrderInventory.sortedQty + qty
|
|
65
|
+
|
|
66
|
+
if (newSortQty > matchedOrderInventory.releaseQty) {
|
|
67
|
+
throw new Error('Sort qty is more than release qty')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (newSortQty > matchedOrderInventory.pickedQty) {
|
|
71
|
+
throw new Error('Sort qty is more than picked qty')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//update oi sorted qty
|
|
75
|
+
await tx
|
|
76
|
+
.getRepository(OrderInventory)
|
|
77
|
+
.update(matchedOrderInventory.id, { sortedQty: parseInt(newSortQty), updatedAt: new Date(), updater: user })
|
|
78
|
+
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
import { DeliveryOrder, ReleaseGood, OrderInventory, ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
|
|
3
|
+
import { Domain } from '@things-factory/shell'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { generateInventoryHistory, Inventory, INVENTORY_TRANSACTION_TYPE } from '@things-factory/warehouse-base'
|
|
6
|
+
import { WorksheetDetail, WORKSHEET_TYPE, WORKSHEET_STATUS } from '@things-factory/worksheet-base'
|
|
7
|
+
|
|
8
|
+
export const undoLoad = {
|
|
9
|
+
async undoLoad(_: any, { doId }, context: any) {
|
|
10
|
+
const { domain, tx, user }: { domain: Domain; tx: EntityManager; user: User } = context.state
|
|
11
|
+
|
|
12
|
+
const deliveryOrder: DeliveryOrder = await tx.getRepository(DeliveryOrder).findOne({
|
|
13
|
+
where: { id: doId, domain },
|
|
14
|
+
relations: ['orderInventories', 'orderInventories.inventory', 'releaseGood', 'releaseGood.orderInventories']
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if (!deliveryOrder) {
|
|
18
|
+
throw new Error(`Delivery order not found`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const releaseGood = deliveryOrder.releaseGood
|
|
22
|
+
|
|
23
|
+
for (const doInventory of deliveryOrder.orderInventories) {
|
|
24
|
+
const worksheetDetail: WorksheetDetail = await tx.getRepository(WorksheetDetail).findOne({
|
|
25
|
+
where: { targetInventory: doInventory, type: WORKSHEET_TYPE.LOADING, status: WORKSHEET_STATUS.DONE }
|
|
26
|
+
})
|
|
27
|
+
//find if the oi is splitted and not yet loaded
|
|
28
|
+
const previousOi: OrderInventory = releaseGood.orderInventories.find(
|
|
29
|
+
roInventory =>
|
|
30
|
+
roInventory.id !== doInventory.id &&
|
|
31
|
+
roInventory.inventoryId === doInventory.inventoryId &&
|
|
32
|
+
roInventory.productId === doInventory.productId &&
|
|
33
|
+
roInventory.productDetailId === doInventory.productDetailId &&
|
|
34
|
+
roInventory.status === ORDER_INVENTORY_STATUS.PICKED
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
if (previousOi) {
|
|
38
|
+
//combine previously splitted oi
|
|
39
|
+
await tx.getRepository(OrderInventory).update(previousOi.id, {
|
|
40
|
+
releaseQty: previousOi.releaseQty + doInventory.releaseQty,
|
|
41
|
+
pickedQty: previousOi.pickedQty + doInventory.pickedQty,
|
|
42
|
+
sortedQty: previousOi.sortedQty + doInventory.sortedQty,
|
|
43
|
+
releaseUomValue: previousOi.releaseUomValue + doInventory.releaseUomValue,
|
|
44
|
+
updater: user,
|
|
45
|
+
updatedAt: new Date()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
//terminate splitted oi
|
|
49
|
+
await tx.getRepository(OrderInventory).update(doInventory.id, {
|
|
50
|
+
deliveryOrder: null,
|
|
51
|
+
status: ORDER_INVENTORY_STATUS.TERMINATED,
|
|
52
|
+
updatedAt: new Date(),
|
|
53
|
+
updater: user
|
|
54
|
+
})
|
|
55
|
+
//delete wsd
|
|
56
|
+
await tx.getRepository(WorksheetDetail).delete({ id: worksheetDetail.id, status: WORKSHEET_STATUS.DONE })
|
|
57
|
+
} else {
|
|
58
|
+
//undo oi and wsd
|
|
59
|
+
await tx.getRepository(OrderInventory).update(doInventory.id, {
|
|
60
|
+
deliveryOrder: null,
|
|
61
|
+
status: ORDER_INVENTORY_STATUS.PICKED,
|
|
62
|
+
loadedAt: null,
|
|
63
|
+
loadedByUser: null,
|
|
64
|
+
loadedBy: null,
|
|
65
|
+
updater: user
|
|
66
|
+
})
|
|
67
|
+
await tx.getRepository(WorksheetDetail).update(worksheetDetail.id, {
|
|
68
|
+
status: WORKSHEET_STATUS.EXECUTING,
|
|
69
|
+
updater: user,
|
|
70
|
+
updatedAt: new Date()
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//generate inventory history
|
|
75
|
+
let inventory: Inventory = doInventory.inventory
|
|
76
|
+
await generateInventoryHistory(inventory, releaseGood, INVENTORY_TRANSACTION_TYPE.UNDO_LOADING, 0, 0, this.user)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
await tx.getRepository(DeliveryOrder).delete(deliveryOrder.id)
|
|
80
|
+
|
|
81
|
+
return true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Domain } from '@things-factory/shell'
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
3
|
+
import { EntityManager, In } from 'typeorm'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { ReleaseGood, OrderInventory, ORDER_INVENTORY_STATUS, OrderNoGenerator } from '@things-factory/sales-base'
|
|
6
|
+
import { Worksheet, WorksheetDetail, WORKSHEET_TYPE, WORKSHEET_STATUS } from '@things-factory/worksheet-base'
|
|
7
|
+
|
|
8
|
+
export const warehouseReturn = {
|
|
9
|
+
//this function is used for zone picking warehouse return
|
|
10
|
+
//in this case, ro status will remain PROCESSING/PARTIAL_PROCESSING
|
|
11
|
+
async warehouseReturn(_: any, { releaseGoodNo, worksheetDetails }, context: any) {
|
|
12
|
+
const { domain, tx, user }: { domain: Domain; tx: EntityManager; user: User } = context.state
|
|
13
|
+
|
|
14
|
+
//find release order
|
|
15
|
+
const releaseOrder: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
16
|
+
where: { domain, name: releaseGoodNo }
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
if (!releaseOrder) {
|
|
20
|
+
throw new Error(`Release good not found`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const existingWorksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
24
|
+
where: { releaseGood: releaseOrder, type: WORKSHEET_TYPE.WAREHOUSE_RETURN }
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
if (existingWorksheet) {
|
|
28
|
+
throw new Error('Existing return worksheet exist for this order')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let orderInventories = worksheetDetails.map(wsd => wsd.relatedOrderInv)
|
|
32
|
+
|
|
33
|
+
//find order inventories
|
|
34
|
+
let foundOrderInventories: OrderInventory[] = await tx.getRepository(OrderInventory).find({
|
|
35
|
+
where: { domain, id: In(orderInventories.map(oi => oi.id)) },
|
|
36
|
+
relations: [
|
|
37
|
+
'inventory',
|
|
38
|
+
'domain',
|
|
39
|
+
'bizplace',
|
|
40
|
+
'releaseGood',
|
|
41
|
+
'product',
|
|
42
|
+
'productDetail',
|
|
43
|
+
'binLocation',
|
|
44
|
+
'orderProduct'
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
let completedLoadingWsdIds: string[] = []
|
|
49
|
+
|
|
50
|
+
let returnOrderInventories = foundOrderInventories.flatMap(oi => {
|
|
51
|
+
const matchingWorksheetDetail = worksheetDetails.find(wsd => wsd.relatedOrderInv.id === oi.id)
|
|
52
|
+
if (!matchingWorksheetDetail) return [oi]
|
|
53
|
+
|
|
54
|
+
if (matchingWorksheetDetail.returnQty < oi.releaseQty) {
|
|
55
|
+
const remainingOI = {
|
|
56
|
+
...oi,
|
|
57
|
+
id: undefined,
|
|
58
|
+
name: OrderNoGenerator.orderInventory(),
|
|
59
|
+
status: ORDER_INVENTORY_STATUS.RETURNING,
|
|
60
|
+
releaseQty: matchingWorksheetDetail.returnQty,
|
|
61
|
+
releaseUomValue: (oi.releaseUomValue / oi.releaseQty) * matchingWorksheetDetail.returnQty,
|
|
62
|
+
pickedQty: oi.pickedQty - matchingWorksheetDetail.returnQty,
|
|
63
|
+
sortedQty: oi.sortedQty - matchingWorksheetDetail.returnQty,
|
|
64
|
+
updatedAt: new Date(),
|
|
65
|
+
updater: user
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
oi.releaseQty = oi.releaseQty - matchingWorksheetDetail.returnQty
|
|
69
|
+
oi.releaseUomValue = oi.releaseUomValue - remainingOI.releaseUomValue
|
|
70
|
+
oi.pickedQty = oi.pickedQty - matchingWorksheetDetail.returnQty
|
|
71
|
+
oi.sortedQty = oi.sortedQty - matchingWorksheetDetail.returnQty
|
|
72
|
+
oi.updatedAt = new Date()
|
|
73
|
+
oi.updater = user
|
|
74
|
+
|
|
75
|
+
return [oi, remainingOI]
|
|
76
|
+
} else if (matchingWorksheetDetail.returnQty === oi.releaseQty) {
|
|
77
|
+
oi.status = ORDER_INVENTORY_STATUS.RETURNING
|
|
78
|
+
oi.updatedAt = new Date()
|
|
79
|
+
oi.updater = user
|
|
80
|
+
completedLoadingWsdIds.push(oi.id)
|
|
81
|
+
return [oi]
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
//update current loading wsd status to done
|
|
86
|
+
//for returnQty = releaseQty items
|
|
87
|
+
await tx.getRepository(WorksheetDetail).update(
|
|
88
|
+
{ targetInventory: In(completedLoadingWsdIds) },
|
|
89
|
+
{
|
|
90
|
+
status: WORKSHEET_STATUS.DONE,
|
|
91
|
+
updater: user,
|
|
92
|
+
updatedAt: new Date()
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
await tx.getRepository(OrderInventory).save(returnOrderInventories)
|
|
97
|
+
|
|
98
|
+
//generate worksheet
|
|
99
|
+
let returnWorksheet: Worksheet = {
|
|
100
|
+
name: `RETURN-${uuidv4()}`,
|
|
101
|
+
type: WORKSHEET_TYPE.WAREHOUSE_RETURN,
|
|
102
|
+
status: WORKSHEET_STATUS.DEACTIVATED,
|
|
103
|
+
createdAt: new Date(),
|
|
104
|
+
domain: releaseOrder.domainId,
|
|
105
|
+
bizplace: releaseOrder.bizplaceId,
|
|
106
|
+
releaseGood: releaseOrder,
|
|
107
|
+
creator: user
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await tx.getRepository(Worksheet).save(returnWorksheet)
|
|
111
|
+
|
|
112
|
+
//generate worksheet detail only for return order inventories
|
|
113
|
+
const returnWorksheetDetails = returnOrderInventories
|
|
114
|
+
.filter(oi => oi.status === ORDER_INVENTORY_STATUS.RETURNING)
|
|
115
|
+
.map(roi => ({
|
|
116
|
+
name: `RETURN-DETAIL-` + uuidv4(),
|
|
117
|
+
type: WORKSHEET_TYPE.WAREHOUSE_RETURN,
|
|
118
|
+
status: WORKSHEET_STATUS.DEACTIVATED,
|
|
119
|
+
createdAt: new Date(),
|
|
120
|
+
domain: domain,
|
|
121
|
+
bizplaceId: releaseOrder.bizplaceId,
|
|
122
|
+
worksheet: returnWorksheet,
|
|
123
|
+
targetInventory: roi,
|
|
124
|
+
creator: user
|
|
125
|
+
}))
|
|
126
|
+
|
|
127
|
+
await tx.getRepository(WorksheetDetail).save(returnWorksheetDetails)
|
|
128
|
+
}
|
|
129
|
+
}
|