@things-factory/worksheet-base 4.3.88 → 4.3.94-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/ecommerce/ecommerce-controller.js +1 -1
- package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +87 -71
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +2 -4
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +10 -4
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +47 -33
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +78 -48
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +12 -14
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +1 -2
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +3 -8
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +3 -2
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +29 -62
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +1 -2
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +6 -6
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/delivery-order-by-worksheet.js +7 -4
- package/dist-server/graphql/resolvers/worksheet/delivery-order-by-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js +67 -28
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js +23 -8
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js +30 -7
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +23 -8
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +25 -8
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +60 -12
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +51 -25
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +37 -29
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +132 -118
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js +6 -4
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +39 -14
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/transfer.js +9 -9
- package/dist-server/graphql/resolvers/worksheet/transfer.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js +17 -17
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js +4 -4
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/types/worksheet/delivery-order-info.js +1 -0
- package/dist-server/graphql/types/worksheet/delivery-order-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +1 -98
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/ecommerce/ecommerce-controller.ts +1 -1
- package/server/controllers/inbound/unloading-worksheet-controller.ts +102 -84
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +2 -4
- package/server/controllers/outbound/loading-worksheet-controller.ts +9 -3
- package/server/controllers/outbound/packing-worksheet-controller.ts +56 -45
- package/server/controllers/outbound/picking-worksheet-controller.ts +98 -66
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +18 -23
- package/server/entities/index.ts +2 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +29 -63
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +6 -0
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +1 -2
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/delivery-order-by-worksheet.ts +7 -6
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +3 -1
- package/server/graphql/resolvers/worksheet/loading/complete-loading.ts +77 -33
- package/server/graphql/resolvers/worksheet/packing/activate-packing.ts +26 -9
- package/server/graphql/resolvers/worksheet/packing/complete-packing.ts +34 -9
- package/server/graphql/resolvers/worksheet/packing/packing.ts +26 -9
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +28 -9
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +69 -13
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +60 -30
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +46 -40
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +142 -131
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +3 -2
- package/server/graphql/resolvers/worksheet/proceed-extra-products.ts +5 -4
- package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +45 -15
- package/server/graphql/resolvers/worksheet/transfer.ts +18 -16
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +3 -2
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +4 -1
- package/server/graphql/types/worksheet/delivery-order-info.ts +1 -0
- package/server/graphql/types/worksheet-detail/index.ts +1 -0
- package/server/utils/inventory-util.ts +1 -126
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
VAS_TARGET_TYPES,
|
|
20
20
|
VAS_TYPES
|
|
21
21
|
} from '@things-factory/sales-base'
|
|
22
|
-
import { Domain } from '@things-factory/shell'
|
|
23
22
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
23
|
+
import { Domain } from '@things-factory/shell'
|
|
24
24
|
import {
|
|
25
25
|
Inventory,
|
|
26
26
|
INVENTORY_ITEM_SOURCE,
|
|
@@ -31,12 +31,13 @@ import {
|
|
|
31
31
|
InventoryNoGenerator,
|
|
32
32
|
Location,
|
|
33
33
|
Pallet,
|
|
34
|
-
Warehouse
|
|
34
|
+
Warehouse,
|
|
35
|
+
generateInventoryHistory
|
|
35
36
|
} from '@things-factory/warehouse-base'
|
|
36
37
|
|
|
37
38
|
import { RULE_TYPE, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
38
39
|
import { Worksheet, WorksheetDetail } from '../../entities'
|
|
39
|
-
import { DateGenerator
|
|
40
|
+
import { DateGenerator } from '../../utils'
|
|
40
41
|
import { VasWorksheetController } from '../vas/vas-worksheet-controller'
|
|
41
42
|
|
|
42
43
|
export type UnloadingWorksheetDetail = Partial<WorksheetDetail> & {
|
|
@@ -95,11 +96,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
95
96
|
'worksheet.bufferLocation.warehouse',
|
|
96
97
|
'targetProduct',
|
|
97
98
|
'targetProduct.product',
|
|
99
|
+
'targetProduct.productDetail',
|
|
98
100
|
'targetProduct.product.productDetails',
|
|
99
101
|
'targetProduct.product.productDetails.childProductDetail',
|
|
100
102
|
'targetInventory',
|
|
101
103
|
'targetInventory.inventory',
|
|
102
104
|
'targetInventory.product',
|
|
105
|
+
'targetInventory.productDetail',
|
|
103
106
|
'targetInventory.product.productDetails',
|
|
104
107
|
'targetInventory.product.productDetails.childProductDetail'
|
|
105
108
|
]
|
|
@@ -121,6 +124,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
121
124
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
122
125
|
const batchIdRef: string = Boolean(arrivalNotice) ? targetProduct.batchIdRef : null
|
|
123
126
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
127
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
128
|
+
? targetProduct.productDetail
|
|
129
|
+
: targetInventory.productDetail
|
|
124
130
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
125
131
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
126
132
|
const remark: string = Boolean(arrivalNotice) ? targetProduct.remark : targetInventory.remark
|
|
@@ -140,6 +146,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
140
146
|
|
|
141
147
|
const palletId: string = inventory?.palletId
|
|
142
148
|
const cartonId: string = inventory?.cartonId
|
|
149
|
+
let matchingProduct
|
|
143
150
|
|
|
144
151
|
if (!inventory?.palletId) {
|
|
145
152
|
inventory.palletId = await generateId({
|
|
@@ -153,37 +160,44 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
153
160
|
}
|
|
154
161
|
|
|
155
162
|
if (productBarcode) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
matchingProduct = await this.getDirectQty(
|
|
164
|
+
{
|
|
165
|
+
...productDetail,
|
|
166
|
+
product: targetInventory?.product
|
|
167
|
+
},
|
|
168
|
+
productBarcode,
|
|
169
|
+
qty
|
|
163
170
|
)
|
|
164
171
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
(parentDetail: ProductDetail) =>
|
|
168
|
-
parentDetail.packingType === packingType && parentDetail.packingSize == packingSize
|
|
169
|
-
)
|
|
170
|
-
if (!orderProductDetail)
|
|
171
|
-
throw new Error(
|
|
172
|
-
this.ERROR_MSG.FIND.NO_RESULT(`Packing Type ( ${packingType}) or Packing Size (${packingSize})`)
|
|
173
|
-
)
|
|
172
|
+
//validate matching product details based on scanned barcode
|
|
173
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
qty = (await this.getChildQty(productDetails, productBarcode, orderProductDetail)) * qty
|
|
181
|
-
} else {
|
|
182
|
-
uom = foundProductDetail.uom
|
|
183
|
-
qty
|
|
184
|
-
}
|
|
175
|
+
qty = matchingProduct.qty
|
|
176
|
+
uom = arrivalNotice ? targetProduct.uom : matchingProduct.uom
|
|
177
|
+
} else {
|
|
178
|
+
qty++
|
|
179
|
+
uom = productDetail.uom
|
|
185
180
|
}
|
|
186
181
|
|
|
182
|
+
// if (productBarcode) {
|
|
183
|
+
// const productDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
184
|
+
// const scannedProductDetail: ProductDetail = productDetails.find(detail => detail.gtin == productBarcode)
|
|
185
|
+
// if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
186
|
+
|
|
187
|
+
// if (scannedProductDetail.id !== productDetail.id) {
|
|
188
|
+
// let childQty = await this.getChildQty(productDetails, productBarcode, productDetail, scannedProductDetail)
|
|
189
|
+
// if (arrivalNotice) {
|
|
190
|
+
// uom = targetProduct.uom
|
|
191
|
+
// } else {
|
|
192
|
+
// uom = productDetail.uom
|
|
193
|
+
// }
|
|
194
|
+
// qty *= childQty
|
|
195
|
+
// } else {
|
|
196
|
+
// uom = scannedProductDetail.uom
|
|
197
|
+
// qty
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
200
|
+
|
|
187
201
|
const uomValue: number =
|
|
188
202
|
Math.round(
|
|
189
203
|
qty *
|
|
@@ -200,6 +214,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
200
214
|
newInventory.cartonId = inventory.cartonId
|
|
201
215
|
newInventory.batchId = batchId
|
|
202
216
|
newInventory.product = product
|
|
217
|
+
newInventory.productDetail = productDetail
|
|
203
218
|
newInventory.packingType = packingType
|
|
204
219
|
newInventory.packingSize = packingSize
|
|
205
220
|
newInventory.uom = uom
|
|
@@ -270,6 +285,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
270
285
|
'worksheet.bufferLocation.warehouse',
|
|
271
286
|
'targetProduct',
|
|
272
287
|
'targetProduct.product',
|
|
288
|
+
'targetProduct.productDetail',
|
|
273
289
|
'targetProduct.product.productDetails',
|
|
274
290
|
'targetProduct.product.productDetails.childProductDetail',
|
|
275
291
|
'targetInventory',
|
|
@@ -298,6 +314,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
298
314
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
299
315
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
300
316
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
317
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
318
|
+
? targetProduct.productDetail
|
|
319
|
+
: targetInventory.productDetail
|
|
301
320
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
302
321
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
303
322
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
@@ -309,15 +328,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
309
328
|
|
|
310
329
|
qty++
|
|
311
330
|
|
|
312
|
-
const invQb: SelectQueryBuilder<Inventory> =
|
|
331
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
313
332
|
.getRepository(Inventory)
|
|
314
333
|
.createQueryBuilder('INV')
|
|
315
334
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
316
335
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
317
|
-
.andWhere('INV.
|
|
336
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
318
337
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
319
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
320
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
321
338
|
|
|
322
339
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
323
340
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -357,6 +374,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
357
374
|
newInventory.batchId = batchId
|
|
358
375
|
newInventory.batchIdRef = batchIdRef
|
|
359
376
|
newInventory.product = product
|
|
377
|
+
newInventory.productDetail = productDetail
|
|
360
378
|
newInventory.packingType = packingType
|
|
361
379
|
newInventory.packingSize = packingSize
|
|
362
380
|
newInventory.uom = uom
|
|
@@ -421,6 +439,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
421
439
|
inventoryItem.status = foundInventory.status
|
|
422
440
|
inventoryItem.inboundOrderId = foundInventory.refOrderId
|
|
423
441
|
inventoryItem.product = product
|
|
442
|
+
inventoryItem.productDetail = productDetail
|
|
424
443
|
inventoryItem.inventory = foundInventory
|
|
425
444
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.INBOUND
|
|
426
445
|
inventoryItem.domain = this.domain
|
|
@@ -457,10 +476,12 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
457
476
|
'worksheet.bufferLocation.warehouse',
|
|
458
477
|
'targetProduct',
|
|
459
478
|
'targetProduct.product',
|
|
479
|
+
'targetProduct.productDetail',
|
|
460
480
|
'targetProduct.product.productDetails',
|
|
461
481
|
'targetProduct.product.productDetails.childProductDetail',
|
|
462
482
|
'targetInventory',
|
|
463
483
|
'targetInventory.product',
|
|
484
|
+
'targetInventory.productDetail',
|
|
464
485
|
'targetInventory.product.productDetails',
|
|
465
486
|
'targetInventory.product.productDetails.childProductDetail'
|
|
466
487
|
]
|
|
@@ -485,56 +506,61 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
485
506
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
486
507
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
487
508
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
509
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
510
|
+
? targetProduct.productDetail
|
|
511
|
+
: targetInventory.productDetail
|
|
488
512
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
489
513
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
490
514
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
491
|
-
let qty: number =
|
|
515
|
+
let qty: number = 1
|
|
492
516
|
let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : targetInventory.uom
|
|
493
517
|
const cartonId: string = inventory.cartonId
|
|
494
518
|
const orderId: string = Boolean(arrivalNotice) ? arrivalNotice.id : returnOrder.id
|
|
495
519
|
await this.checkCartonDuplication(cartonId, orderId)
|
|
520
|
+
let matchingProduct
|
|
496
521
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
detail.gtin === productBarcode && detail.packingType === packingType && detail.packingSize == packingSize
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
if (!foundProductDetail) {
|
|
509
|
-
const orderProductDetail: ProductDetail = productDetails.find(
|
|
510
|
-
(parentDetail: ProductDetail) =>
|
|
511
|
-
parentDetail.packingType === packingType && parentDetail.packingSize == packingSize
|
|
522
|
+
if (productBarcode !== productDetail.gtin) {
|
|
523
|
+
matchingProduct = await this.getDirectQty(
|
|
524
|
+
{
|
|
525
|
+
...productDetail,
|
|
526
|
+
product: targetInventory?.product
|
|
527
|
+
},
|
|
528
|
+
productBarcode,
|
|
529
|
+
qty
|
|
512
530
|
)
|
|
513
|
-
if (!orderProductDetail)
|
|
514
|
-
throw new Error(
|
|
515
|
-
this.ERROR_MSG.FIND.NO_RESULT(`Packing Type ( ${packingType}) or Packing Size (${packingSize})`)
|
|
516
|
-
)
|
|
517
531
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
qty = await this.getChildQty(productDetails, productBarcode, orderProductDetail)
|
|
524
|
-
} else {
|
|
525
|
-
uom = foundProductDetail.uom
|
|
526
|
-
qty++
|
|
532
|
+
//validate matching product details based on scanned barcode
|
|
533
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
534
|
+
|
|
535
|
+
qty = matchingProduct.qty
|
|
536
|
+
uom = arrivalNotice ? targetProduct.uom : matchingProduct.uom
|
|
527
537
|
}
|
|
528
538
|
|
|
529
|
-
|
|
539
|
+
// // search for matching product barcode
|
|
540
|
+
// const productDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
541
|
+
// const scannedProductDetail: ProductDetail = productDetails.find(detail => detail.gtin == productBarcode)
|
|
542
|
+
// if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
543
|
+
|
|
544
|
+
// if (scannedProductDetail.id !== productDetail.id && arrivalNotice) {
|
|
545
|
+
// let childQty = await this.getChildQty(productDetails, productBarcode, productDetail, scannedProductDetail)
|
|
546
|
+
// if (arrivalNotice) {
|
|
547
|
+
// uom = targetProduct.uom
|
|
548
|
+
// } else {
|
|
549
|
+
// uom = productDetail.uom
|
|
550
|
+
// }
|
|
551
|
+
// qty = childQty
|
|
552
|
+
// } else {
|
|
553
|
+
// uom = scannedProductDetail.uom
|
|
554
|
+
// qty++
|
|
555
|
+
// }
|
|
556
|
+
|
|
557
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
530
558
|
.getRepository(Inventory)
|
|
531
559
|
.createQueryBuilder('INV')
|
|
532
560
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
533
561
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
534
|
-
.andWhere('INV.
|
|
562
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
535
563
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
536
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
537
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
538
564
|
|
|
539
565
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
540
566
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -574,6 +600,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
574
600
|
newInventory.batchId = batchId
|
|
575
601
|
newInventory.batchIdRef = batchIdRef
|
|
576
602
|
newInventory.product = product
|
|
603
|
+
newInventory.productDetail = productDetail
|
|
577
604
|
newInventory.packingType = packingType
|
|
578
605
|
newInventory.packingSize = packingSize
|
|
579
606
|
newInventory.uom = uom
|
|
@@ -656,8 +683,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
656
683
|
'worksheet.bufferLocation.warehouse',
|
|
657
684
|
'targetProduct',
|
|
658
685
|
'targetProduct.product',
|
|
686
|
+
'targetProduct.productDetail',
|
|
659
687
|
'targetInventory',
|
|
660
|
-
'targetInventory.product'
|
|
688
|
+
'targetInventory.product',
|
|
689
|
+
'targetInventory.productDetail'
|
|
661
690
|
]
|
|
662
691
|
})
|
|
663
692
|
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
@@ -668,9 +697,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
668
697
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
669
698
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
670
699
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
671
|
-
const
|
|
672
|
-
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
673
|
-
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
700
|
+
const productDetail: Product = Boolean(arrivalNotice) ? targetProduct.productDetail : targetInventory.productDetail
|
|
674
701
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
675
702
|
|
|
676
703
|
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
@@ -678,10 +705,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
678
705
|
.createQueryBuilder('INV')
|
|
679
706
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
680
707
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
681
|
-
.andWhere('INV.
|
|
708
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
682
709
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
683
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
684
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
685
710
|
|
|
686
711
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
687
712
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -714,7 +739,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
714
739
|
const inventoryId: string = inventoryIds[i]
|
|
715
740
|
let inventory: Inventory = await this.trxMgr.getRepository(Inventory).findOne({
|
|
716
741
|
where: { domain: this.domain, id: inventoryId },
|
|
717
|
-
relations: ['location', 'product']
|
|
742
|
+
relations: ['location', 'product', 'productDetail']
|
|
718
743
|
})
|
|
719
744
|
|
|
720
745
|
this.checkRecordValidity(inventory, {
|
|
@@ -744,14 +769,11 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
744
769
|
if (orderType === ORDER_TYPES.ARRIVAL_NOTICE) {
|
|
745
770
|
arrivalNotice = await this.trxMgr.getRepository(ArrivalNotice).findOne({
|
|
746
771
|
where: { domain: this.domain, name: orderNo },
|
|
747
|
-
relations: ['orderProducts', 'orderProducts.product']
|
|
772
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.productDetail']
|
|
748
773
|
})
|
|
749
774
|
|
|
750
775
|
targetProduct = arrivalNotice.orderProducts.find(
|
|
751
|
-
op =>
|
|
752
|
-
op.batchId == inventory.batchId &&
|
|
753
|
-
op.packingType == inventory.packingType &&
|
|
754
|
-
op.product.id === inventory.product.id
|
|
776
|
+
op => op.batchId == inventory.batchId && op.productDetail.id == inventory.productDetail.id
|
|
755
777
|
)
|
|
756
778
|
|
|
757
779
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
@@ -777,11 +799,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
777
799
|
})
|
|
778
800
|
|
|
779
801
|
targetInventory = returnOrder.orderInventories.find(
|
|
780
|
-
oi =>
|
|
781
|
-
oi.batchId == inventory.batchId &&
|
|
782
|
-
oi.packingType == inventory.packingType &&
|
|
783
|
-
oi.product.id == inventory.product.id &&
|
|
784
|
-
oi.packingSize === inventory.packingSize
|
|
802
|
+
oi => oi.batchId == inventory.batchId && oi.productDetail.id == inventory.productDetail.id
|
|
785
803
|
)
|
|
786
804
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
787
805
|
targetInventory.actualPackQty -= qty
|
|
@@ -103,16 +103,14 @@ export class CycleCountWorksheetController extends WorksheetController {
|
|
|
103
103
|
let keyval = {
|
|
104
104
|
batchId: 'batch_id',
|
|
105
105
|
batchIdRef: 'batch_id_ref',
|
|
106
|
-
|
|
107
|
-
packingSize: 'packing_size',
|
|
108
|
-
productId: 'product_id'
|
|
106
|
+
productDetailId: 'product_detail_id'
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
qb.andWhere(
|
|
112
110
|
new Brackets(qb => {
|
|
113
111
|
orderInventory.forEach((itm, idx) => {
|
|
114
112
|
// sample itm value
|
|
115
|
-
// batchId: 'WO00019730', batchIdRef: null,
|
|
113
|
+
// batchId: 'WO00019730', batchIdRef: null, productDetailId: '1d679587-c713-42d6-bd0a-74e587e39cc7'
|
|
116
114
|
qb.orWhere(
|
|
117
115
|
new Brackets(qb2 => {
|
|
118
116
|
let first = true
|
|
@@ -12,11 +12,10 @@ import {
|
|
|
12
12
|
OrderToteItem,
|
|
13
13
|
OrderTote
|
|
14
14
|
} from '@things-factory/sales-base'
|
|
15
|
-
import { Inventory, INVENTORY_TRANSACTION_TYPE, Tote, TOTE_STATUS } from '@things-factory/warehouse-base'
|
|
15
|
+
import { Inventory, INVENTORY_TRANSACTION_TYPE, Tote, TOTE_STATUS, generateInventoryHistory } from '@things-factory/warehouse-base'
|
|
16
16
|
|
|
17
17
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
18
18
|
import { Worksheet, WorksheetDetail } from '../../entities'
|
|
19
|
-
import { generateInventoryHistory } from '../../utils'
|
|
20
19
|
import { VasWorksheetController } from '../vas/vas-worksheet-controller'
|
|
21
20
|
|
|
22
21
|
export class LoadingWorksheetController extends VasWorksheetController {
|
|
@@ -112,7 +111,13 @@ export class LoadingWorksheetController extends VasWorksheetController {
|
|
|
112
111
|
let worksheetDetail = await this.findExecutableWorksheetDetailByName(
|
|
113
112
|
worksheetDetails[i].name,
|
|
114
113
|
WORKSHEET_TYPE.LOADING,
|
|
115
|
-
[
|
|
114
|
+
[
|
|
115
|
+
'worksheet',
|
|
116
|
+
'targetInventory',
|
|
117
|
+
'targetInventory.inventory',
|
|
118
|
+
'targetInventory.product',
|
|
119
|
+
'targetInventory.productDetail'
|
|
120
|
+
]
|
|
116
121
|
)
|
|
117
122
|
|
|
118
123
|
const worksheet: Worksheet = worksheetDetail.worksheet
|
|
@@ -170,6 +175,7 @@ export class LoadingWorksheetController extends VasWorksheetController {
|
|
|
170
175
|
newTargetInventory.releaseQty = remainQty
|
|
171
176
|
newTargetInventory.releaseUomValue = remainUomValue
|
|
172
177
|
newTargetInventory.product = targetInventory.product
|
|
178
|
+
newTargetInventory.productDetail = targetInventory.productDetail
|
|
173
179
|
newTargetInventory.packingType = targetInventory.packingType
|
|
174
180
|
newTargetInventory.batchId = targetInventory.batchId
|
|
175
181
|
newTargetInventory.creator = this.user
|
|
@@ -93,13 +93,15 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
93
93
|
'targetInventory.releaseGood',
|
|
94
94
|
'targetInventory.inventory',
|
|
95
95
|
'targetInventory.inventory.location',
|
|
96
|
-
'targetInventory.product'
|
|
96
|
+
'targetInventory.product',
|
|
97
|
+
'targetInventory.productDetail'
|
|
97
98
|
]
|
|
98
99
|
)
|
|
99
|
-
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
100
100
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
101
|
-
const product: Product = targetInventory.product
|
|
102
101
|
let inventory: Inventory = targetInventory.inventory
|
|
102
|
+
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
103
|
+
const product: Product = targetInventory.product
|
|
104
|
+
const productDetail: ProductDetail = targetInventory.productDetail
|
|
103
105
|
const pickedQty: number = targetInventory.releaseQty
|
|
104
106
|
|
|
105
107
|
if (packedQty > pickedQty) {
|
|
@@ -114,8 +116,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
let foundSerialNumber: InventoryItem = await this.trxMgr.getRepository(InventoryItem).findOne({
|
|
117
|
-
where: { domain: this.domain, serialNumber: serialNumber,
|
|
118
|
-
relations: ['product', 'inventory']
|
|
119
|
+
where: { domain: this.domain, serialNumber: serialNumber, productDetail }
|
|
119
120
|
})
|
|
120
121
|
|
|
121
122
|
if (foundSerialNumber) {
|
|
@@ -139,6 +140,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
139
140
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
140
141
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
141
142
|
inventoryItem.product = product
|
|
143
|
+
inventoryItem.productDetail = productDetail
|
|
142
144
|
inventoryItem.inventory = inventory
|
|
143
145
|
inventoryItem.domain = this.domain
|
|
144
146
|
|
|
@@ -181,52 +183,60 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
181
183
|
productBarcode: string,
|
|
182
184
|
serialNumber?: string
|
|
183
185
|
): Promise<WorksheetDetail> {
|
|
184
|
-
let worksheetDetail: WorksheetDetail = await this.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const product: Product = worksheetDetail.targetInventory.inventory.product
|
|
202
|
-
const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
186
|
+
let worksheetDetail: WorksheetDetail = await this.trxMgr
|
|
187
|
+
.getRepository(WorksheetDetail)
|
|
188
|
+
.createQueryBuilder('wd')
|
|
189
|
+
.innerJoinAndSelect('wd.worksheet', 'ws')
|
|
190
|
+
.innerJoinAndSelect('ws.bizplace', 'bz')
|
|
191
|
+
.innerJoinAndSelect('wd.targetInventory', 'oi')
|
|
192
|
+
.innerJoinAndSelect('oi.releaseGood', 'rg')
|
|
193
|
+
.innerJoinAndSelect('oi.inventory', 'inv')
|
|
194
|
+
.leftJoinAndSelect('oi.orderProduct', 'op')
|
|
195
|
+
.innerJoinAndSelect('oi.product', 'prd')
|
|
196
|
+
.innerJoinAndSelect('oi.productDetail', 'pd')
|
|
197
|
+
.where('wd.name = :name', { name: worksheetDetailName })
|
|
198
|
+
.andWhere('wd.domain_id = :domainId', { domainId: this.domain.id })
|
|
199
|
+
.andWhere('wd.type = :type', { type: WORKSHEET_TYPE.PACKING })
|
|
200
|
+
.andWhere('wd.status = :status', { status: WORKSHEET_STATUS.EXECUTING })
|
|
201
|
+
.getOne()
|
|
202
|
+
|
|
203
203
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
204
204
|
let inventory: Inventory = targetInventory.inventory
|
|
205
205
|
let packedQty: number = 1
|
|
206
206
|
let pickedQty: number = targetInventory.releaseQty
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const productDetail: ProductDetail =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
207
|
+
const releaseGood: ReleaseGood = targetInventory.releaseGood
|
|
208
|
+
const product: Product = targetInventory.inventory.product
|
|
209
|
+
const productDetail: ProductDetail = targetInventory.productDetail
|
|
210
|
+
let matchingProduct
|
|
211
|
+
|
|
212
|
+
// // search for matching product barcode
|
|
213
|
+
// const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
214
|
+
// const scannedProductDetail: ProductDetail = filterProductDetails.find(detail => detail.gtin == productBarcode)
|
|
215
|
+
// if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
216
|
+
|
|
217
|
+
// // case for scanning parent packing type, packing size
|
|
218
|
+
// // when scannedProductDetail id is not the same as productDetail id, then it's not child gtin, proceed to get child qty
|
|
219
|
+
// if (scannedProductDetail.id !== productDetail.id && !product?.isRequireSerialNumberScanningOutbound) {
|
|
220
|
+
// let childQty = await this.getChildQty(filterProductDetails, productBarcode, productDetail, scannedProductDetail)
|
|
221
|
+
// packedQty *= childQty
|
|
222
|
+
// }
|
|
223
|
+
|
|
224
|
+
if (productBarcode !== productDetail.gtin) {
|
|
225
|
+
if (product?.isRequireSerialNumberScanningOutbound) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
226
|
+
|
|
227
|
+
matchingProduct = await this.getDirectQty(
|
|
228
|
+
{
|
|
229
|
+
...productDetail,
|
|
230
|
+
product: targetInventory?.product
|
|
231
|
+
},
|
|
232
|
+
productBarcode,
|
|
233
|
+
packedQty
|
|
222
234
|
)
|
|
223
235
|
|
|
224
|
-
|
|
236
|
+
//validate matching product details based on scanned barcode
|
|
237
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
225
238
|
|
|
226
|
-
|
|
227
|
-
packedQty *= childQty
|
|
228
|
-
} else if (!productDetail) {
|
|
229
|
-
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
239
|
+
packedQty = matchingProduct.qty
|
|
230
240
|
}
|
|
231
241
|
|
|
232
242
|
if (packedQty + targetInventory.packedQty > pickedQty) {
|
|
@@ -242,7 +252,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
242
252
|
|
|
243
253
|
let foundSerialNumber: InventoryItem = await this.trxMgr
|
|
244
254
|
.getRepository(InventoryItem)
|
|
245
|
-
.findOne({ where: { domain: this.domain, serialNumber: serialNumber,
|
|
255
|
+
.findOne({ where: { domain: this.domain, serialNumber: serialNumber, productDetail } })
|
|
246
256
|
|
|
247
257
|
if (foundSerialNumber) {
|
|
248
258
|
if (foundSerialNumber.inventoryId !== inventory.id) {
|
|
@@ -269,6 +279,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
269
279
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
270
280
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
271
281
|
inventoryItem.product = product
|
|
282
|
+
inventoryItem.productDetail = productDetail
|
|
272
283
|
inventoryItem.inventory = inventory
|
|
273
284
|
inventoryItem.domain = this.domain
|
|
274
285
|
|