@things-factory/worksheet-base 4.3.79-alpha.0 → 4.3.80-alpha.0
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/unloading-worksheet-controller.js +49 -49
- 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 +22 -20
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +34 -39
- 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 +2 -3
- package/dist-server/controllers/worksheet-controller.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/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/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/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-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 +5 -5
- package/server/controllers/inbound/unloading-worksheet-controller.ts +49 -70
- 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 +23 -31
- package/server/controllers/outbound/picking-worksheet-controller.ts +34 -51
- 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 +4 -6
- 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/inventories-by-pallet.ts +3 -1
- 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/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-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
|
|
@@ -154,32 +160,19 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
154
160
|
|
|
155
161
|
if (productBarcode) {
|
|
156
162
|
const productDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
159
|
-
|
|
160
|
-
const foundProductDetail: ProductDetail = productDetails.find(
|
|
161
|
-
(detail: ProductDetail) =>
|
|
162
|
-
detail.gtin === productBarcode && detail.packingType === packingType && detail.packingSize == packingSize
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
if (!foundProductDetail) {
|
|
166
|
-
const orderProductDetail: ProductDetail = productDetails.find(
|
|
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
|
-
)
|
|
163
|
+
const scannedProductDetail: ProductDetail = productDetails.find(detail => detail.gtin == productBarcode)
|
|
164
|
+
if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
174
165
|
|
|
166
|
+
if (scannedProductDetail.id !== productDetail.id) {
|
|
167
|
+
let childQty = await this.getChildQty(productDetails, productBarcode, productDetail, scannedProductDetail)
|
|
175
168
|
if (arrivalNotice) {
|
|
176
169
|
uom = targetProduct.uom
|
|
177
170
|
} else {
|
|
178
|
-
uom =
|
|
171
|
+
uom = productDetail.uom
|
|
179
172
|
}
|
|
180
|
-
qty
|
|
173
|
+
qty *= childQty
|
|
181
174
|
} else {
|
|
182
|
-
uom =
|
|
175
|
+
uom = scannedProductDetail.uom
|
|
183
176
|
qty
|
|
184
177
|
}
|
|
185
178
|
}
|
|
@@ -200,6 +193,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
200
193
|
newInventory.cartonId = inventory.cartonId
|
|
201
194
|
newInventory.batchId = batchId
|
|
202
195
|
newInventory.product = product
|
|
196
|
+
newInventory.productDetail = productDetail
|
|
203
197
|
newInventory.packingType = packingType
|
|
204
198
|
newInventory.packingSize = packingSize
|
|
205
199
|
newInventory.uom = uom
|
|
@@ -270,6 +264,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
270
264
|
'worksheet.bufferLocation.warehouse',
|
|
271
265
|
'targetProduct',
|
|
272
266
|
'targetProduct.product',
|
|
267
|
+
'targetProduct.productDetail',
|
|
273
268
|
'targetProduct.product.productDetails',
|
|
274
269
|
'targetProduct.product.productDetails.childProductDetail',
|
|
275
270
|
'targetInventory',
|
|
@@ -298,6 +293,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
298
293
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
299
294
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
300
295
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
296
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
297
|
+
? targetProduct.productDetail
|
|
298
|
+
: targetInventory.productDetail
|
|
301
299
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
302
300
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
303
301
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
@@ -309,15 +307,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
309
307
|
|
|
310
308
|
qty++
|
|
311
309
|
|
|
312
|
-
const invQb: SelectQueryBuilder<Inventory> =
|
|
310
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
313
311
|
.getRepository(Inventory)
|
|
314
312
|
.createQueryBuilder('INV')
|
|
315
313
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
316
314
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
317
|
-
.andWhere('INV.
|
|
315
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
318
316
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
319
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
320
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
321
317
|
|
|
322
318
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
323
319
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -357,6 +353,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
357
353
|
newInventory.batchId = batchId
|
|
358
354
|
newInventory.batchIdRef = batchIdRef
|
|
359
355
|
newInventory.product = product
|
|
356
|
+
newInventory.productDetail = productDetail
|
|
360
357
|
newInventory.packingType = packingType
|
|
361
358
|
newInventory.packingSize = packingSize
|
|
362
359
|
newInventory.uom = uom
|
|
@@ -421,6 +418,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
421
418
|
inventoryItem.status = foundInventory.status
|
|
422
419
|
inventoryItem.inboundOrderId = foundInventory.refOrderId
|
|
423
420
|
inventoryItem.product = product
|
|
421
|
+
inventoryItem.productDetail = productDetail
|
|
424
422
|
inventoryItem.inventory = foundInventory
|
|
425
423
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.INBOUND
|
|
426
424
|
inventoryItem.domain = this.domain
|
|
@@ -457,10 +455,12 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
457
455
|
'worksheet.bufferLocation.warehouse',
|
|
458
456
|
'targetProduct',
|
|
459
457
|
'targetProduct.product',
|
|
458
|
+
'targetProduct.productDetail',
|
|
460
459
|
'targetProduct.product.productDetails',
|
|
461
460
|
'targetProduct.product.productDetails.childProductDetail',
|
|
462
461
|
'targetInventory',
|
|
463
462
|
'targetInventory.product',
|
|
463
|
+
'targetInventory.productDetail',
|
|
464
464
|
'targetInventory.product.productDetails',
|
|
465
465
|
'targetInventory.product.productDetails.childProductDetail'
|
|
466
466
|
]
|
|
@@ -485,6 +485,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
485
485
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
486
486
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
487
487
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
488
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
489
|
+
? targetProduct.productDetail
|
|
490
|
+
: targetInventory.productDetail
|
|
488
491
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
489
492
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
490
493
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
@@ -496,45 +499,29 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
496
499
|
|
|
497
500
|
// search for matching product barcode
|
|
498
501
|
const productDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
499
|
-
const
|
|
500
|
-
if (!
|
|
501
|
-
|
|
502
|
-
// case for scanning parent packing type, packing size
|
|
503
|
-
const foundProductDetail: ProductDetail = productDetails.find(
|
|
504
|
-
(detail: ProductDetail) =>
|
|
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
|
|
512
|
-
)
|
|
513
|
-
if (!orderProductDetail)
|
|
514
|
-
throw new Error(
|
|
515
|
-
this.ERROR_MSG.FIND.NO_RESULT(`Packing Type ( ${packingType}) or Packing Size (${packingSize})`)
|
|
516
|
-
)
|
|
502
|
+
const scannedProductDetail: ProductDetail = productDetails.find(detail => detail.gtin == productBarcode)
|
|
503
|
+
if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
517
504
|
|
|
505
|
+
if (scannedProductDetail.id !== productDetail.id && arrivalNotice) {
|
|
506
|
+
let childQty = await this.getChildQty(productDetails, productBarcode, productDetail, scannedProductDetail)
|
|
518
507
|
if (arrivalNotice) {
|
|
519
508
|
uom = targetProduct.uom
|
|
520
509
|
} else {
|
|
521
|
-
uom =
|
|
510
|
+
uom = productDetail.uom
|
|
522
511
|
}
|
|
523
|
-
qty =
|
|
512
|
+
qty = childQty
|
|
524
513
|
} else {
|
|
525
|
-
uom =
|
|
514
|
+
uom = scannedProductDetail.uom
|
|
526
515
|
qty++
|
|
527
516
|
}
|
|
528
517
|
|
|
529
|
-
const invQb: SelectQueryBuilder<Inventory> =
|
|
518
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
530
519
|
.getRepository(Inventory)
|
|
531
520
|
.createQueryBuilder('INV')
|
|
532
521
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
533
522
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
534
|
-
.andWhere('INV.
|
|
523
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
535
524
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
536
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
537
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
538
525
|
|
|
539
526
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
540
527
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -574,6 +561,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
574
561
|
newInventory.batchId = batchId
|
|
575
562
|
newInventory.batchIdRef = batchIdRef
|
|
576
563
|
newInventory.product = product
|
|
564
|
+
newInventory.productDetail = productDetail
|
|
577
565
|
newInventory.packingType = packingType
|
|
578
566
|
newInventory.packingSize = packingSize
|
|
579
567
|
newInventory.uom = uom
|
|
@@ -656,8 +644,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
656
644
|
'worksheet.bufferLocation.warehouse',
|
|
657
645
|
'targetProduct',
|
|
658
646
|
'targetProduct.product',
|
|
647
|
+
'targetProduct.productDetail',
|
|
659
648
|
'targetInventory',
|
|
660
|
-
'targetInventory.product'
|
|
649
|
+
'targetInventory.product',
|
|
650
|
+
'targetInventory.productDetail'
|
|
661
651
|
]
|
|
662
652
|
})
|
|
663
653
|
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
@@ -668,9 +658,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
668
658
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
669
659
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
670
660
|
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
|
|
661
|
+
const productDetail: Product = Boolean(arrivalNotice) ? targetProduct.productDetail : targetInventory.productDetail
|
|
674
662
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
675
663
|
|
|
676
664
|
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
@@ -678,10 +666,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
678
666
|
.createQueryBuilder('INV')
|
|
679
667
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
680
668
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
681
|
-
.andWhere('INV.
|
|
669
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
682
670
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
683
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
684
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
685
671
|
|
|
686
672
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
687
673
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -714,7 +700,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
714
700
|
const inventoryId: string = inventoryIds[i]
|
|
715
701
|
let inventory: Inventory = await this.trxMgr.getRepository(Inventory).findOne({
|
|
716
702
|
where: { domain: this.domain, id: inventoryId },
|
|
717
|
-
relations: ['location', 'product']
|
|
703
|
+
relations: ['location', 'product', 'productDetail']
|
|
718
704
|
})
|
|
719
705
|
|
|
720
706
|
this.checkRecordValidity(inventory, {
|
|
@@ -744,14 +730,11 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
744
730
|
if (orderType === ORDER_TYPES.ARRIVAL_NOTICE) {
|
|
745
731
|
arrivalNotice = await this.trxMgr.getRepository(ArrivalNotice).findOne({
|
|
746
732
|
where: { domain: this.domain, name: orderNo },
|
|
747
|
-
relations: ['orderProducts', 'orderProducts.product']
|
|
733
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.productDetail']
|
|
748
734
|
})
|
|
749
735
|
|
|
750
736
|
targetProduct = arrivalNotice.orderProducts.find(
|
|
751
|
-
op =>
|
|
752
|
-
op.batchId == inventory.batchId &&
|
|
753
|
-
op.packingType == inventory.packingType &&
|
|
754
|
-
op.product.id === inventory.product.id
|
|
737
|
+
op => op.batchId == inventory.batchId && op.productDetail.id == inventory.productDetail.id
|
|
755
738
|
)
|
|
756
739
|
|
|
757
740
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
@@ -777,11 +760,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
777
760
|
})
|
|
778
761
|
|
|
779
762
|
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
|
|
763
|
+
oi => oi.batchId == inventory.batchId && oi.productDetail.id == inventory.productDetail.id
|
|
785
764
|
)
|
|
786
765
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
787
766
|
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
|
|
|
@@ -194,39 +196,28 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
194
196
|
'targetInventory.inventory.product',
|
|
195
197
|
'targetInventory.inventory.product.productDetails',
|
|
196
198
|
'targetInventory.inventory.product.productDetails.childProductDetail',
|
|
197
|
-
'targetInventory.inventory.location'
|
|
199
|
+
'targetInventory.inventory.location',
|
|
200
|
+
'targetInventory.productDetail'
|
|
198
201
|
]
|
|
199
202
|
)
|
|
200
|
-
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
201
|
-
const product: Product = worksheetDetail.targetInventory.inventory.product
|
|
202
|
-
const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
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
|
+
const releaseGood: ReleaseGood = targetInventory.releaseGood
|
|
208
|
+
const product: Product = targetInventory.inventory.product
|
|
209
|
+
const productDetail: ProductDetail = targetInventory.productDetail
|
|
207
210
|
|
|
208
211
|
// search for matching product barcode
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
if (!productDetail && !product?.isRequireSerialNumberScanningOutbound) {
|
|
219
|
-
let roProductDetail: ProductDetail = product?.productDetails.find(
|
|
220
|
-
(parentDetail: ProductDetail) =>
|
|
221
|
-
parentDetail.packingType === inventory.packingType && parentDetail.packingSize == inventory.packingSize
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
roProductDetail.product = product
|
|
225
|
-
|
|
226
|
-
let childQty = await this.getChildQty(filterProductDetails, productBarcode, roProductDetail)
|
|
227
|
-
packedQty *= childQty
|
|
228
|
-
} else if (!productDetail) {
|
|
229
|
-
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
212
|
+
const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
213
|
+
const scannedProductDetail: ProductDetail = filterProductDetails.find(detail => detail.gtin == productBarcode)
|
|
214
|
+
if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
215
|
+
|
|
216
|
+
// case for scanning parent packing type, packing size
|
|
217
|
+
// when scannedProductDetail id is not the same as productDetail id, then it's not child gtin, proceed to get child qty
|
|
218
|
+
if (scannedProductDetail.id !== productDetail.id && !product?.isRequireSerialNumberScanningOutbound) {
|
|
219
|
+
let childQty = await this.getChildQty(filterProductDetails, productBarcode, productDetail, scannedProductDetail)
|
|
220
|
+
pickedQty *= childQty
|
|
230
221
|
}
|
|
231
222
|
|
|
232
223
|
if (packedQty + targetInventory.packedQty > pickedQty) {
|
|
@@ -242,7 +233,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
242
233
|
|
|
243
234
|
let foundSerialNumber: InventoryItem = await this.trxMgr
|
|
244
235
|
.getRepository(InventoryItem)
|
|
245
|
-
.findOne({ where: { domain: this.domain, serialNumber: serialNumber,
|
|
236
|
+
.findOne({ where: { domain: this.domain, serialNumber: serialNumber, productDetail } })
|
|
246
237
|
|
|
247
238
|
if (foundSerialNumber) {
|
|
248
239
|
if (foundSerialNumber.inventoryId !== inventory.id) {
|
|
@@ -269,6 +260,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
269
260
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
270
261
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
271
262
|
inventoryItem.product = product
|
|
263
|
+
inventoryItem.productDetail = productDetail
|
|
272
264
|
inventoryItem.inventory = inventory
|
|
273
265
|
inventoryItem.domain = this.domain
|
|
274
266
|
|