@things-factory/operato-wms 6.1.83 → 6.1.85
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -39
- package/server/graphql/index.ts +0 -7
- package/server/graphql/resolvers/board-setting/board-settings.ts +0 -93
- package/server/graphql/resolvers/board-setting/index.ts +0 -5
- package/server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.ts +0 -92
- package/server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.ts +0 -147
- package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.ts +0 -135
- package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +0 -178
- package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +0 -123
- package/server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.ts +0 -36
- package/server/graphql/resolvers/custom/elccl/index.ts +0 -15
- package/server/graphql/resolvers/custom/kimeda/index.ts +0 -5
- package/server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.ts +0 -42
- package/server/graphql/resolvers/dashboard/arrival-notices-by-status.ts +0 -34
- package/server/graphql/resolvers/dashboard/collection-orders-by-status.ts +0 -24
- package/server/graphql/resolvers/dashboard/delivery-orders-by-status.ts +0 -24
- package/server/graphql/resolvers/dashboard/index.ts +0 -17
- package/server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts +0 -60
- package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +0 -126
- package/server/graphql/resolvers/dashboard/release-goods-by-status.ts +0 -34
- package/server/graphql/resolvers/dashboard/unit-inbounded-outbounded.ts +0 -61
- package/server/graphql/resolvers/index.ts +0 -24
- package/server/graphql/resolvers/inventory-comparison/index.ts +0 -5
- package/server/graphql/resolvers/inventory-comparison/inventory-comparison-list.ts +0 -101
- package/server/graphql/resolvers/opa-menu/index.ts +0 -5
- package/server/graphql/resolvers/opa-menu/opa-menus.ts +0 -77
- package/server/graphql/resolvers/other/add-release-good-products.ts +0 -413
- package/server/graphql/resolvers/other/index.ts +0 -10
- package/server/graphql/resolvers/other/page-settings.ts +0 -105
- package/server/graphql/resolvers/reports/costing-report.ts +0 -194
- package/server/graphql/resolvers/reports/inbound-order-details-report.ts +0 -216
- package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +0 -156
- package/server/graphql/resolvers/reports/index.ts +0 -18
- package/server/graphql/resolvers/reports/outbound-order-details-report.ts +0 -250
- package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +0 -159
- package/server/graphql/resolvers/reports/product-label-report.ts +0 -55
- package/server/graphql/resolvers/reports/release-inventory-report.ts +0 -201
- package/server/graphql/resolvers/shipping-provider/index.ts +0 -5
- package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +0 -18
- package/server/graphql/resolvers/warehouse-inventory-adjustment/index.ts +0 -5
- package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +0 -79
- package/server/graphql/types/board-setting/board-setting.ts +0 -10
- package/server/graphql/types/board-setting/index.ts +0 -6
- package/server/graphql/types/custom/elccl/elccl-daily-collection-report-list.ts +0 -8
- package/server/graphql/types/custom/elccl/elccl-daily-collection-report.ts +0 -24
- package/server/graphql/types/custom/elccl/elccl-daily-order-inventory-report-list.ts +0 -8
- package/server/graphql/types/custom/elccl/elccl-daily-order-inventory-report.ts +0 -19
- package/server/graphql/types/custom/elccl/elccl-inventory-report.ts +0 -16
- package/server/graphql/types/custom/elccl/elccl-inventory-summary-report-list.ts +0 -8
- package/server/graphql/types/custom/elccl/elccl-inventory-summary-report.ts +0 -17
- package/server/graphql/types/custom/elccl/elccl-pallet-detail-report.ts +0 -16
- package/server/graphql/types/custom/elccl/index.ts +0 -28
- package/server/graphql/types/custom/kimeda/index.ts +0 -3
- package/server/graphql/types/dashboard/index.ts +0 -14
- package/server/graphql/types/dashboard/inventory-expiry-counter.ts +0 -9
- package/server/graphql/types/dashboard/inventory-expiry-status.ts +0 -8
- package/server/graphql/types/dashboard/order-status-counter.ts +0 -8
- package/server/graphql/types/index.ts +0 -38
- package/server/graphql/types/inventory-comparison/index.ts +0 -11
- package/server/graphql/types/inventory-comparison/inventory-comparison-list.ts +0 -8
- package/server/graphql/types/inventory-comparison/inventory-comparison.ts +0 -12
- package/server/graphql/types/opa-menu/index.ts +0 -6
- package/server/graphql/types/opa-menu/opa-menu.ts +0 -39
- package/server/graphql/types/other/index.ts +0 -19
- package/server/graphql/types/other/page-setting.ts +0 -33
- package/server/graphql/types/reports/costing-report-list.ts +0 -8
- package/server/graphql/types/reports/costing-report.ts +0 -13
- package/server/graphql/types/reports/inbound-order-details-report-list.ts +0 -8
- package/server/graphql/types/reports/inbound-order-details-report.ts +0 -53
- package/server/graphql/types/reports/inbound-serial-number-report-list.ts +0 -8
- package/server/graphql/types/reports/inbound-serial-number-report.ts +0 -17
- package/server/graphql/types/reports/index.ts +0 -43
- package/server/graphql/types/reports/outbound-order-details-report-list.ts +0 -8
- package/server/graphql/types/reports/outbound-order-details-report.ts +0 -70
- package/server/graphql/types/reports/outbound-serial-number-report-list.ts +0 -8
- package/server/graphql/types/reports/outbound-serial-number-report.ts +0 -19
- package/server/graphql/types/reports/product-label-report-list.ts +0 -8
- package/server/graphql/types/reports/product-label-report.ts +0 -10
- package/server/graphql/types/reports/release-inventory-report-list.ts +0 -8
- package/server/graphql/types/reports/release-inventory-report.ts +0 -23
- package/server/graphql/types/shipping-provider/index.ts +0 -8
- package/server/graphql/types/shipping-provider/shipping-provider-list.ts +0 -7
- package/server/graphql/types/shipping-provider/shipping-provider.ts +0 -7
- package/server/graphql/types/warehouse-inventory-adjustment/index.ts +0 -5
- package/server/index.ts +0 -4
- package/server/migrations/1568858861188-SeedSetting.ts +0 -57
- package/server/migrations/1623308919899-SeedLocationRecommendSetting.ts +0 -35
- package/server/migrations/1623381200659-SeedStoringRule.ts +0 -33
- package/server/migrations/index.ts +0 -9
- package/server/opa-app-setting-constants.ts +0 -9
- package/server/routes.ts +0 -1
- package/server/utils/index.ts +0 -1
- package/server/utils/report-query-util.ts +0 -47
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
import { In, Not } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
4
|
-
import { Product } from '@things-factory/product-base'
|
|
5
|
-
import {
|
|
6
|
-
ORDER_INVENTORY_STATUS,
|
|
7
|
-
ORDER_PRODUCT_STATUS,
|
|
8
|
-
OrderInventory,
|
|
9
|
-
OrderNoGenerator,
|
|
10
|
-
OrderProduct,
|
|
11
|
-
ReleaseGood
|
|
12
|
-
} from '@things-factory/sales-base'
|
|
13
|
-
import { Inventory } from '@things-factory/warehouse-base'
|
|
14
|
-
import {
|
|
15
|
-
generatePickingWorksheetDetail,
|
|
16
|
-
Worksheet,
|
|
17
|
-
WORKSHEET_STATUS,
|
|
18
|
-
WORKSHEET_TYPE,
|
|
19
|
-
WorksheetDetail
|
|
20
|
-
} from '@things-factory/worksheet-base'
|
|
21
|
-
|
|
22
|
-
export const addReleaseGoodProducts = {
|
|
23
|
-
async addReleaseGoodProducts(_: any, { name, orderInventories, existingOrderInventories }, context: ResolverContext) {
|
|
24
|
-
try {
|
|
25
|
-
const { tx, user, domain } = context.state
|
|
26
|
-
|
|
27
|
-
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
28
|
-
where: { domain: { id: domain.id }, name: name },
|
|
29
|
-
relations: ['bizplace', 'orderProducts']
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const bizplace: Bizplace = releaseGood.bizplace
|
|
33
|
-
|
|
34
|
-
let pickingWorksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
35
|
-
where: { releaseGood, type: WORKSHEET_TYPE.PICKING }
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
let loadingWorksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
39
|
-
where: { releaseGood, type: WORKSHEET_TYPE.LOADING }
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
if (existingOrderInventories) {
|
|
43
|
-
for (let oi of existingOrderInventories) {
|
|
44
|
-
// map input to OrderInventory Object
|
|
45
|
-
let curOrderInv: OrderInventory = Object.assign({}, oi)
|
|
46
|
-
curOrderInv.domain = domain
|
|
47
|
-
curOrderInv.bizplace = bizplace
|
|
48
|
-
curOrderInv.releaseGood = releaseGood
|
|
49
|
-
curOrderInv.product = await tx.getRepository(Product).findOneBy({ id: oi.product.id })
|
|
50
|
-
|
|
51
|
-
let existingOrderInv: OrderInventory
|
|
52
|
-
|
|
53
|
-
if (curOrderInv?.inventory?.id) {
|
|
54
|
-
const foundInv: Inventory = await tx.getRepository(Inventory).findOneBy({ id: curOrderInv.inventory.id })
|
|
55
|
-
curOrderInv.inventory = foundInv
|
|
56
|
-
|
|
57
|
-
existingOrderInv = await tx.getRepository(OrderInventory).findOne({
|
|
58
|
-
where: {
|
|
59
|
-
releaseGood,
|
|
60
|
-
product: curOrderInv.product,
|
|
61
|
-
batchId: curOrderInv.batchId,
|
|
62
|
-
packingType: curOrderInv.packingType,
|
|
63
|
-
inventory: foundInv
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (foundInv && foundInv.lockedQty == 0) {
|
|
68
|
-
foundInv.qty += Number(existingOrderInv.releaseQty)
|
|
69
|
-
foundInv.uomValue += Number(existingOrderInv.releaseUomValue)
|
|
70
|
-
foundInv.lockedQty = Number(existingOrderInv.releaseQty)
|
|
71
|
-
foundInv.lockedUomValue = Number(existingOrderInv.releaseUomValue)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (curOrderInv.releaseQty < existingOrderInv.pickedQty) {
|
|
75
|
-
throw new Error(`${curOrderInv.inventory.palletId} has already picked ${existingOrderInv.pickedQty}`)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (curOrderInv.releaseQty === 0) {
|
|
79
|
-
foundInv.lockedQty = Number(foundInv.lockedQty) - Number(existingOrderInv.releaseQty)
|
|
80
|
-
foundInv.lockedUomValue = Number(foundInv.lockedUomValue) - Number(existingOrderInv.releaseUomValue)
|
|
81
|
-
|
|
82
|
-
await tx.getRepository(Inventory).save(foundInv)
|
|
83
|
-
|
|
84
|
-
if (existingOrderInv) {
|
|
85
|
-
// if found existing OrderInventory and worksheetDetail then qty, uomValue, and status are updated
|
|
86
|
-
curOrderInv = {
|
|
87
|
-
...existingOrderInv,
|
|
88
|
-
releaseQty: curOrderInv.releaseQty,
|
|
89
|
-
releaseUomValue: curOrderInv.releaseUomValue,
|
|
90
|
-
lockedUomValue: curOrderInv.lockedUomValue,
|
|
91
|
-
status: ORDER_INVENTORY_STATUS.CANCELLED
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let existingWorksheetDetail: WorksheetDetail = await tx.getRepository(WorksheetDetail).findOne({
|
|
95
|
-
where: {
|
|
96
|
-
worksheet: { id: pickingWorksheet.id },
|
|
97
|
-
type: WORKSHEET_TYPE.PICKING,
|
|
98
|
-
targetInventory: { id: curOrderInv.id }
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
existingWorksheetDetail = {
|
|
103
|
-
...existingWorksheetDetail,
|
|
104
|
-
status: WORKSHEET_STATUS.CANCELLED
|
|
105
|
-
}
|
|
106
|
-
await tx.getRepository(WorksheetDetail).save(existingWorksheetDetail)
|
|
107
|
-
await tx.getRepository(OrderInventory).save(curOrderInv)
|
|
108
|
-
}
|
|
109
|
-
} else if (curOrderInv.releaseQty == existingOrderInv.pickedQty) {
|
|
110
|
-
curOrderInv = {
|
|
111
|
-
...existingOrderInv,
|
|
112
|
-
releaseQty: curOrderInv.releaseQty,
|
|
113
|
-
releaseUomValue: curOrderInv.releaseUomValue,
|
|
114
|
-
lockedUomValue: curOrderInv.lockedUomValue,
|
|
115
|
-
status: ORDER_INVENTORY_STATUS.PICKED
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let existingWorksheetDetail: WorksheetDetail = await tx.getRepository(WorksheetDetail).findOne({
|
|
119
|
-
where: {
|
|
120
|
-
targetInventory: { id: curOrderInv.id }
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
existingWorksheetDetail = {
|
|
125
|
-
...existingWorksheetDetail,
|
|
126
|
-
status: WORKSHEET_STATUS.PICKED
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
await tx.getRepository(WorksheetDetail).save(existingWorksheetDetail)
|
|
130
|
-
await tx.getRepository(OrderInventory).save(curOrderInv)
|
|
131
|
-
} else {
|
|
132
|
-
foundInv.updater = user
|
|
133
|
-
foundInv.lockedQty =
|
|
134
|
-
foundInv.lockedQty - Number(existingOrderInv.releaseQty) + Number(curOrderInv.releaseQty)
|
|
135
|
-
foundInv.lockedUomValue =
|
|
136
|
-
foundInv.lockedUomValue - Number(existingOrderInv.releaseUomValue) + Number(curOrderInv.releaseUomValue)
|
|
137
|
-
|
|
138
|
-
await tx.getRepository(Inventory).save(foundInv)
|
|
139
|
-
|
|
140
|
-
if (existingOrderInv) {
|
|
141
|
-
// if found existing OrderInventory and worksheetDetail then qty, uomValue, and status are updated
|
|
142
|
-
curOrderInv = {
|
|
143
|
-
...existingOrderInv,
|
|
144
|
-
releaseQty: curOrderInv.releaseQty,
|
|
145
|
-
releaseUomValue: curOrderInv.releaseUomValue,
|
|
146
|
-
status: ORDER_INVENTORY_STATUS.PICKING
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
let existingWorksheetDetail: WorksheetDetail = await tx.getRepository(WorksheetDetail).findOne({
|
|
150
|
-
where: {
|
|
151
|
-
worksheet: { id: pickingWorksheet.id },
|
|
152
|
-
type: WORKSHEET_TYPE.PICKING,
|
|
153
|
-
targetInventory: { id: existingOrderInv.id }
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
if (existingWorksheetDetail) {
|
|
158
|
-
if (curOrderInv.releaseQty != existingOrderInv.releaseQty) {
|
|
159
|
-
existingWorksheetDetail = {
|
|
160
|
-
...existingWorksheetDetail,
|
|
161
|
-
status: WORKSHEET_STATUS.DEACTIVATED
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
await tx.getRepository(WorksheetDetail).save(existingWorksheetDetail)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
await tx.getRepository(OrderInventory).save(curOrderInv)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (pickingWorksheet) {
|
|
173
|
-
// if has picking worksheet, status will be deactivated to prevent any action from warehouse operator until office admin has confirmation
|
|
174
|
-
pickingWorksheet = {
|
|
175
|
-
...pickingWorksheet,
|
|
176
|
-
status: WORKSHEET_STATUS.DEACTIVATED
|
|
177
|
-
}
|
|
178
|
-
await tx.getRepository(Worksheet).save(pickingWorksheet)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (loadingWorksheet) {
|
|
182
|
-
// if has loading worksheet, status will be deactivated to prevent any action from warehouse operator until office admin has confirmation
|
|
183
|
-
loadingWorksheet = {
|
|
184
|
-
...loadingWorksheet,
|
|
185
|
-
status: WORKSHEET_STATUS.DEACTIVATED
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
await tx.getRepository(Worksheet).save(loadingWorksheet)
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (orderInventories) {
|
|
195
|
-
for (let oi of orderInventories) {
|
|
196
|
-
// map input to OrderInventory Object
|
|
197
|
-
let newOrderInv: OrderInventory = Object.assign({}, oi)
|
|
198
|
-
newOrderInv.domain = domain
|
|
199
|
-
newOrderInv.bizplace = bizplace
|
|
200
|
-
newOrderInv.batchId = oi.batchId
|
|
201
|
-
newOrderInv.packingType = oi.packingType
|
|
202
|
-
newOrderInv.status = pickingWorksheet ? ORDER_INVENTORY_STATUS.PICKING : ORDER_INVENTORY_STATUS.PENDING
|
|
203
|
-
newOrderInv.name = OrderNoGenerator.orderInventory()
|
|
204
|
-
newOrderInv.releaseGood = releaseGood
|
|
205
|
-
newOrderInv.product = await tx.getRepository(Product).findOneBy({ id: oi.product.id })
|
|
206
|
-
newOrderInv.creator = user
|
|
207
|
-
newOrderInv.updater = user
|
|
208
|
-
|
|
209
|
-
let existingOrderInv: OrderInventory
|
|
210
|
-
|
|
211
|
-
let existingOrderProduct: OrderProduct = await tx.getRepository(OrderProduct).findOne({
|
|
212
|
-
where: {
|
|
213
|
-
domain: { id: domain.id },
|
|
214
|
-
releaseGood: { id: releaseGood.id },
|
|
215
|
-
batchId: oi.batchId,
|
|
216
|
-
packingType: oi.packingType,
|
|
217
|
-
product: { id: newOrderInv.product.id }
|
|
218
|
-
}
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
// check if it is release by inventory (has inventory value) or product
|
|
222
|
-
if (newOrderInv.inventory?.id) {
|
|
223
|
-
// if release by inventory, then quantity and uomValue values are updated
|
|
224
|
-
const foundInv: Inventory = await tx.getRepository(Inventory).findOneBy({ id: newOrderInv.inventory.id })
|
|
225
|
-
newOrderInv.inventory = foundInv
|
|
226
|
-
newOrderInv.uom = oi?.uom || foundInv.uom
|
|
227
|
-
newOrderInv.batchIdRef = oi?.batchIdRef || foundInv.batchIdRef
|
|
228
|
-
|
|
229
|
-
// check for existing released OrderInventory specifying product, batchId, packingType, and inventory
|
|
230
|
-
existingOrderInv = await tx.getRepository(OrderInventory).findOne({
|
|
231
|
-
where: {
|
|
232
|
-
releaseGood: { id: releaseGood.id },
|
|
233
|
-
product: { id: newOrderInv.product.id },
|
|
234
|
-
batchId: newOrderInv.batchId,
|
|
235
|
-
packingType: newOrderInv.packingType,
|
|
236
|
-
inventory: { id: foundInv.id }
|
|
237
|
-
}
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
foundInv.lockedQty = Number(foundInv.lockedQty) + newOrderInv.releaseQty
|
|
241
|
-
foundInv.lockedUomValue = Number(foundInv.lockedUomValue) + newOrderInv.releaseUomValue
|
|
242
|
-
foundInv.updater = user
|
|
243
|
-
|
|
244
|
-
let newOrderProduct: OrderProduct = Object.assign(new OrderProduct(), newOrderInv)
|
|
245
|
-
newOrderProduct = {
|
|
246
|
-
...newOrderProduct,
|
|
247
|
-
packQty: 0,
|
|
248
|
-
actualPackQty: 0,
|
|
249
|
-
palletQty: 0,
|
|
250
|
-
actualPalletQty: 0,
|
|
251
|
-
status: ORDER_PRODUCT_STATUS.ASSIGNED
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (!existingOrderProduct) newOrderProduct = await tx.getRepository(OrderProduct).save(newOrderProduct)
|
|
255
|
-
|
|
256
|
-
newOrderInv.orderProduct = existingOrderProduct ? existingOrderProduct : newOrderProduct
|
|
257
|
-
|
|
258
|
-
await tx.getRepository(Inventory).save(foundInv)
|
|
259
|
-
} else {
|
|
260
|
-
// check for existing released OrderInventory specifying product, batchId and packingType
|
|
261
|
-
existingOrderInv = await tx.getRepository(OrderInventory).findOne({
|
|
262
|
-
where: {
|
|
263
|
-
releaseGood: { id: releaseGood.id },
|
|
264
|
-
product: { id: newOrderInv.product.id },
|
|
265
|
-
batchId: newOrderInv.batchId,
|
|
266
|
-
packingType: newOrderInv.packingType
|
|
267
|
-
}
|
|
268
|
-
})
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (existingOrderInv) {
|
|
272
|
-
// if found existing OrderInventory and worksheetDetail then qty, uomValue, and status are updated
|
|
273
|
-
newOrderInv = {
|
|
274
|
-
...existingOrderInv,
|
|
275
|
-
releaseQty:
|
|
276
|
-
existingOrderInv.status === ORDER_INVENTORY_STATUS.REPLACED
|
|
277
|
-
? newOrderInv.releaseQty
|
|
278
|
-
: existingOrderInv.releaseQty + newOrderInv.releaseQty,
|
|
279
|
-
releaseUomValue: ORDER_INVENTORY_STATUS.REPLACED
|
|
280
|
-
? newOrderInv.releaseUomValue
|
|
281
|
-
: existingOrderInv.releaseUomValue + newOrderInv.releaseUomValue,
|
|
282
|
-
status:
|
|
283
|
-
existingOrderInv.status === ORDER_INVENTORY_STATUS.CANCELLED
|
|
284
|
-
? pickingWorksheet
|
|
285
|
-
? ORDER_INVENTORY_STATUS.PICKING
|
|
286
|
-
: ORDER_INVENTORY_STATUS.PENDING
|
|
287
|
-
: existingOrderInv.status
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
let existingWorksheetDetail: WorksheetDetail = await tx.getRepository(WorksheetDetail).findOne({
|
|
291
|
-
where: {
|
|
292
|
-
worksheet: { id: pickingWorksheet.id },
|
|
293
|
-
type: WORKSHEET_TYPE.PICKING,
|
|
294
|
-
targetInventory: { id: existingOrderInv.id }
|
|
295
|
-
}
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
if (existingWorksheetDetail) {
|
|
299
|
-
existingWorksheetDetail = {
|
|
300
|
-
...existingWorksheetDetail,
|
|
301
|
-
targetProduct: newOrderInv.orderProduct,
|
|
302
|
-
status: WORKSHEET_STATUS.DEACTIVATED
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
await tx.getRepository(WorksheetDetail).save(existingWorksheetDetail)
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (pickingWorksheet) {
|
|
310
|
-
// if has picking worksheet, status will be deactivated to prevent any action from warehouse operator until office admin has confirmation
|
|
311
|
-
pickingWorksheet = {
|
|
312
|
-
...pickingWorksheet,
|
|
313
|
-
status: WORKSHEET_STATUS.DEACTIVATED
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
let savedOrderInv: OrderInventory = new OrderInventory()
|
|
317
|
-
savedOrderInv.name = newOrderInv.name
|
|
318
|
-
savedOrderInv.type = newOrderInv.type
|
|
319
|
-
savedOrderInv.releaseQty = newOrderInv.releaseQty
|
|
320
|
-
savedOrderInv.releaseUomValue = newOrderInv.releaseUomValue
|
|
321
|
-
savedOrderInv.batchId = newOrderInv.batchId
|
|
322
|
-
savedOrderInv.batchIdRef = newOrderInv.batchIdRef
|
|
323
|
-
savedOrderInv.packingType = newOrderInv.packingType
|
|
324
|
-
savedOrderInv.uom = newOrderInv.uom
|
|
325
|
-
savedOrderInv.product = newOrderInv.product
|
|
326
|
-
savedOrderInv.inventory = newOrderInv.inventory
|
|
327
|
-
savedOrderInv.status = newOrderInv.status
|
|
328
|
-
savedOrderInv.releaseGood = newOrderInv.releaseGood
|
|
329
|
-
savedOrderInv.orderProduct = newOrderInv.orderProduct
|
|
330
|
-
savedOrderInv.bizplace = newOrderInv.bizplace
|
|
331
|
-
savedOrderInv.domain = domain
|
|
332
|
-
savedOrderInv.creator = user
|
|
333
|
-
savedOrderInv.updater = user
|
|
334
|
-
|
|
335
|
-
if (newOrderInv?.id) {
|
|
336
|
-
// newOrderInv will have id if it was updated from existingOrderInv
|
|
337
|
-
// this solution will remove ix_order-inventory_0 unique error
|
|
338
|
-
// ** please revise this resolver in future. looks like there's few
|
|
339
|
-
// things that can refactor
|
|
340
|
-
savedOrderInv.id = newOrderInv.id
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
savedOrderInv = await tx.getRepository(OrderInventory).save(savedOrderInv)
|
|
344
|
-
|
|
345
|
-
if (!existingOrderInv && pickingWorksheet) {
|
|
346
|
-
// if this is a new orderInventory and has existing worksheet then generate a new worksheet detail for it
|
|
347
|
-
await generatePickingWorksheetDetail(tx, domain, user, pickingWorksheet, savedOrderInv)
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
await tx.getRepository(Worksheet).save(pickingWorksheet)
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (loadingWorksheet) {
|
|
356
|
-
// if has loading worksheet, status will be deactivated to prevent any action from warehouse operator until office admin has confirmation
|
|
357
|
-
loadingWorksheet = {
|
|
358
|
-
...loadingWorksheet,
|
|
359
|
-
status: WORKSHEET_STATUS.DEACTIVATED
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
await tx.getRepository(Worksheet).save(loadingWorksheet)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Update Order Product Release Qty
|
|
366
|
-
let rgOrderProducts: OrderProduct[] = await tx
|
|
367
|
-
.getRepository(OrderProduct)
|
|
368
|
-
.find({ where: { domain: { id: domain.id }, releaseGood: { id: releaseGood.id } } })
|
|
369
|
-
|
|
370
|
-
await Promise.all(
|
|
371
|
-
rgOrderProducts.map(async op => {
|
|
372
|
-
const orderInventories: OrderInventory[] = await tx.getRepository(OrderInventory).find({
|
|
373
|
-
where: {
|
|
374
|
-
domain: { id: domain.id },
|
|
375
|
-
releaseGood: { id: releaseGood.id },
|
|
376
|
-
orderProduct: { id: op.id },
|
|
377
|
-
status: Not(
|
|
378
|
-
In([
|
|
379
|
-
ORDER_INVENTORY_STATUS.TERMINATED,
|
|
380
|
-
ORDER_INVENTORY_STATUS.CANCELLED,
|
|
381
|
-
ORDER_INVENTORY_STATUS.PENDING_CANCEL
|
|
382
|
-
])
|
|
383
|
-
)
|
|
384
|
-
}
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
let totalReleaseQty: number = orderInventories.reduce((total, currentValue) => {
|
|
388
|
-
total += currentValue.releaseQty
|
|
389
|
-
return total
|
|
390
|
-
}, 0)
|
|
391
|
-
|
|
392
|
-
let totalReleaseUomValue: number = orderInventories.reduce((total, currentValue) => {
|
|
393
|
-
total += currentValue.releaseUomValue
|
|
394
|
-
return total
|
|
395
|
-
}, 0)
|
|
396
|
-
|
|
397
|
-
let updateOPInfo: any = {
|
|
398
|
-
releaseQty: totalReleaseQty,
|
|
399
|
-
releaseUomValue: totalReleaseUomValue
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (totalReleaseQty <= 0) {
|
|
403
|
-
updateOPInfo.status = ORDER_PRODUCT_STATUS.TERMINATED
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
await tx.getRepository(OrderProduct).update({ id: op.id }, updateOPInfo)
|
|
407
|
-
})
|
|
408
|
-
)
|
|
409
|
-
} catch (error) {
|
|
410
|
-
throw error
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { getRepository, EntityManager, In } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { Sequence, SEQUENCE_TYPE } from '@things-factory/id-rule-base'
|
|
4
|
-
import { buildQuery, Domain, ListParam, convertListParams } from '@things-factory/shell'
|
|
5
|
-
import { User } from '@things-factory/auth-base'
|
|
6
|
-
import {
|
|
7
|
-
getMyBizplace,
|
|
8
|
-
getPartnerBizplaceIds,
|
|
9
|
-
getPartnersBizplaces,
|
|
10
|
-
getPartnersCompanyBizplaces,
|
|
11
|
-
getPermittedBizplaceIds,
|
|
12
|
-
Bizplace
|
|
13
|
-
} from '@things-factory/biz-base'
|
|
14
|
-
|
|
15
|
-
import { CommonCode as CommonCodeEntity, CommonCodeDetail as CommonCodeDetailEntity } from '@things-factory/code-base'
|
|
16
|
-
|
|
17
|
-
export const pageSettings = {
|
|
18
|
-
async pageSettings(_: any, { codes, partners }, context: any) {
|
|
19
|
-
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
20
|
-
try {
|
|
21
|
-
let promiseTask = []
|
|
22
|
-
if (codes) {
|
|
23
|
-
promiseTask.push(queryCommonCode(codes, domain, tx, context))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (partners) {
|
|
27
|
-
promiseTask.push(queryPartners(partners, domain, tx, context))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return await Promise.all(promiseTask)
|
|
31
|
-
} catch (error) {
|
|
32
|
-
throw error
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function queryCommonCode(codes, domain, tx, context) {
|
|
38
|
-
const codeQb = tx.getRepository(CommonCodeEntity).createQueryBuilder('cc')
|
|
39
|
-
buildQuery(codeQb, { filters: codes }, context)
|
|
40
|
-
|
|
41
|
-
codes = (await codeQb
|
|
42
|
-
.leftJoinAndSelect('cc.details', 'ccdet')
|
|
43
|
-
.orderBy('cc.name')
|
|
44
|
-
.addOrderBy('ccdet.rank')
|
|
45
|
-
.addOrderBy('ccdet.name')
|
|
46
|
-
.getMany()).map((cc: CommonCodeEntity) => {
|
|
47
|
-
return {
|
|
48
|
-
id: cc.id,
|
|
49
|
-
name: cc.name,
|
|
50
|
-
description: cc.description,
|
|
51
|
-
settingDetails: cc.details.map(det => {
|
|
52
|
-
return {
|
|
53
|
-
id: det.id,
|
|
54
|
-
name: det.name,
|
|
55
|
-
description: det.description,
|
|
56
|
-
rank: det.rank
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
type: 'code',
|
|
64
|
-
details: codes
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function queryPartners(partners, domain, tx, context) {
|
|
69
|
-
let partnersBizplaceIds = []
|
|
70
|
-
let bizplaceIndex: any = partners.filters?.findIndex(x => x.name === 'bizplace')
|
|
71
|
-
if (bizplaceIndex && bizplaceIndex > -1) {
|
|
72
|
-
partnersBizplaceIds = partners.filters
|
|
73
|
-
.filter(x => x.name === 'bizplace')
|
|
74
|
-
.map(item => {
|
|
75
|
-
return item.value
|
|
76
|
-
})
|
|
77
|
-
partners.filters.splice(bizplaceIndex, 1)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const convertedParams = convertListParams({ filters: partners })
|
|
81
|
-
|
|
82
|
-
if (!(partnersBizplaceIds.length > 0)) {
|
|
83
|
-
const partnersBizplaces: Bizplace[] = await getPartnersBizplaces(context.state.domain, context.state.user)
|
|
84
|
-
partnersBizplaceIds = partnersBizplaces.map((bizplace: Bizplace) => bizplace.id || null)
|
|
85
|
-
convertedParams.where.id = In(partnersBizplaceIds)
|
|
86
|
-
} else {
|
|
87
|
-
convertedParams.where.id = In(partnersBizplaceIds)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
partners = ((await tx.getRepository(Bizplace).find({
|
|
91
|
-
...convertedParams,
|
|
92
|
-
relations: ['domain', 'company', 'users', 'creator', 'updater']
|
|
93
|
-
})).map((biz: Bizplace) => {
|
|
94
|
-
return {
|
|
95
|
-
id: biz.id,
|
|
96
|
-
name: biz.name,
|
|
97
|
-
description: biz.description,
|
|
98
|
-
}
|
|
99
|
-
}))
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
type: 'partner',
|
|
103
|
-
details: partners
|
|
104
|
-
}
|
|
105
|
-
}
|