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