@things-factory/worksheet-base 4.3.103 → 4.3.105-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 +56 -72
- 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 +51 -34
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +78 -48
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +12 -14
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-orientage-do.js +2 -2
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +1 -2
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +3 -8
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +3 -2
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +29 -62
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +1 -2
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +6 -6
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/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/scan-product-packing.js +5 -22
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +39 -59
- 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/worksheets.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheets.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/index.js +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/dist-server/utils/worksheet-util.js +1 -3
- package/dist-server/utils/worksheet-util.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/inbound/unloading-worksheet-controller.ts +70 -85
- 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 +61 -51
- package/server/controllers/outbound/picking-worksheet-controller.ts +98 -66
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/render-orientage-do.ts +2 -3
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +18 -23
- package/server/entities/index.ts +2 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +29 -63
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +6 -0
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +1 -2
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +3 -1
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +5 -24
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +58 -95
- 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/worksheets.ts +1 -1
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +4 -1
- package/server/graphql/types/worksheet/index.ts +1 -1
- package/server/graphql/types/worksheet-detail/index.ts +1 -0
- package/server/utils/inventory-util.ts +1 -126
- package/server/utils/worksheet-util.ts +1 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet-util.js","sourceRoot":"","sources":["../../server/utils/worksheet-util.ts"],"names":[],"mappings":";;;AACA,2DAA8F;AAE9F,qCAAkF;AAClF,4CAA+C;AAC/C,0CAAuC;AAEhC,KAAK,UAAU,uBAAuB,CAC3C,MAAc,EACd,QAAkB,EAClB,SAAmB,EACnB,IAA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|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.105-alpha.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/auth-base": "^4.3.
|
|
28
|
-
"@things-factory/biz-base": "^4.3.
|
|
29
|
-
"@things-factory/document-template-base": "^4.3.
|
|
30
|
-
"@things-factory/id-rule-base": "^4.3.
|
|
31
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
32
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
33
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
34
|
-
"@things-factory/integration-sftp": "^4.3.
|
|
35
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
36
|
-
"@things-factory/notification": "^4.3.
|
|
37
|
-
"@things-factory/sales-base": "^4.3.
|
|
38
|
-
"@things-factory/setting-base": "^4.3.
|
|
39
|
-
"@things-factory/shell": "^4.3.
|
|
40
|
-
"@things-factory/transport-base": "^4.3.
|
|
41
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
27
|
+
"@things-factory/auth-base": "^4.3.105-alpha.0",
|
|
28
|
+
"@things-factory/biz-base": "^4.3.105-alpha.0",
|
|
29
|
+
"@things-factory/document-template-base": "^4.3.105-alpha.0",
|
|
30
|
+
"@things-factory/id-rule-base": "^4.3.105-alpha.0",
|
|
31
|
+
"@things-factory/integration-lmd": "^4.3.105-alpha.0",
|
|
32
|
+
"@things-factory/integration-marketplace": "^4.3.105-alpha.0",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^4.3.105-alpha.0",
|
|
34
|
+
"@things-factory/integration-sftp": "^4.3.105-alpha.0",
|
|
35
|
+
"@things-factory/marketplace-base": "^4.3.105-alpha.0",
|
|
36
|
+
"@things-factory/notification": "^4.3.105-alpha.0",
|
|
37
|
+
"@things-factory/sales-base": "^4.3.105-alpha.0",
|
|
38
|
+
"@things-factory/setting-base": "^4.3.105-alpha.0",
|
|
39
|
+
"@things-factory/shell": "^4.3.105-alpha.0",
|
|
40
|
+
"@things-factory/transport-base": "^4.3.105-alpha.0",
|
|
41
|
+
"@things-factory/warehouse-base": "^4.3.105-alpha.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "3bf9a95c5f77324220346e5109880a171ee2a13d"
|
|
44
44
|
}
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
VAS_TARGET_TYPES,
|
|
20
20
|
VAS_TYPES
|
|
21
21
|
} from '@things-factory/sales-base'
|
|
22
|
-
import { Domain } from '@things-factory/shell'
|
|
23
22
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
23
|
+
import { Domain } from '@things-factory/shell'
|
|
24
24
|
import {
|
|
25
25
|
Inventory,
|
|
26
26
|
INVENTORY_ITEM_SOURCE,
|
|
@@ -31,12 +31,13 @@ import {
|
|
|
31
31
|
InventoryNoGenerator,
|
|
32
32
|
Location,
|
|
33
33
|
Pallet,
|
|
34
|
-
Warehouse
|
|
34
|
+
Warehouse,
|
|
35
|
+
generateInventoryHistory
|
|
35
36
|
} from '@things-factory/warehouse-base'
|
|
36
37
|
|
|
37
38
|
import { RULE_TYPE, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
38
39
|
import { Worksheet, WorksheetDetail } from '../../entities'
|
|
39
|
-
import { DateGenerator
|
|
40
|
+
import { DateGenerator } from '../../utils'
|
|
40
41
|
import { VasWorksheetController } from '../vas/vas-worksheet-controller'
|
|
41
42
|
|
|
42
43
|
export type UnloadingWorksheetDetail = Partial<WorksheetDetail> & {
|
|
@@ -95,11 +96,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
95
96
|
'worksheet.bufferLocation.warehouse',
|
|
96
97
|
'targetProduct',
|
|
97
98
|
'targetProduct.product',
|
|
99
|
+
'targetProduct.productDetail',
|
|
98
100
|
'targetProduct.product.productDetails',
|
|
99
101
|
'targetProduct.product.productDetails.childProductDetail',
|
|
100
102
|
'targetInventory',
|
|
101
103
|
'targetInventory.inventory',
|
|
102
104
|
'targetInventory.product',
|
|
105
|
+
'targetInventory.productDetail',
|
|
103
106
|
'targetInventory.product.productDetails',
|
|
104
107
|
'targetInventory.product.productDetails.childProductDetail'
|
|
105
108
|
]
|
|
@@ -121,6 +124,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
121
124
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
122
125
|
const batchIdRef: string = Boolean(arrivalNotice) ? targetProduct.batchIdRef : null
|
|
123
126
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
127
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
128
|
+
? targetProduct.productDetail
|
|
129
|
+
: targetInventory.productDetail
|
|
124
130
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
125
131
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
126
132
|
const remark: string = Boolean(arrivalNotice) ? targetProduct.remark : targetInventory.remark
|
|
@@ -140,6 +146,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
140
146
|
|
|
141
147
|
const palletId: string = inventory?.palletId
|
|
142
148
|
const cartonId: string = inventory?.cartonId
|
|
149
|
+
let matchingProduct
|
|
143
150
|
|
|
144
151
|
if (!inventory?.palletId) {
|
|
145
152
|
inventory.palletId = await generateId({
|
|
@@ -153,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
|
|
@@ -270,6 +267,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
270
267
|
'worksheet.bufferLocation.warehouse',
|
|
271
268
|
'targetProduct',
|
|
272
269
|
'targetProduct.product',
|
|
270
|
+
'targetProduct.productDetail',
|
|
273
271
|
'targetProduct.product.productDetails',
|
|
274
272
|
'targetProduct.product.productDetails.childProductDetail',
|
|
275
273
|
'targetInventory',
|
|
@@ -298,6 +296,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
298
296
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
299
297
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
300
298
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
299
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
300
|
+
? targetProduct.productDetail
|
|
301
|
+
: targetInventory.productDetail
|
|
301
302
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
302
303
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
303
304
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
@@ -309,15 +310,13 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
309
310
|
|
|
310
311
|
qty++
|
|
311
312
|
|
|
312
|
-
const invQb: SelectQueryBuilder<Inventory> =
|
|
313
|
+
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
313
314
|
.getRepository(Inventory)
|
|
314
315
|
.createQueryBuilder('INV')
|
|
315
316
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
316
317
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
317
|
-
.andWhere('INV.
|
|
318
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
318
319
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
319
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
320
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
321
320
|
|
|
322
321
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
323
322
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -357,6 +356,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
357
356
|
newInventory.batchId = batchId
|
|
358
357
|
newInventory.batchIdRef = batchIdRef
|
|
359
358
|
newInventory.product = product
|
|
359
|
+
newInventory.productDetail = productDetail
|
|
360
360
|
newInventory.packingType = packingType
|
|
361
361
|
newInventory.packingSize = packingSize
|
|
362
362
|
newInventory.uom = uom
|
|
@@ -421,6 +421,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
421
421
|
inventoryItem.status = foundInventory.status
|
|
422
422
|
inventoryItem.inboundOrderId = foundInventory.refOrderId
|
|
423
423
|
inventoryItem.product = product
|
|
424
|
+
inventoryItem.productDetail = productDetail
|
|
424
425
|
inventoryItem.inventory = foundInventory
|
|
425
426
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.INBOUND
|
|
426
427
|
inventoryItem.domain = this.domain
|
|
@@ -457,10 +458,12 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
457
458
|
'worksheet.bufferLocation.warehouse',
|
|
458
459
|
'targetProduct',
|
|
459
460
|
'targetProduct.product',
|
|
461
|
+
'targetProduct.productDetail',
|
|
460
462
|
'targetProduct.product.productDetails',
|
|
461
463
|
'targetProduct.product.productDetails.childProductDetail',
|
|
462
464
|
'targetInventory',
|
|
463
465
|
'targetInventory.product',
|
|
466
|
+
'targetInventory.productDetail',
|
|
464
467
|
'targetInventory.product.productDetails',
|
|
465
468
|
'targetInventory.product.productDetails.childProductDetail'
|
|
466
469
|
]
|
|
@@ -485,56 +488,43 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
485
488
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
486
489
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
487
490
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
491
|
+
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
492
|
+
? targetProduct.productDetail
|
|
493
|
+
: targetInventory.productDetail
|
|
488
494
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
489
495
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
490
496
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
491
|
-
let qty: number =
|
|
497
|
+
let qty: number = 1
|
|
492
498
|
let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : targetInventory.uom
|
|
493
499
|
const cartonId: string = inventory.cartonId
|
|
494
500
|
const orderId: string = Boolean(arrivalNotice) ? arrivalNotice.id : returnOrder.id
|
|
495
501
|
await this.checkCartonDuplication(cartonId, orderId)
|
|
502
|
+
let matchingProduct
|
|
496
503
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
detail.gtin === productBarcode && detail.packingType === packingType && detail.packingSize == packingSize
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
if (!foundProductDetail) {
|
|
509
|
-
const orderProductDetail: ProductDetail = productDetails.find(
|
|
510
|
-
(parentDetail: ProductDetail) =>
|
|
511
|
-
parentDetail.packingType === packingType && parentDetail.packingSize == packingSize
|
|
504
|
+
if (productBarcode !== productDetail.gtin) {
|
|
505
|
+
matchingProduct = await this.getDirectQty(
|
|
506
|
+
{
|
|
507
|
+
...productDetail,
|
|
508
|
+
product: targetInventory?.product
|
|
509
|
+
},
|
|
510
|
+
productBarcode,
|
|
511
|
+
qty
|
|
512
512
|
)
|
|
513
|
-
if (!orderProductDetail)
|
|
514
|
-
throw new Error(
|
|
515
|
-
this.ERROR_MSG.FIND.NO_RESULT(`Packing Type ( ${packingType}) or Packing Size (${packingSize})`)
|
|
516
|
-
)
|
|
517
513
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
qty = await this.getChildQty(productDetails, productBarcode, orderProductDetail)
|
|
524
|
-
} else {
|
|
525
|
-
uom = foundProductDetail.uom
|
|
526
|
-
qty++
|
|
514
|
+
//validate matching product details based on scanned barcode
|
|
515
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
516
|
+
|
|
517
|
+
qty = matchingProduct.qty
|
|
518
|
+
uom = arrivalNotice ? targetProduct.uom : matchingProduct.uom
|
|
527
519
|
}
|
|
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
|
|
@@ -656,8 +647,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
656
647
|
'worksheet.bufferLocation.warehouse',
|
|
657
648
|
'targetProduct',
|
|
658
649
|
'targetProduct.product',
|
|
650
|
+
'targetProduct.productDetail',
|
|
659
651
|
'targetInventory',
|
|
660
|
-
'targetInventory.product'
|
|
652
|
+
'targetInventory.product',
|
|
653
|
+
'targetInventory.productDetail'
|
|
661
654
|
]
|
|
662
655
|
})
|
|
663
656
|
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
@@ -668,9 +661,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
668
661
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
669
662
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
670
663
|
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
|
|
664
|
+
const productDetail: Product = Boolean(arrivalNotice) ? targetProduct.productDetail : targetInventory.productDetail
|
|
674
665
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
675
666
|
|
|
676
667
|
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
@@ -678,10 +669,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
678
669
|
.createQueryBuilder('INV')
|
|
679
670
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
680
671
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
681
|
-
.andWhere('INV.
|
|
672
|
+
.andWhere('INV.product_detail_id = :productDetailId', { productDetailId: productDetail.id })
|
|
682
673
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
683
|
-
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
684
|
-
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
685
674
|
|
|
686
675
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
687
676
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -714,7 +703,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
714
703
|
const inventoryId: string = inventoryIds[i]
|
|
715
704
|
let inventory: Inventory = await this.trxMgr.getRepository(Inventory).findOne({
|
|
716
705
|
where: { domain: this.domain, id: inventoryId },
|
|
717
|
-
relations: ['location', 'product']
|
|
706
|
+
relations: ['location', 'product', 'productDetail']
|
|
718
707
|
})
|
|
719
708
|
|
|
720
709
|
this.checkRecordValidity(inventory, {
|
|
@@ -744,14 +733,11 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
744
733
|
if (orderType === ORDER_TYPES.ARRIVAL_NOTICE) {
|
|
745
734
|
arrivalNotice = await this.trxMgr.getRepository(ArrivalNotice).findOne({
|
|
746
735
|
where: { domain: this.domain, name: orderNo },
|
|
747
|
-
relations: ['orderProducts', 'orderProducts.product']
|
|
736
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.productDetail']
|
|
748
737
|
})
|
|
749
738
|
|
|
750
739
|
targetProduct = arrivalNotice.orderProducts.find(
|
|
751
|
-
op =>
|
|
752
|
-
op.batchId == inventory.batchId &&
|
|
753
|
-
op.packingType == inventory.packingType &&
|
|
754
|
-
op.product.id === inventory.product.id
|
|
740
|
+
op => op.batchId == inventory.batchId && op.productDetail.id == inventory.productDetail.id
|
|
755
741
|
)
|
|
756
742
|
|
|
757
743
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
@@ -770,18 +756,17 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
770
756
|
worksheetDetail = await this.trxMgr
|
|
771
757
|
.getRepository(WorksheetDetail)
|
|
772
758
|
.findOne({ where: { domain: this.domain, targetProduct } })
|
|
759
|
+
|
|
760
|
+
//remove all related serial numbers
|
|
761
|
+
await this.trxMgr.getRepository(InventoryItem).delete({ inventory: inventoryId })
|
|
773
762
|
} else {
|
|
774
763
|
returnOrder = await this.trxMgr.getRepository(ReturnOrder).findOne({
|
|
775
764
|
where: { domain: this.domain, name: orderNo },
|
|
776
|
-
relations: ['orderInventories', 'orderInventories.inventory', 'orderInventories.
|
|
765
|
+
relations: ['orderInventories', 'orderInventories.inventory', 'orderInventories.productDetail']
|
|
777
766
|
})
|
|
778
767
|
|
|
779
768
|
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
|
|
769
|
+
oi => oi.batchId == inventory.batchId && oi.productDetail.id == inventory.productDetail.id
|
|
785
770
|
)
|
|
786
771
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
787
772
|
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
|
|
|
@@ -176,57 +178,57 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
176
178
|
return worksheetDetail
|
|
177
179
|
}
|
|
178
180
|
|
|
179
|
-
async scanProductPacking(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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)
|
|
181
|
+
async scanProductPacking(worksheetDetailName: string, productBarcode: string, serialNumber?: string): Promise<any> {
|
|
182
|
+
let worksheetDetail: WorksheetDetail = await this.trxMgr
|
|
183
|
+
.getRepository(WorksheetDetail)
|
|
184
|
+
.createQueryBuilder('wd')
|
|
185
|
+
.innerJoinAndSelect('wd.bizplace', 'b') //
|
|
186
|
+
.innerJoinAndSelect('wd.targetInventory', 'oi')
|
|
187
|
+
.innerJoinAndSelect('oi.releaseGood', 'rg')
|
|
188
|
+
.innerJoinAndSelect('oi.inventory', 'inv')
|
|
189
|
+
.leftJoinAndSelect('oi.orderProduct', 'op')
|
|
190
|
+
.innerJoinAndSelect('oi.product', 'prd')
|
|
191
|
+
.innerJoinAndSelect('oi.productDetail', 'pd')
|
|
192
|
+
.where('wd.id = :id', { id: worksheetDetailName })
|
|
193
|
+
.getOne()
|
|
194
|
+
|
|
203
195
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
204
196
|
let inventory: Inventory = targetInventory.inventory
|
|
205
197
|
let packedQty: number = 1
|
|
206
198
|
let pickedQty: number = targetInventory.releaseQty
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const productDetail: ProductDetail =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
199
|
+
const releaseGood: ReleaseGood = targetInventory.releaseGood
|
|
200
|
+
const product: Product = targetInventory.inventory.product
|
|
201
|
+
const productDetail: ProductDetail = targetInventory.productDetail
|
|
202
|
+
let matchingProduct
|
|
203
|
+
|
|
204
|
+
// // search for matching product barcode
|
|
205
|
+
// const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
206
|
+
// const scannedProductDetail: ProductDetail = filterProductDetails.find(detail => detail.gtin == productBarcode)
|
|
207
|
+
// if (!scannedProductDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
208
|
+
|
|
209
|
+
// // case for scanning parent packing type, packing size
|
|
210
|
+
// // when scannedProductDetail id is not the same as productDetail id, then it's not child gtin, proceed to get child qty
|
|
211
|
+
// if (scannedProductDetail.id !== productDetail.id && !product?.isRequireSerialNumberScanningOutbound) {
|
|
212
|
+
// let childQty = await this.getChildQty(filterProductDetails, productBarcode, productDetail, scannedProductDetail)
|
|
213
|
+
// packedQty *= childQty
|
|
214
|
+
// }
|
|
215
|
+
|
|
216
|
+
if (productBarcode !== productDetail.gtin) {
|
|
217
|
+
if (product?.isRequireSerialNumberScanningOutbound) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
218
|
+
|
|
219
|
+
matchingProduct = await this.getDirectQty(
|
|
220
|
+
{
|
|
221
|
+
...productDetail,
|
|
222
|
+
product: targetInventory?.product
|
|
223
|
+
},
|
|
224
|
+
productBarcode,
|
|
225
|
+
packedQty
|
|
222
226
|
)
|
|
223
227
|
|
|
224
|
-
|
|
228
|
+
//validate matching product details based on scanned barcode
|
|
229
|
+
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
225
230
|
|
|
226
|
-
|
|
227
|
-
packedQty *= childQty
|
|
228
|
-
} else if (!productDetail) {
|
|
229
|
-
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
231
|
+
packedQty = matchingProduct.qty
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
if (packedQty + targetInventory.packedQty > pickedQty) {
|
|
@@ -242,7 +244,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
242
244
|
|
|
243
245
|
let foundSerialNumber: InventoryItem = await this.trxMgr
|
|
244
246
|
.getRepository(InventoryItem)
|
|
245
|
-
.findOne({ where: { domain: this.domain, serialNumber: serialNumber,
|
|
247
|
+
.findOne({ where: { domain: this.domain, serialNumber: serialNumber, productDetail } })
|
|
246
248
|
|
|
247
249
|
if (foundSerialNumber) {
|
|
248
250
|
if (foundSerialNumber.inventoryId !== inventory.id) {
|
|
@@ -269,6 +271,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
269
271
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
270
272
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
271
273
|
inventoryItem.product = product
|
|
274
|
+
inventoryItem.productDetail = productDetail
|
|
272
275
|
inventoryItem.inventory = inventory
|
|
273
276
|
inventoryItem.domain = this.domain
|
|
274
277
|
|
|
@@ -316,7 +319,14 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
316
319
|
await this.trxMgr.getRepository(OrderInventory).save(targetInventory)
|
|
317
320
|
}
|
|
318
321
|
|
|
319
|
-
return
|
|
322
|
+
return {
|
|
323
|
+
worksheetDetailInfos: [{
|
|
324
|
+
id: worksheetDetail.id,
|
|
325
|
+
releaseQty: worksheetDetail.targetInventory.releaseQty,
|
|
326
|
+
packedQty: worksheetDetail.targetInventory.packedQty,
|
|
327
|
+
status: worksheetDetail.status,
|
|
328
|
+
}]
|
|
329
|
+
}
|
|
320
330
|
}
|
|
321
331
|
|
|
322
332
|
async completePacking(releaseGoodNo: string): Promise<Worksheet> {
|