@things-factory/worksheet-base 4.3.137 → 4.3.138
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 +59 -73
- 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 +5 -4
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +23 -23
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +78 -45
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +14 -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 +7 -7
- 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/find-sorting-release-orders-by-task-no.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/find-sorting-release-orders-by-task-no.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/packing-worksheet.js +4 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.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/transfer.js +9 -9
- package/dist-server/graphql/resolvers/worksheet/transfer.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.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 +16 -16
- package/server/controllers/inbound/unloading-worksheet-controller.ts +74 -86
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +2 -4
- package/server/controllers/outbound/loading-worksheet-controller.ts +13 -3
- package/server/controllers/outbound/packing-worksheet-controller.ts +32 -37
- package/server/controllers/outbound/picking-worksheet-controller.ts +94 -59
- package/server/controllers/outbound/sorting-worksheet-controller.ts +14 -21
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +15 -10
- 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/find-sorting-release-orders-by-task-no.ts +2 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +3 -1
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +4 -2
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +3 -2
- package/server/graphql/resolvers/worksheet/transfer.ts +18 -16
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +1 -1
- 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
|
+
let 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,35 +160,24 @@ 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
|
-
|
|
181
|
-
} else {
|
|
182
|
-
uom = foundProductDetail.uom
|
|
183
|
-
qty
|
|
184
|
-
}
|
|
175
|
+
qty = matchingProduct.qty
|
|
176
|
+
uom = arrivalNotice ? targetProduct.uom : matchingProduct.uom
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!uom) {
|
|
180
|
+
uom = productDetail.uom
|
|
185
181
|
}
|
|
186
182
|
|
|
187
183
|
const uomValue: number =
|
|
@@ -200,6 +196,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
200
196
|
newInventory.cartonId = inventory.cartonId
|
|
201
197
|
newInventory.batchId = batchId
|
|
202
198
|
newInventory.product = product
|
|
199
|
+
newInventory.productDetail = productDetail
|
|
203
200
|
newInventory.packingType = packingType
|
|
204
201
|
newInventory.packingSize = packingSize
|
|
205
202
|
newInventory.uom = uom
|
|
@@ -241,6 +238,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
241
238
|
targetProduct.actualPackQty += qty
|
|
242
239
|
targetProduct.status = ORDER_PRODUCT_STATUS.UNLOADED
|
|
243
240
|
targetProduct.updater = this.user
|
|
241
|
+
targetProduct.productDetail = productDetail
|
|
244
242
|
this.updateOrderTargets([targetProduct])
|
|
245
243
|
} else if (returnOrder) {
|
|
246
244
|
targetInventory.actualPalletQty++
|
|
@@ -270,9 +268,11 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
270
268
|
'worksheet.bufferLocation.warehouse',
|
|
271
269
|
'targetProduct',
|
|
272
270
|
'targetProduct.product',
|
|
271
|
+
'targetProduct.productDetail',
|
|
273
272
|
'targetProduct.product.productDetails',
|
|
274
273
|
'targetProduct.product.productDetails.childProductDetail',
|
|
275
274
|
'targetInventory',
|
|
275
|
+
'targetInventory.productDetail',
|
|
276
276
|
'targetInventory.product',
|
|
277
277
|
'targetInventory.product.productDetails',
|
|
278
278
|
'targetInventory.product.productDetails.childProductDetail'
|
|
@@ -289,7 +289,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
289
289
|
|
|
290
290
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
291
291
|
|
|
292
|
-
if (targetProduct
|
|
292
|
+
if (targetProduct?.status == ORDER_PRODUCT_STATUS.EDITED)
|
|
293
293
|
throw new Error('this product is pending for changes approval')
|
|
294
294
|
|
|
295
295
|
const bizplace: Bizplace = worksheetDetail.bizplace
|
|
@@ -298,6 +298,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
298
298
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
299
299
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
300
300
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
301
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
302
|
+
? targetProduct.productDetail
|
|
303
|
+
: targetInventory.productDetail
|
|
301
304
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
302
305
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
303
306
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
@@ -309,15 +312,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
309
312
|
|
|
310
313
|
qty++
|
|
311
314
|
|
|
312
|
-
const invQb: SelectQueryBuilder<Inventory> =
|
|
315
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
313
316
|
.getRepository(Inventory)
|
|
314
317
|
.createQueryBuilder('INV')
|
|
315
318
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
316
319
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
317
|
-
.andWhere('INV.
|
|
320
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
318
321
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
319
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
320
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
321
322
|
|
|
322
323
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
323
324
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -357,6 +358,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
357
358
|
newInventory.batchId = batchId
|
|
358
359
|
newInventory.batchIdRef = batchIdRef
|
|
359
360
|
newInventory.product = product
|
|
361
|
+
newInventory.productDetail = productDetail
|
|
360
362
|
newInventory.packingType = packingType
|
|
361
363
|
newInventory.packingSize = packingSize
|
|
362
364
|
newInventory.uom = uom
|
|
@@ -421,6 +423,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
421
423
|
inventoryItem.status = foundInventory.status
|
|
422
424
|
inventoryItem.inboundOrderId = foundInventory.refOrderId
|
|
423
425
|
inventoryItem.product = product
|
|
426
|
+
inventoryItem.productDetail = productDetail
|
|
424
427
|
inventoryItem.inventory = foundInventory
|
|
425
428
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.INBOUND
|
|
426
429
|
inventoryItem.domain = this.domain
|
|
@@ -457,10 +460,12 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
457
460
|
'worksheet.bufferLocation.warehouse',
|
|
458
461
|
'targetProduct',
|
|
459
462
|
'targetProduct.product',
|
|
463
|
+
'targetProduct.productDetail',
|
|
460
464
|
'targetProduct.product.productDetails',
|
|
461
465
|
'targetProduct.product.productDetails.childProductDetail',
|
|
462
466
|
'targetInventory',
|
|
463
467
|
'targetInventory.product',
|
|
468
|
+
'targetInventory.productDetail',
|
|
464
469
|
'targetInventory.product.productDetails',
|
|
465
470
|
'targetInventory.product.productDetails.childProductDetail'
|
|
466
471
|
]
|
|
@@ -485,56 +490,41 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
485
490
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
486
491
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
487
492
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
493
|
+
let productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
494
|
+
? targetProduct.productDetail
|
|
495
|
+
: targetInventory.productDetail
|
|
488
496
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
489
497
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
490
498
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
491
|
-
let qty: number =
|
|
499
|
+
let qty: number = 1
|
|
492
500
|
let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : targetInventory.uom
|
|
493
501
|
const cartonId: string = inventory.cartonId
|
|
494
502
|
const orderId: string = Boolean(arrivalNotice) ? arrivalNotice.id : returnOrder.id
|
|
495
503
|
await this.checkCartonDuplication(cartonId, orderId)
|
|
504
|
+
let matchingProduct
|
|
496
505
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
(detail: ProductDetail) =>
|
|
505
|
-
detail.gtin === productBarcode && detail.packingType === packingType && detail.packingSize == packingSize
|
|
506
|
+
matchingProduct = await this.getDirectQty(
|
|
507
|
+
{
|
|
508
|
+
...productDetail,
|
|
509
|
+
product: targetInventory?.product
|
|
510
|
+
},
|
|
511
|
+
productBarcode,
|
|
512
|
+
qty
|
|
506
513
|
)
|
|
507
514
|
|
|
508
|
-
|
|
509
|
-
|
|
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
|
-
)
|
|
515
|
+
//validate matching product details based on scanned barcode
|
|
516
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
517
517
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
} else {
|
|
521
|
-
uom = orderProductDetail.uom
|
|
522
|
-
}
|
|
523
|
-
qty = await this.getChildQty(productDetails, productBarcode, orderProductDetail)
|
|
524
|
-
} else {
|
|
525
|
-
uom = foundProductDetail.uom
|
|
526
|
-
qty++
|
|
527
|
-
}
|
|
518
|
+
qty = matchingProduct.qty
|
|
519
|
+
uom = arrivalNotice ? targetProduct.uom : matchingProduct.uom
|
|
528
520
|
|
|
529
|
-
const invQb: SelectQueryBuilder<Inventory> =
|
|
521
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
530
522
|
.getRepository(Inventory)
|
|
531
523
|
.createQueryBuilder('INV')
|
|
532
524
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
533
525
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
534
|
-
.andWhere('INV.
|
|
526
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
535
527
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
536
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
537
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
538
528
|
|
|
539
529
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
540
530
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -574,6 +564,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
574
564
|
newInventory.batchId = batchId
|
|
575
565
|
newInventory.batchIdRef = batchIdRef
|
|
576
566
|
newInventory.product = product
|
|
567
|
+
newInventory.productDetail = productDetail
|
|
577
568
|
newInventory.packingType = packingType
|
|
578
569
|
newInventory.packingSize = packingSize
|
|
579
570
|
newInventory.uom = uom
|
|
@@ -627,13 +618,16 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
627
618
|
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
628
619
|
100
|
|
629
620
|
) / 100
|
|
621
|
+
foundInventory.productDetail = productDetail
|
|
630
622
|
if (arrivalNotice) targetProduct.actualPackQty = targetProduct.actualPackQty + qty
|
|
631
623
|
else if (returnOrder) targetInventory.actualPackQty = targetInventory.actualPackQty + qty
|
|
624
|
+
|
|
632
625
|
await this.trxMgr.getRepository(Inventory).save(foundInventory)
|
|
633
626
|
}
|
|
634
627
|
|
|
635
628
|
if (arrivalNotice) {
|
|
636
629
|
targetProduct.updater = this.user
|
|
630
|
+
targetProduct.productDetail = productDetail
|
|
637
631
|
this.updateOrderTargets([targetProduct])
|
|
638
632
|
} else if (returnOrder) {
|
|
639
633
|
targetInventory.updater = this.user
|
|
@@ -656,8 +650,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
656
650
|
'worksheet.bufferLocation.warehouse',
|
|
657
651
|
'targetProduct',
|
|
658
652
|
'targetProduct.product',
|
|
653
|
+
'targetProduct.productDetail',
|
|
659
654
|
'targetInventory',
|
|
660
|
-
'targetInventory.product'
|
|
655
|
+
'targetInventory.product',
|
|
656
|
+
'targetInventory.productDetail'
|
|
661
657
|
]
|
|
662
658
|
})
|
|
663
659
|
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
@@ -668,9 +664,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
668
664
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
669
665
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
670
666
|
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
|
|
667
|
+
const productDetail: Product = Boolean(arrivalNotice) ? targetProduct.productDetail : targetInventory.productDetail
|
|
674
668
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
675
669
|
|
|
676
670
|
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
@@ -678,10 +672,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
678
672
|
.createQueryBuilder('INV')
|
|
679
673
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
680
674
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
681
|
-
.andWhere('INV.
|
|
675
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
682
676
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
683
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
684
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
685
677
|
|
|
686
678
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
687
679
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -714,7 +706,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
714
706
|
const inventoryId: string = inventoryIds[i]
|
|
715
707
|
let inventory: Inventory = await this.trxMgr.getRepository(Inventory).findOne({
|
|
716
708
|
where: { domain: this.domain, id: inventoryId },
|
|
717
|
-
relations: ['location', 'product']
|
|
709
|
+
relations: ['location', 'product', 'productDetail']
|
|
718
710
|
})
|
|
719
711
|
|
|
720
712
|
this.checkRecordValidity(inventory, {
|
|
@@ -744,14 +736,11 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
744
736
|
if (orderType === ORDER_TYPES.ARRIVAL_NOTICE) {
|
|
745
737
|
arrivalNotice = await this.trxMgr.getRepository(ArrivalNotice).findOne({
|
|
746
738
|
where: { domain: this.domain, name: orderNo },
|
|
747
|
-
relations: ['orderProducts', 'orderProducts.product']
|
|
739
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.productDetail']
|
|
748
740
|
})
|
|
749
741
|
|
|
750
742
|
targetProduct = arrivalNotice.orderProducts.find(
|
|
751
|
-
op =>
|
|
752
|
-
op.batchId == inventory.batchId &&
|
|
753
|
-
op.packingType == inventory.packingType &&
|
|
754
|
-
op.product.id === inventory.product.id
|
|
743
|
+
op => op.batchId == inventory.batchId && op.productDetail.id == inventory.productDetail.id
|
|
755
744
|
)
|
|
756
745
|
|
|
757
746
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
@@ -770,18 +759,17 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
770
759
|
worksheetDetail = await this.trxMgr
|
|
771
760
|
.getRepository(WorksheetDetail)
|
|
772
761
|
.findOne({ where: { domain: this.domain, targetProduct } })
|
|
762
|
+
|
|
763
|
+
//remove all related serial numbers
|
|
764
|
+
await this.trxMgr.getRepository(InventoryItem).delete({ inventory: inventoryId })
|
|
773
765
|
} else {
|
|
774
766
|
returnOrder = await this.trxMgr.getRepository(ReturnOrder).findOne({
|
|
775
767
|
where: { domain: this.domain, name: orderNo },
|
|
776
|
-
relations: ['orderInventories', 'orderInventories.inventory', 'orderInventories.
|
|
768
|
+
relations: ['orderInventories', 'orderInventories.inventory', 'orderInventories.productDetail']
|
|
777
769
|
})
|
|
778
770
|
|
|
779
771
|
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
|
|
772
|
+
oi => oi.batchId == inventory.batchId && oi.productDetail.id == inventory.productDetail.id
|
|
785
773
|
)
|
|
786
774
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
787
775
|
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,16 @@ import {
|
|
|
12
12
|
OrderToteItem,
|
|
13
13
|
ReleaseGood
|
|
14
14
|
} from '@things-factory/sales-base'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
generateInventoryHistory,
|
|
17
|
+
Inventory,
|
|
18
|
+
INVENTORY_TRANSACTION_TYPE,
|
|
19
|
+
Tote,
|
|
20
|
+
TOTE_STATUS
|
|
21
|
+
} from '@things-factory/warehouse-base'
|
|
16
22
|
|
|
17
23
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
18
24
|
import { Worksheet, WorksheetDetail } from '../../entities'
|
|
19
|
-
import { generateInventoryHistory } from '../../utils'
|
|
20
25
|
import { VasWorksheetController } from '../vas/vas-worksheet-controller'
|
|
21
26
|
|
|
22
27
|
export class LoadingWorksheetController extends VasWorksheetController {
|
|
@@ -48,7 +53,7 @@ export class LoadingWorksheetController extends VasWorksheetController {
|
|
|
48
53
|
{ domain: this.domain, name: releaseGoodNo },
|
|
49
54
|
['bizplace']
|
|
50
55
|
)
|
|
51
|
-
return await this.
|
|
56
|
+
return await this.updateLoadWorksheet(
|
|
52
57
|
WORKSHEET_TYPE.LOADING,
|
|
53
58
|
releaseGood,
|
|
54
59
|
worksheet,
|
|
@@ -114,9 +119,13 @@ export class LoadingWorksheetController extends VasWorksheetController {
|
|
|
114
119
|
WORKSHEET_TYPE.LOADING,
|
|
115
120
|
[
|
|
116
121
|
'worksheet',
|
|
122
|
+
|
|
117
123
|
'targetInventory',
|
|
124
|
+
|
|
118
125
|
'targetInventory.inventory',
|
|
126
|
+
|
|
119
127
|
'targetInventory.product',
|
|
128
|
+
'targetInventory.productDetail',
|
|
120
129
|
'targetInventory.orderProduct'
|
|
121
130
|
]
|
|
122
131
|
)
|
|
@@ -176,6 +185,7 @@ export class LoadingWorksheetController extends VasWorksheetController {
|
|
|
176
185
|
newTargetInventory.releaseQty = remainQty
|
|
177
186
|
newTargetInventory.releaseUomValue = remainUomValue
|
|
178
187
|
newTargetInventory.product = targetInventory.product
|
|
188
|
+
newTargetInventory.productDetail = targetInventory.productDetail
|
|
179
189
|
newTargetInventory.packingType = targetInventory.packingType
|
|
180
190
|
newTargetInventory.batchId = targetInventory.batchId
|
|
181
191
|
newTargetInventory.orderProduct = targetInventory.orderProduct
|
|
@@ -2,7 +2,7 @@ import { Equal, Not } from 'typeorm'
|
|
|
2
2
|
|
|
3
3
|
import { ApplicationType } from '@things-factory/auth-base'
|
|
4
4
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
5
|
-
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
5
|
+
import { Product, ProductDetail, ProductBarcode } from '@things-factory/product-base'
|
|
6
6
|
import { logger } from '@things-factory/env'
|
|
7
7
|
import { ORDER_INVENTORY_STATUS, ORDER_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
8
8
|
import { Setting } from '@things-factory/setting-base'
|
|
@@ -141,13 +141,15 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
141
141
|
'targetInventory.releaseGood',
|
|
142
142
|
'targetInventory.inventory',
|
|
143
143
|
'targetInventory.inventory.location',
|
|
144
|
-
'targetInventory.product'
|
|
144
|
+
'targetInventory.product',
|
|
145
|
+
'targetInventory.productDetail'
|
|
145
146
|
]
|
|
146
147
|
)
|
|
147
|
-
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
148
148
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
149
|
-
const product: Product = targetInventory.product
|
|
150
149
|
let inventory: Inventory = targetInventory.inventory
|
|
150
|
+
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
151
|
+
const product: Product = targetInventory.product
|
|
152
|
+
const productDetail: ProductDetail = targetInventory.productDetail
|
|
151
153
|
const pickedQty: number = targetInventory.releaseQty
|
|
152
154
|
|
|
153
155
|
if (packedQty > pickedQty) {
|
|
@@ -162,8 +164,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
let foundSerialNumber: InventoryItem = await this.trxMgr.getRepository(InventoryItem).findOne({
|
|
165
|
-
where: { domain: this.domain, serialNumber: serialNumber,
|
|
166
|
-
relations: ['product', 'inventory']
|
|
167
|
+
where: { domain: this.domain, serialNumber: serialNumber, productDetail }
|
|
167
168
|
})
|
|
168
169
|
|
|
169
170
|
if (foundSerialNumber) {
|
|
@@ -187,6 +188,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
187
188
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
188
189
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
189
190
|
inventoryItem.product = product
|
|
191
|
+
inventoryItem.productDetail = productDetail
|
|
190
192
|
inventoryItem.inventory = inventory
|
|
191
193
|
inventoryItem.domain = this.domain
|
|
192
194
|
|
|
@@ -233,47 +235,39 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
233
235
|
.innerJoinAndSelect('oi.releaseGood', 'rg')
|
|
234
236
|
.innerJoinAndSelect('oi.inventory', 'inv')
|
|
235
237
|
.leftJoinAndSelect('oi.orderProduct', 'op')
|
|
236
|
-
.innerJoinAndSelect('
|
|
237
|
-
.
|
|
238
|
-
|
|
239
|
-
'pd',
|
|
240
|
-
'pd.product_id = oi.product_id AND pd.deleted_at is null AND pd.packing_type = oi.packing_type AND pd.packing_size = oi.packing_size AND pd.uom = oi.uom'
|
|
241
|
-
)
|
|
238
|
+
.innerJoinAndSelect('oi.product', 'prd')
|
|
239
|
+
.innerJoinAndSelect('oi.productDetail', 'pd')
|
|
240
|
+
.innerJoinAndSelect('pd.productBarcodes', 'pb')
|
|
242
241
|
.where('wd.id = :id', { id: worksheetDetailName })
|
|
243
|
-
.andWhere('wd.type = :type', { type: WORKSHEET_TYPE.PACKING })
|
|
244
242
|
.getOne()
|
|
245
243
|
|
|
246
|
-
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
247
|
-
const product: Product = worksheetDetail.targetInventory.inventory.product
|
|
248
|
-
const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
249
244
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
250
245
|
let inventory: Inventory = targetInventory.inventory
|
|
251
246
|
let packedQty: number = 1
|
|
252
247
|
let pickedQty: number = targetInventory.releaseQty
|
|
248
|
+
const releaseGood: ReleaseGood = targetInventory.releaseGood
|
|
249
|
+
const product: Product = targetInventory.product
|
|
250
|
+
const productDetail: ProductDetail = targetInventory.productDetail
|
|
251
|
+
const productBarcodes: [ProductBarcode] = productDetail.productBarcodes
|
|
252
|
+
let matchingProduct
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
.find(
|
|
258
|
-
detail =>
|
|
259
|
-
detail.gtin === productBarcode &&
|
|
260
|
-
detail.packingType === inventory.packingType &&
|
|
261
|
-
detail.packingSize === inventory.packingSize
|
|
262
|
-
)
|
|
254
|
+
if (!productBarcodes.find(itm => itm.gtin == productBarcode) && product?.isRequireSerialNumberScanningOutbound) {
|
|
255
|
+
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
256
|
+
}
|
|
263
257
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
258
|
+
matchingProduct = await this.getDirectQty(
|
|
259
|
+
{
|
|
260
|
+
...productDetail,
|
|
261
|
+
product: targetInventory?.product
|
|
262
|
+
},
|
|
263
|
+
productBarcode,
|
|
264
|
+
packedQty
|
|
265
|
+
)
|
|
269
266
|
|
|
270
|
-
|
|
267
|
+
//validate matching product details based on scanned barcode
|
|
268
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
271
269
|
|
|
272
|
-
|
|
273
|
-
packedQty *= childQty
|
|
274
|
-
} else if (!productDetail) {
|
|
275
|
-
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
276
|
-
}
|
|
270
|
+
packedQty = matchingProduct.qty
|
|
277
271
|
|
|
278
272
|
if (packedQty + targetInventory.packedQty > pickedQty) {
|
|
279
273
|
throw new Error(this.ERROR_MSG.VALIDITY.CANT_PROCEED_STEP_BY('picking', `over release`))
|
|
@@ -288,7 +282,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
288
282
|
|
|
289
283
|
let foundSerialNumber: InventoryItem = await this.trxMgr
|
|
290
284
|
.getRepository(InventoryItem)
|
|
291
|
-
.findOne({ where: { domain: this.domain, serialNumber: serialNumber,
|
|
285
|
+
.findOne({ where: { domain: this.domain, serialNumber: serialNumber, productDetail } })
|
|
292
286
|
|
|
293
287
|
if (foundSerialNumber) {
|
|
294
288
|
if (foundSerialNumber.inventoryId !== inventory.id) {
|
|
@@ -315,6 +309,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
315
309
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
316
310
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
317
311
|
inventoryItem.product = product
|
|
312
|
+
inventoryItem.productDetail = productDetail
|
|
318
313
|
inventoryItem.inventory = inventory
|
|
319
314
|
inventoryItem.domain = this.domain
|
|
320
315
|
|