@things-factory/worksheet-base 4.3.108 → 4.3.109
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 +73 -58
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +6 -7
- 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 +24 -33
- 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/check-stock-take-current-location.js +39 -43
- package/dist-server/graphql/resolvers/worksheet/check-stock-take-current-location.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/packing-worksheet.js +1 -4
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +3 -3
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.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/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-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 +86 -72
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +6 -7
- package/server/controllers/outbound/loading-worksheet-controller.ts +3 -9
- package/server/controllers/outbound/packing-worksheet-controller.ts +36 -41
- 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/check-stock-take-current-location.ts +50 -52
- 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/packing-worksheet.ts +2 -4
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +3 -3
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +2 -3
- package/server/graphql/resolvers/worksheet/transfer.ts +16 -18
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +1 -1
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +2 -3
- package/server/graphql/resolvers/worksheet/worksheets.ts +1 -1
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.109",
|
|
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.109",
|
|
28
|
+
"@things-factory/biz-base": "^4.3.109",
|
|
29
|
+
"@things-factory/document-template-base": "^4.3.109",
|
|
30
|
+
"@things-factory/id-rule-base": "^4.3.109",
|
|
31
|
+
"@things-factory/integration-lmd": "^4.3.109",
|
|
32
|
+
"@things-factory/integration-marketplace": "^4.3.109",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^4.3.109",
|
|
34
|
+
"@things-factory/integration-sftp": "^4.3.109",
|
|
35
|
+
"@things-factory/marketplace-base": "^4.3.109",
|
|
36
|
+
"@things-factory/notification": "^4.3.109",
|
|
37
|
+
"@things-factory/sales-base": "^4.3.109",
|
|
38
|
+
"@things-factory/setting-base": "^4.3.109",
|
|
39
|
+
"@things-factory/shell": "^4.3.109",
|
|
40
|
+
"@things-factory/transport-base": "^4.3.109",
|
|
41
|
+
"@things-factory/warehouse-base": "^4.3.109"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a1b81fa991795b27a9f30867347a3c1774d2c41b"
|
|
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 { 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,24 +153,35 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
160
153
|
}
|
|
161
154
|
|
|
162
155
|
if (productBarcode) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
product: targetInventory?.product
|
|
167
|
-
},
|
|
168
|
-
productBarcode,
|
|
169
|
-
qty
|
|
170
|
-
)
|
|
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))
|
|
171
159
|
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
const foundProductDetail: ProductDetail = productDetails.find(
|
|
161
|
+
(detail: ProductDetail) =>
|
|
162
|
+
detail.gtin === productBarcode && detail.packingType === packingType && detail.packingSize == packingSize
|
|
163
|
+
)
|
|
174
164
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
+
)
|
|
178
174
|
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
}
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
const uomValue: number =
|
|
@@ -196,7 +200,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
196
200
|
newInventory.cartonId = inventory.cartonId
|
|
197
201
|
newInventory.batchId = batchId
|
|
198
202
|
newInventory.product = product
|
|
199
|
-
newInventory.productDetail = productDetail
|
|
200
203
|
newInventory.packingType = packingType
|
|
201
204
|
newInventory.packingSize = packingSize
|
|
202
205
|
newInventory.uom = uom
|
|
@@ -267,11 +270,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
267
270
|
'worksheet.bufferLocation.warehouse',
|
|
268
271
|
'targetProduct',
|
|
269
272
|
'targetProduct.product',
|
|
270
|
-
'targetProduct.productDetail',
|
|
271
273
|
'targetProduct.product.productDetails',
|
|
272
274
|
'targetProduct.product.productDetails.childProductDetail',
|
|
273
275
|
'targetInventory',
|
|
274
|
-
'targetInventory.productDetail',
|
|
275
276
|
'targetInventory.product',
|
|
276
277
|
'targetInventory.product.productDetails',
|
|
277
278
|
'targetInventory.product.productDetails.childProductDetail'
|
|
@@ -288,7 +289,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
288
289
|
|
|
289
290
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
290
291
|
|
|
291
|
-
if (targetProduct
|
|
292
|
+
if (targetProduct.status == ORDER_PRODUCT_STATUS.EDITED)
|
|
292
293
|
throw new Error('this product is pending for changes approval')
|
|
293
294
|
|
|
294
295
|
const bizplace: Bizplace = worksheetDetail.bizplace
|
|
@@ -297,9 +298,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
297
298
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
298
299
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
299
300
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
300
|
-
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
301
|
-
? targetProduct.productDetail
|
|
302
|
-
: targetInventory.productDetail
|
|
303
301
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
304
302
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
305
303
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
@@ -311,13 +309,15 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
311
309
|
|
|
312
310
|
qty++
|
|
313
311
|
|
|
314
|
-
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
312
|
+
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
315
313
|
.getRepository(Inventory)
|
|
316
314
|
.createQueryBuilder('INV')
|
|
317
315
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
318
316
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
319
|
-
.andWhere('INV.
|
|
317
|
+
.andWhere('INV.product_id = :productId', { productId: product.id })
|
|
320
318
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
319
|
+
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
320
|
+
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
321
321
|
|
|
322
322
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
323
323
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -357,7 +357,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
357
357
|
newInventory.batchId = batchId
|
|
358
358
|
newInventory.batchIdRef = batchIdRef
|
|
359
359
|
newInventory.product = product
|
|
360
|
-
newInventory.productDetail = productDetail
|
|
361
360
|
newInventory.packingType = packingType
|
|
362
361
|
newInventory.packingSize = packingSize
|
|
363
362
|
newInventory.uom = uom
|
|
@@ -422,7 +421,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
422
421
|
inventoryItem.status = foundInventory.status
|
|
423
422
|
inventoryItem.inboundOrderId = foundInventory.refOrderId
|
|
424
423
|
inventoryItem.product = product
|
|
425
|
-
inventoryItem.productDetail = productDetail
|
|
426
424
|
inventoryItem.inventory = foundInventory
|
|
427
425
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.INBOUND
|
|
428
426
|
inventoryItem.domain = this.domain
|
|
@@ -459,12 +457,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
459
457
|
'worksheet.bufferLocation.warehouse',
|
|
460
458
|
'targetProduct',
|
|
461
459
|
'targetProduct.product',
|
|
462
|
-
'targetProduct.productDetail',
|
|
463
460
|
'targetProduct.product.productDetails',
|
|
464
461
|
'targetProduct.product.productDetails.childProductDetail',
|
|
465
462
|
'targetInventory',
|
|
466
463
|
'targetInventory.product',
|
|
467
|
-
'targetInventory.productDetail',
|
|
468
464
|
'targetInventory.product.productDetails',
|
|
469
465
|
'targetInventory.product.productDetails.childProductDetail'
|
|
470
466
|
]
|
|
@@ -489,43 +485,56 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
489
485
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
490
486
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
491
487
|
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
492
|
-
const productDetail: ProductDetail = Boolean(arrivalNotice)
|
|
493
|
-
? targetProduct.productDetail
|
|
494
|
-
: targetInventory.productDetail
|
|
495
488
|
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
496
489
|
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
497
490
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
498
|
-
let qty: number =
|
|
491
|
+
let qty: number = 0
|
|
499
492
|
let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : targetInventory.uom
|
|
500
493
|
const cartonId: string = inventory.cartonId
|
|
501
494
|
const orderId: string = Boolean(arrivalNotice) ? arrivalNotice.id : returnOrder.id
|
|
502
495
|
await this.checkCartonDuplication(cartonId, orderId)
|
|
503
|
-
let matchingProduct
|
|
504
496
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
product: targetInventory?.product
|
|
510
|
-
},
|
|
511
|
-
productBarcode,
|
|
512
|
-
qty
|
|
513
|
-
)
|
|
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))
|
|
514
501
|
|
|
515
|
-
|
|
516
|
-
|
|
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
|
+
)
|
|
517
507
|
|
|
518
|
-
|
|
519
|
-
|
|
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++
|
|
520
527
|
}
|
|
521
528
|
|
|
522
|
-
const invQb: SelectQueryBuilder<Inventory> = this.trxMgr
|
|
529
|
+
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
523
530
|
.getRepository(Inventory)
|
|
524
531
|
.createQueryBuilder('INV')
|
|
525
532
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
526
533
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
527
|
-
.andWhere('INV.
|
|
534
|
+
.andWhere('INV.product_id = :productId', { productId: product.id })
|
|
528
535
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
536
|
+
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
537
|
+
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
529
538
|
|
|
530
539
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
531
540
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -565,7 +574,6 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
565
574
|
newInventory.batchId = batchId
|
|
566
575
|
newInventory.batchIdRef = batchIdRef
|
|
567
576
|
newInventory.product = product
|
|
568
|
-
newInventory.productDetail = productDetail
|
|
569
577
|
newInventory.packingType = packingType
|
|
570
578
|
newInventory.packingSize = packingSize
|
|
571
579
|
newInventory.uom = uom
|
|
@@ -648,10 +656,8 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
648
656
|
'worksheet.bufferLocation.warehouse',
|
|
649
657
|
'targetProduct',
|
|
650
658
|
'targetProduct.product',
|
|
651
|
-
'targetProduct.productDetail',
|
|
652
659
|
'targetInventory',
|
|
653
|
-
'targetInventory.product'
|
|
654
|
-
'targetInventory.productDetail'
|
|
660
|
+
'targetInventory.product'
|
|
655
661
|
]
|
|
656
662
|
})
|
|
657
663
|
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
@@ -662,7 +668,9 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
662
668
|
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
663
669
|
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
664
670
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
665
|
-
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
|
|
666
674
|
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
667
675
|
|
|
668
676
|
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
@@ -670,8 +678,10 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
670
678
|
.createQueryBuilder('INV')
|
|
671
679
|
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
672
680
|
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
673
|
-
.andWhere('INV.
|
|
681
|
+
.andWhere('INV.product_id = :productId', { productId: product.id })
|
|
674
682
|
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
683
|
+
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
684
|
+
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
675
685
|
|
|
676
686
|
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
677
687
|
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
@@ -704,7 +714,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
704
714
|
const inventoryId: string = inventoryIds[i]
|
|
705
715
|
let inventory: Inventory = await this.trxMgr.getRepository(Inventory).findOne({
|
|
706
716
|
where: { domain: this.domain, id: inventoryId },
|
|
707
|
-
relations: ['location', 'product'
|
|
717
|
+
relations: ['location', 'product']
|
|
708
718
|
})
|
|
709
719
|
|
|
710
720
|
this.checkRecordValidity(inventory, {
|
|
@@ -734,11 +744,14 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
734
744
|
if (orderType === ORDER_TYPES.ARRIVAL_NOTICE) {
|
|
735
745
|
arrivalNotice = await this.trxMgr.getRepository(ArrivalNotice).findOne({
|
|
736
746
|
where: { domain: this.domain, name: orderNo },
|
|
737
|
-
relations: ['orderProducts', 'orderProducts.product'
|
|
747
|
+
relations: ['orderProducts', 'orderProducts.product']
|
|
738
748
|
})
|
|
739
749
|
|
|
740
750
|
targetProduct = arrivalNotice.orderProducts.find(
|
|
741
|
-
op =>
|
|
751
|
+
op =>
|
|
752
|
+
op.batchId == inventory.batchId &&
|
|
753
|
+
op.packingType == inventory.packingType &&
|
|
754
|
+
op.product.id === inventory.product.id
|
|
742
755
|
)
|
|
743
756
|
|
|
744
757
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
@@ -757,17 +770,18 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
757
770
|
worksheetDetail = await this.trxMgr
|
|
758
771
|
.getRepository(WorksheetDetail)
|
|
759
772
|
.findOne({ where: { domain: this.domain, targetProduct } })
|
|
760
|
-
|
|
761
|
-
//remove all related serial numbers
|
|
762
|
-
await this.trxMgr.getRepository(InventoryItem).delete({ inventory: inventoryId })
|
|
763
773
|
} else {
|
|
764
774
|
returnOrder = await this.trxMgr.getRepository(ReturnOrder).findOne({
|
|
765
775
|
where: { domain: this.domain, name: orderNo },
|
|
766
|
-
relations: ['orderInventories', 'orderInventories.inventory', 'orderInventories.
|
|
776
|
+
relations: ['orderInventories', 'orderInventories.inventory', 'orderInventories.product']
|
|
767
777
|
})
|
|
768
778
|
|
|
769
779
|
targetInventory = returnOrder.orderInventories.find(
|
|
770
|
-
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
|
|
771
785
|
)
|
|
772
786
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
773
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
|
|
@@ -307,10 +309,7 @@ export class CycleCountWorksheetController extends WorksheetController {
|
|
|
307
309
|
targetInventory.updater = this.user
|
|
308
310
|
await this.updateOrderTargets([targetInventory])
|
|
309
311
|
|
|
310
|
-
worksheetDetail.status =
|
|
311
|
-
targetInventory.status === ORDER_INVENTORY_STATUS.MISSING
|
|
312
|
-
? WORKSHEET_STATUS.NOT_TALLY
|
|
313
|
-
: WORKSHEET_STATUS.EXECUTING
|
|
312
|
+
worksheetDetail.status = WORKSHEET_STATUS.EXECUTING
|
|
314
313
|
worksheetDetail.updater = this.user
|
|
315
314
|
await this.trxMgr.getRepository(WorksheetDetail).save(worksheetDetail)
|
|
316
315
|
|
|
@@ -398,7 +397,7 @@ export class CycleCountWorksheetController extends WorksheetController {
|
|
|
398
397
|
targetInventory.inspectedLocation = location
|
|
399
398
|
targetInventory.creator = this.user
|
|
400
399
|
targetInventory.updater = this.user
|
|
401
|
-
await this.
|
|
400
|
+
await this.updateOrderTargets([targetInventory])
|
|
402
401
|
|
|
403
402
|
let worksheetDetail: WorksheetDetail = new WorksheetDetail()
|
|
404
403
|
worksheetDetail.domain = this.domain
|
|
@@ -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
|
|
|
@@ -187,48 +185,46 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
187
185
|
.innerJoinAndSelect('oi.releaseGood', 'rg')
|
|
188
186
|
.innerJoinAndSelect('oi.inventory', 'inv')
|
|
189
187
|
.leftJoinAndSelect('oi.orderProduct', 'op')
|
|
190
|
-
.innerJoinAndSelect('
|
|
191
|
-
.
|
|
188
|
+
.innerJoinAndSelect('inv.product', 'prd')
|
|
189
|
+
.leftJoinAndSelect(
|
|
190
|
+
'prd.productDetails',
|
|
191
|
+
'pd',
|
|
192
|
+
'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'
|
|
193
|
+
)
|
|
192
194
|
.where('wd.id = :id', { id: worksheetDetailName })
|
|
195
|
+
.andWhere('wd.type = :type', { type: WORKSHEET_TYPE.PACKING })
|
|
193
196
|
.getOne()
|
|
194
197
|
|
|
198
|
+
const releaseGood: ReleaseGood = worksheetDetail.targetInventory.releaseGood
|
|
199
|
+
const product: Product = worksheetDetail.targetInventory.inventory.product
|
|
200
|
+
const filterProductDetails: ProductDetail[] = product?.productDetails.filter(detail => !detail.deletedAt)
|
|
195
201
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
196
202
|
let inventory: Inventory = targetInventory.inventory
|
|
197
203
|
let packedQty: number = 1
|
|
198
204
|
let pickedQty: number = targetInventory.releaseQty
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const productDetail: ProductDetail =
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
|
205
|
+
|
|
206
|
+
// search for matching product barcode
|
|
207
|
+
const productDetail: ProductDetail = product?.productDetails
|
|
208
|
+
.filter(detail => !detail.deletedAt)
|
|
209
|
+
.find(
|
|
210
|
+
detail =>
|
|
211
|
+
detail.gtin === productBarcode &&
|
|
212
|
+
detail.packingType === inventory.packingType &&
|
|
213
|
+
detail.packingSize === inventory.packingSize
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
if (!productDetail && !product?.isRequireSerialNumberScanningOutbound) {
|
|
217
|
+
let roProductDetail: ProductDetail = product?.productDetails.find(
|
|
218
|
+
(parentDetail: ProductDetail) =>
|
|
219
|
+
parentDetail.packingType === inventory.packingType && parentDetail.packingSize == inventory.packingSize
|
|
226
220
|
)
|
|
227
221
|
|
|
228
|
-
|
|
229
|
-
if (!matchingProduct) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
222
|
+
roProductDetail.product = product
|
|
230
223
|
|
|
231
|
-
|
|
224
|
+
let childQty = await this.getChildQty(filterProductDetails, productBarcode, roProductDetail)
|
|
225
|
+
packedQty *= childQty
|
|
226
|
+
} else if (!productDetail) {
|
|
227
|
+
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
|
|
232
228
|
}
|
|
233
229
|
|
|
234
230
|
if (packedQty + targetInventory.packedQty > pickedQty) {
|
|
@@ -244,7 +240,7 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
244
240
|
|
|
245
241
|
let foundSerialNumber: InventoryItem = await this.trxMgr
|
|
246
242
|
.getRepository(InventoryItem)
|
|
247
|
-
.findOne({ where: { domain: this.domain, serialNumber: serialNumber,
|
|
243
|
+
.findOne({ where: { domain: this.domain, serialNumber: serialNumber, product } })
|
|
248
244
|
|
|
249
245
|
if (foundSerialNumber) {
|
|
250
246
|
if (foundSerialNumber.inventoryId !== inventory.id) {
|
|
@@ -271,7 +267,6 @@ export class PackingWorksheetController extends VasWorksheetController {
|
|
|
271
267
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
272
268
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
273
269
|
inventoryItem.product = product
|
|
274
|
-
inventoryItem.productDetail = productDetail
|
|
275
270
|
inventoryItem.inventory = inventory
|
|
276
271
|
inventoryItem.domain = this.domain
|
|
277
272
|
|