@things-factory/worksheet-base 4.3.211 → 4.3.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js +11 -9
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +77 -98
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +28 -8
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +4 -2
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/putaway.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway-worksheet.js +86 -49
- package/dist-server/graphql/resolvers/worksheet/putaway-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/unload.js +5 -3
- package/dist-server/graphql/resolvers/worksheet/unloading/unload.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-worksheet.js +84 -74
- package/dist-server/graphql/resolvers/worksheet/unloading-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +116 -0
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +10 -4
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +4 -0
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
- package/dist-server/utils/lmd-util.js +24 -8
- package/dist-server/utils/lmd-util.js.map +1 -1
- package/package.json +8 -8
- package/server/controllers/inbound/putaway-worksheet-controller.ts +12 -9
- package/server/controllers/inbound/unloading-worksheet-controller.ts +150 -130
- package/server/controllers/worksheet-controller.ts +28 -8
- package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +6 -2
- package/server/graphql/resolvers/worksheet/putaway/putaway.ts +5 -1
- package/server/graphql/resolvers/worksheet/putaway-worksheet.ts +92 -46
- package/server/graphql/resolvers/worksheet/unloading/unload.ts +8 -4
- package/server/graphql/resolvers/worksheet/unloading-worksheet.ts +100 -82
- package/server/graphql/resolvers/worksheet/worksheet.ts +134 -0
- package/server/graphql/types/worksheet/index.ts +11 -5
- package/server/graphql/types/worksheet/worksheet-detail-info.ts +4 -0
- package/server/utils/lmd-util.ts +38 -26
|
@@ -81,7 +81,11 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
async unload(
|
|
84
|
+
async unload(
|
|
85
|
+
worksheetDetailName: string,
|
|
86
|
+
inventory: Partial<Inventory>,
|
|
87
|
+
productBarcode: string
|
|
88
|
+
): Promise<string> {
|
|
85
89
|
const worksheetDetail: WorksheetDetail = await this.trxMgr.getRepository(WorksheetDetail).findOne({
|
|
86
90
|
where: {
|
|
87
91
|
name: worksheetDetailName,
|
|
@@ -97,73 +101,73 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
97
101
|
'targetProduct',
|
|
98
102
|
'targetProduct.product',
|
|
99
103
|
'targetProduct.productDetail',
|
|
100
|
-
'targetProduct.product.productDetails',
|
|
101
|
-
'targetProduct.product.productDetails.childProductDetail',
|
|
102
104
|
'targetInventory',
|
|
103
105
|
'targetInventory.inventory',
|
|
104
106
|
'targetInventory.product',
|
|
105
|
-
'targetInventory.productDetail'
|
|
106
|
-
'targetInventory.product.productDetails',
|
|
107
|
-
'targetInventory.product.productDetails.childProductDetail'
|
|
107
|
+
'targetInventory.productDetail'
|
|
108
108
|
]
|
|
109
109
|
})
|
|
110
|
+
|
|
110
111
|
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
111
112
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
112
113
|
|
|
113
114
|
if (targetProduct && targetProduct.status == ORDER_PRODUCT_STATUS.EDITED)
|
|
114
115
|
throw new Error('this product is pending for changes approval')
|
|
115
116
|
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
117
|
+
const arrivalNotice: ArrivalNotice = worksheetDetail.worksheet.arrivalNotice
|
|
118
|
+
const returnOrder: ReturnOrder = worksheetDetail.worksheet.returnOrder
|
|
119
|
+
const location: Location = worksheetDetail.worksheet.bufferLocation
|
|
120
|
+
const targetOrderInventory: OrderInventory = worksheetDetail?.targetInventory
|
|
121
|
+
const originInventory: OrderInventory = targetOrderInventory?.inventory || null
|
|
121
122
|
const orderId: string = Boolean(arrivalNotice?.id) ? arrivalNotice.id : returnOrder.id
|
|
122
|
-
|
|
123
|
-
const originInventory: OrderInventory = targetInventory ? targetInventory.inventory : null
|
|
124
|
-
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
125
|
-
const batchIdRef: string = Boolean(arrivalNotice) ? targetProduct.batchIdRef : null
|
|
126
|
-
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
123
|
+
|
|
127
124
|
let productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
128
125
|
? targetProduct.productDetail
|
|
129
|
-
:
|
|
130
|
-
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
131
|
-
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
132
|
-
const remark: string = Boolean(arrivalNotice) ? targetProduct.remark : targetInventory.remark
|
|
133
|
-
const manufactureDate: number = Boolean(arrivalNotice) ? targetProduct.manufactureDate : null
|
|
126
|
+
: targetOrderInventory.productDetail
|
|
134
127
|
let qty: number = inventory.qty
|
|
135
128
|
let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : originInventory.uom
|
|
136
|
-
const location: Location = worksheet.bufferLocation
|
|
137
|
-
const warehouse: Warehouse = location.warehouse
|
|
138
|
-
const zone: string = location.zone
|
|
139
|
-
const unitCost: number = Boolean(arrivalNotice)
|
|
140
|
-
? targetProduct?.unitPrice
|
|
141
|
-
? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
|
|
142
|
-
(1 + targetProduct.taxRate / 100)) /
|
|
143
|
-
targetProduct.packQty
|
|
144
|
-
: 0
|
|
145
|
-
: null
|
|
146
|
-
|
|
147
|
-
const palletId: string = inventory?.palletId
|
|
148
|
-
const cartonId: string = inventory?.cartonId
|
|
149
|
-
let matchingProduct
|
|
150
129
|
|
|
151
130
|
if (!inventory?.palletId) {
|
|
131
|
+
if (!inventory?.cartonId) {
|
|
132
|
+
throw new Error('missing carton Id')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
await this.checkCartonDuplication(inventory.cartonId, orderId)
|
|
152
136
|
inventory.palletId = await generateId({
|
|
153
137
|
domain: this.domain,
|
|
154
138
|
type: RULE_TYPE.LOT_NUMBER_ID,
|
|
155
139
|
seed: { date: DateGenerator.generateDate() }
|
|
156
140
|
})
|
|
157
|
-
await this.checkCartonDuplication(cartonId, orderId)
|
|
158
141
|
} else {
|
|
159
|
-
await this.checkPalletDuplication(palletId)
|
|
142
|
+
await this.checkPalletDuplication(inventory.palletId)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let newInventory: Partial<Inventory> = new Inventory()
|
|
146
|
+
newInventory = {
|
|
147
|
+
bizplace: worksheetDetail.bizplace,
|
|
148
|
+
name: InventoryNoGenerator.inventoryName(),
|
|
149
|
+
palletId: inventory.palletId,
|
|
150
|
+
cartonId: inventory.cartonId || undefined,
|
|
151
|
+
refOrderId: orderId,
|
|
152
|
+
productDetail,
|
|
153
|
+
warehouse: location.warehouse,
|
|
154
|
+
zone: location.zone,
|
|
155
|
+
location: location,
|
|
156
|
+
expirationDate: inventory?.expirationDate ? new Date(inventory.expirationDate) : undefined,
|
|
157
|
+
status: INVENTORY_STATUS.UNLOADED
|
|
160
158
|
}
|
|
161
159
|
|
|
160
|
+
if (inventory.reusablePallet?.id) {
|
|
161
|
+
newInventory.reusablePallet = await this.trxMgr.getRepository(Pallet).findOne(inventory.reusablePallet.id)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Find matching product based on GTIN
|
|
162
165
|
if (productBarcode) {
|
|
166
|
+
let matchingProduct
|
|
163
167
|
matchingProduct = await this.getDirectQty(
|
|
164
168
|
{
|
|
165
169
|
...productDetail,
|
|
166
|
-
product:
|
|
170
|
+
product: targetOrderInventory?.product
|
|
167
171
|
},
|
|
168
172
|
productBarcode,
|
|
169
173
|
qty
|
|
@@ -176,55 +180,79 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
176
180
|
uom = arrivalNotice ? targetProduct.uom : matchingProduct.uom
|
|
177
181
|
}
|
|
178
182
|
|
|
179
|
-
|
|
180
|
-
uom = productDetail.uom
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
+
// Calculate uom value
|
|
183
184
|
const uomValue: number =
|
|
184
185
|
Math.round(
|
|
185
186
|
qty *
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
(Boolean(arrivalNotice)
|
|
188
|
+
? targetProduct.uomValue
|
|
189
|
+
: targetOrderInventory.returnUomValue / targetOrderInventory.returnQty) *
|
|
190
|
+
100
|
|
190
191
|
) / 100
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
newInventory.name = InventoryNoGenerator.inventoryName()
|
|
195
|
-
newInventory.palletId = inventory.palletId
|
|
196
|
-
newInventory.cartonId = inventory.cartonId
|
|
197
|
-
newInventory.batchId = batchId
|
|
198
|
-
newInventory.product = product
|
|
199
|
-
newInventory.productDetail = productDetail
|
|
200
|
-
newInventory.packingType = packingType
|
|
201
|
-
newInventory.packingSize = packingSize
|
|
202
|
-
newInventory.uom = uom
|
|
203
|
-
newInventory.remark = remark
|
|
204
|
-
newInventory.qty = qty
|
|
205
|
-
newInventory.uomValue = uomValue
|
|
206
|
-
newInventory.refOrderId = orderId
|
|
207
|
-
newInventory.unitCost = unitCost
|
|
208
|
-
if (inventory.reusablePallet?.id) {
|
|
209
|
-
newInventory.reusablePallet = await this.trxMgr.getRepository(Pallet).findOne(inventory.reusablePallet.id)
|
|
210
|
-
}
|
|
193
|
+
|
|
194
|
+
// case 1: Arrival Notice -> Update Order Product
|
|
211
195
|
if (arrivalNotice) {
|
|
212
|
-
newInventory
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
196
|
+
newInventory = {
|
|
197
|
+
...newInventory,
|
|
198
|
+
batchId: targetProduct.batchId,
|
|
199
|
+
batchIdRef: targetProduct.batchIdRef,
|
|
200
|
+
product: targetProduct.product,
|
|
201
|
+
packingType: targetProduct.packingType,
|
|
202
|
+
packingSize: targetProduct.packingSize,
|
|
203
|
+
remark: targetProduct.remark,
|
|
204
|
+
manufactureDate: targetProduct.manufactureDate,
|
|
205
|
+
orderProductId: targetProduct?.id,
|
|
206
|
+
uom: uom || productDetail.uom,
|
|
207
|
+
qty: qty,
|
|
208
|
+
uomValue: uomValue,
|
|
209
|
+
unitCost: targetProduct?.unitPrice
|
|
210
|
+
? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
|
|
211
|
+
(1 + targetProduct.taxRate / 100)) /
|
|
212
|
+
targetProduct.packQty
|
|
213
|
+
: 0
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const updateOP = {
|
|
217
|
+
id: targetProduct.id,
|
|
218
|
+
actualPalletQty: ++targetProduct.actualPalletQty,
|
|
219
|
+
actualPackQty: targetProduct.actualPackQty + qty,
|
|
220
|
+
status: ORDER_PRODUCT_STATUS.UNLOADED,
|
|
221
|
+
productDetail: productDetail
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADED
|
|
225
|
+
// targetProduct.productDetail = productDetail
|
|
226
|
+
await this.updateOrderTargets([updateOP], OrderProduct)
|
|
218
227
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
// case 2: Return Order -> Update Order Inventory
|
|
229
|
+
else if (returnOrder) {
|
|
230
|
+
newInventory = {
|
|
231
|
+
...newInventory,
|
|
232
|
+
batchId: targetOrderInventory.batchId,
|
|
233
|
+
batchIdRef: null,
|
|
234
|
+
product: targetOrderInventory.product,
|
|
235
|
+
packingType: targetOrderInventory.packingType,
|
|
236
|
+
packingSize: targetOrderInventory.packingSize,
|
|
237
|
+
remark: targetOrderInventory.remark,
|
|
238
|
+
uom: uom || productDetail.uom,
|
|
239
|
+
qty: qty,
|
|
240
|
+
uomValue: uomValue,
|
|
241
|
+
unitCost: targetOrderInventory.unitCost,
|
|
242
|
+
orderInventoryId: targetOrderInventory?.id,
|
|
243
|
+
refInventory: targetOrderInventory?.inventory
|
|
244
|
+
}
|
|
223
245
|
|
|
224
|
-
|
|
225
|
-
|
|
246
|
+
const updateOI = {
|
|
247
|
+
id: targetOrderInventory.id,
|
|
248
|
+
actualPalletQty: ++targetOrderInventory.actualPalletQty,
|
|
249
|
+
actualPackQty: targetOrderInventory.actualPackQty + qty,
|
|
250
|
+
status: ORDER_PRODUCT_STATUS.UNLOADED
|
|
251
|
+
}
|
|
252
|
+
await this.updateOrderTargets([updateOI], OrderInventory)
|
|
226
253
|
}
|
|
227
254
|
|
|
255
|
+
// Create New History Transaction
|
|
228
256
|
newInventory = await this.transactionInventory(
|
|
229
257
|
newInventory,
|
|
230
258
|
Boolean(arrivalNotice) ? arrivalNotice : returnOrder,
|
|
@@ -233,20 +261,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
233
261
|
INVENTORY_TRANSACTION_TYPE.UNLOADING
|
|
234
262
|
)
|
|
235
263
|
|
|
236
|
-
|
|
237
|
-
targetProduct.actualPalletQty++
|
|
238
|
-
targetProduct.actualPackQty += qty
|
|
239
|
-
targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADED
|
|
240
|
-
targetProduct.updater = this.user
|
|
241
|
-
targetProduct.productDetail = productDetail
|
|
242
|
-
this.updateOrderTargets([targetProduct])
|
|
243
|
-
} else if (returnOrder) {
|
|
244
|
-
targetInventory.actualPalletQty++
|
|
245
|
-
targetInventory.actualPackQty += qty
|
|
246
|
-
targetInventory.status = ORDER_PRODUCT_STATUS.UNLOADED
|
|
247
|
-
targetInventory.updater = this.user
|
|
248
|
-
this.updateOrderTargets([targetInventory])
|
|
249
|
-
}
|
|
264
|
+
return arrivalNotice.name
|
|
250
265
|
}
|
|
251
266
|
|
|
252
267
|
async scanSerialNumberUnload(
|
|
@@ -343,8 +358,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
343
358
|
const unitCost: number = Boolean(arrivalNotice)
|
|
344
359
|
? targetProduct?.unitPrice
|
|
345
360
|
? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
|
|
346
|
-
|
|
347
|
-
|
|
361
|
+
(1 + targetProduct.taxRate / 100)) /
|
|
362
|
+
targetProduct.packQty
|
|
348
363
|
: 0
|
|
349
364
|
: null
|
|
350
365
|
|
|
@@ -367,10 +382,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
367
382
|
newInventory.uomValue =
|
|
368
383
|
Math.round(
|
|
369
384
|
qty *
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
385
|
+
(Boolean(arrivalNotice)
|
|
386
|
+
? targetProduct.uomValue
|
|
387
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
388
|
+
100
|
|
374
389
|
) / 100
|
|
375
390
|
newInventory.manufactureDate = manufactureDate
|
|
376
391
|
newInventory.refOrderId = orderId
|
|
@@ -407,10 +422,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
407
422
|
foundInventory.uomValue +=
|
|
408
423
|
Math.round(
|
|
409
424
|
qty *
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
425
|
+
(Boolean(arrivalNotice)
|
|
426
|
+
? targetProduct.uomValue
|
|
427
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
428
|
+
100
|
|
414
429
|
) / 100
|
|
415
430
|
if (arrivalNotice) targetProduct.actualPackQty = targetProduct.actualPackQty + qty
|
|
416
431
|
else if (returnOrder) targetInventory.actualPackQty = targetInventory.actualPackQty + qty
|
|
@@ -549,8 +564,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
549
564
|
const unitCost: number = Boolean(arrivalNotice)
|
|
550
565
|
? targetProduct?.unitPrice
|
|
551
566
|
? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
|
|
552
|
-
|
|
553
|
-
|
|
567
|
+
(1 + targetProduct.taxRate / 100)) /
|
|
568
|
+
targetProduct.packQty
|
|
554
569
|
: 0
|
|
555
570
|
: null
|
|
556
571
|
|
|
@@ -573,10 +588,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
573
588
|
newInventory.uomValue =
|
|
574
589
|
Math.round(
|
|
575
590
|
qty *
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
591
|
+
(Boolean(arrivalNotice)
|
|
592
|
+
? targetProduct.uomValue
|
|
593
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
594
|
+
100
|
|
580
595
|
) / 100
|
|
581
596
|
newInventory.manufactureDate = manufactureDate
|
|
582
597
|
newInventory.refOrderId = orderId
|
|
@@ -613,10 +628,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
613
628
|
foundInventory.uomValue +=
|
|
614
629
|
Math.round(
|
|
615
630
|
qty *
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
631
|
+
(Boolean(arrivalNotice)
|
|
632
|
+
? targetProduct.uomValue
|
|
633
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
634
|
+
100
|
|
620
635
|
) / 100
|
|
621
636
|
foundInventory.productDetail = productDetail
|
|
622
637
|
if (arrivalNotice) targetProduct.actualPackQty = targetProduct.actualPackQty + qty
|
|
@@ -801,10 +816,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
801
816
|
inventory.uomValue =
|
|
802
817
|
Math.round(
|
|
803
818
|
inventory.qty *
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
819
|
+
(Boolean(orderType === ORDER_TYPES.ARRIVAL_NOTICE)
|
|
820
|
+
? targetProduct.uomValue
|
|
821
|
+
: targetInventory.returnUomValue) *
|
|
822
|
+
100
|
|
808
823
|
) / 100
|
|
809
824
|
inventory.updater = this.user
|
|
810
825
|
await this.trxMgr.getRepository(Inventory).save(inventory)
|
|
@@ -888,10 +903,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
888
903
|
inventory.uomValue =
|
|
889
904
|
Math.round(
|
|
890
905
|
inventory.qty *
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
906
|
+
(Boolean(arrivalNotice)
|
|
907
|
+
? targetProduct.uomValue
|
|
908
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
909
|
+
100
|
|
895
910
|
) / 100
|
|
896
911
|
await this.trxMgr
|
|
897
912
|
.getRepository(Inventory)
|
|
@@ -939,19 +954,24 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
939
954
|
const bizplace: Bizplace = worksheet.bizplace
|
|
940
955
|
let worksheetDetails: WorksheetDetail[] = worksheet.worksheetDetails
|
|
941
956
|
|
|
942
|
-
const
|
|
943
|
-
|
|
957
|
+
const targetProductsId = worksheet.worksheetDetails.map(wsd => { return wsd.targetProduct.id })
|
|
958
|
+
await this.trxMgr
|
|
959
|
+
.getRepository(OrderInventory)
|
|
960
|
+
.update({ id: In(targetProductsId) }, { status: ORDER_PRODUCT_STATUS.UNLOADING, updater: this.user })
|
|
944
961
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
targetProduct.palletQty = palletQty
|
|
948
|
-
}
|
|
949
|
-
targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADING
|
|
950
|
-
targetProduct.updater = this.user
|
|
962
|
+
// const targetProducts: OrderProduct[] = worksheetDetails.map((wsd: WorksheetDetail) => {
|
|
963
|
+
// let targetProduct: OrderProduct = wsd.targetProduct
|
|
951
964
|
|
|
952
|
-
|
|
953
|
-
})
|
|
954
|
-
|
|
965
|
+
// if (!targetProduct.palletQty) {
|
|
966
|
+
// const { palletQty }: { palletQty: number } = this.findMatchedWSD(wsd.name, unloadingWorksheetDetails)
|
|
967
|
+
// targetProduct.palletQty = palletQty
|
|
968
|
+
// }
|
|
969
|
+
// targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADING
|
|
970
|
+
// targetProduct.updater = this.user
|
|
971
|
+
|
|
972
|
+
// return targetProduct
|
|
973
|
+
// })
|
|
974
|
+
// await this.updateOrderTargets(targetProducts)
|
|
955
975
|
|
|
956
976
|
arrivalNotice.status = ORDER_STATUS.PROCESSING
|
|
957
977
|
arrivalNotice.updater = this.user
|
|
@@ -439,7 +439,7 @@ export class WorksheetController {
|
|
|
439
439
|
let existingWorksheet: Worksheet
|
|
440
440
|
try {
|
|
441
441
|
existingWorksheet = await this.findWorksheetByRefOrder(refOrder, type)
|
|
442
|
-
} catch (e) {}
|
|
442
|
+
} catch (e) { }
|
|
443
443
|
|
|
444
444
|
if (existingWorksheet)
|
|
445
445
|
throw new Error(
|
|
@@ -594,6 +594,13 @@ export class WorksheetController {
|
|
|
594
594
|
* Update order targets like (OrderProduct, OrderInventory, OrderVas)
|
|
595
595
|
*/
|
|
596
596
|
async updateOrderTargets(orderTargets: OrderTargetTypes[], entitySchema?: EntitySchema): Promise<any> {
|
|
597
|
+
|
|
598
|
+
if (orderTargets.some((orderTarget: any) => !orderTarget.id)) throw new Error(this.ERROR_MSG.UPDATE.ID_NOT_EXISTS)
|
|
599
|
+
|
|
600
|
+
orderTargets.forEach((orderTarget: OrderTargetTypes) => {
|
|
601
|
+
if (!orderTarget.updater?.id) orderTarget = this.setStamp(orderTarget)
|
|
602
|
+
})
|
|
603
|
+
|
|
597
604
|
if (!entitySchema) {
|
|
598
605
|
if (orderTargets[0] instanceof OrderProduct) {
|
|
599
606
|
entitySchema = OrderProduct
|
|
@@ -604,12 +611,25 @@ export class WorksheetController {
|
|
|
604
611
|
}
|
|
605
612
|
}
|
|
606
613
|
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
614
|
+
if (!entitySchema) { throw new Error('updateOrderTargets - missing entity Schema.') }
|
|
615
|
+
|
|
616
|
+
if (entitySchema === OrderProduct) {
|
|
617
|
+
// update all order targets with 1 action
|
|
618
|
+
await Promise.all(orderTargets.map(async orderTarget => {
|
|
619
|
+
try {
|
|
620
|
+
await this.trxMgr.getRepository(OrderProduct).update({
|
|
621
|
+
id: orderTarget.id
|
|
622
|
+
}, orderTarget)
|
|
623
|
+
} catch (error) {
|
|
624
|
+
console.error(error)
|
|
625
|
+
}
|
|
626
|
+
}))
|
|
611
627
|
|
|
612
|
-
|
|
628
|
+
// find all based on Ids
|
|
629
|
+
return await this.trxMgr.getRepository(entitySchema).findByIds(orderTargets.map(ot => ot.id))
|
|
630
|
+
} else {
|
|
631
|
+
return await this.trxMgr.getRepository(entitySchema).save(orderTargets)
|
|
632
|
+
}
|
|
613
633
|
}
|
|
614
634
|
|
|
615
635
|
/**
|
|
@@ -631,18 +651,18 @@ export class WorksheetController {
|
|
|
631
651
|
orderTargetStatus: string,
|
|
632
652
|
additionalProps: Partial<Worksheet> = {}
|
|
633
653
|
): Promise<Worksheet> {
|
|
654
|
+
|
|
634
655
|
const worksheet: Worksheet = await this.createWorksheet(refOrder, worksheetType, additionalProps)
|
|
635
656
|
|
|
636
657
|
orderTargets.forEach((orderTarget: OrderTargetTypes) => {
|
|
637
658
|
orderTarget.status = orderTargetStatus
|
|
638
659
|
})
|
|
660
|
+
|
|
639
661
|
orderTargets = await this.updateOrderTargets(orderTargets)
|
|
640
662
|
|
|
641
663
|
worksheet.worksheetDetails = await this.createWorksheetDetails(worksheet, worksheetType, orderTargets)
|
|
642
|
-
|
|
643
664
|
refOrder.status = refOrderStatus
|
|
644
665
|
await this.updateRefOrder(refOrder)
|
|
645
|
-
|
|
646
666
|
return worksheet
|
|
647
667
|
}
|
|
648
668
|
|
|
@@ -74,12 +74,16 @@ export const completePutawayResolver = {
|
|
|
74
74
|
|
|
75
75
|
if (sellercraft) {
|
|
76
76
|
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
// allow async run to skip user wait time
|
|
79
|
+
sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
81
83
|
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
82
|
-
|
|
84
|
+
|
|
85
|
+
// allow async run to skip user wait time
|
|
86
|
+
ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
}
|
|
@@ -3,10 +3,14 @@ import { Domain } from '@things-factory/shell'
|
|
|
3
3
|
import { EntityManager } from 'typeorm'
|
|
4
4
|
import { PutawayWorksheetController } from '../../../../controllers'
|
|
5
5
|
|
|
6
|
+
import { findPutawayWorksheetByArrivalNoticeNo } from '../putaway-worksheet'
|
|
7
|
+
|
|
6
8
|
export const putawayResolver = {
|
|
7
|
-
async putaway(_: any, { worksheetDetailName, palletId, cartonId, toLocation }, context: any) {
|
|
9
|
+
async putaway(_: any, { arrivalNoticeNo, worksheetDetailName, palletId, cartonId, toLocation }, context: any) {
|
|
8
10
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
9
11
|
await putaway(tx, domain, user, worksheetDetailName, palletId, cartonId, toLocation)
|
|
12
|
+
|
|
13
|
+
return await findPutawayWorksheetByArrivalNoticeNo(arrivalNoticeNo, context)
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
|