@things-factory/worksheet-base 4.1.31 → 4.1.35
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 +235 -0
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +327 -39
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-invoices.js +15 -13
- package/dist-server/controllers/render-invoices.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +14 -0
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js +16 -2
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +0 -17
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/picking/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/undo-serial-number-picking.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/picking/undo-serial-number-picking.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/index.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/scan-serial-number-unload.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/scan-serial-number-unload.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-serial-number-unload.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-serial-number-unload.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/unload.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-worksheet.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-worksheet.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +16 -0
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +1 -0
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-info.js +1 -0
- package/dist-server/graphql/types/worksheet/worksheet-info.js.map +1 -1
- package/package.json +7 -7
- package/server/controllers/inbound/unloading-worksheet-controller.ts +277 -1
- package/server/controllers/outbound/picking-worksheet-controller.ts +433 -52
- package/server/controllers/render-invoices.ts +23 -26
- package/server/controllers/worksheet-controller.ts +17 -2
- package/server/graphql/resolvers/worksheet/loading/complete-loading.ts +25 -6
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +0 -18
- package/server/graphql/resolvers/worksheet/picking/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/picking/undo-serial-number-picking.ts +24 -0
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +6 -2
- package/server/graphql/resolvers/worksheet/unloading/index.ts +4 -0
- package/server/graphql/resolvers/worksheet/unloading/scan-serial-number-unload.ts +26 -0
- package/server/graphql/resolvers/worksheet/unloading/undo-serial-number-unload.ts +24 -0
- package/server/graphql/resolvers/worksheet/unloading/unload.ts +3 -1
- package/server/graphql/resolvers/worksheet/unloading-worksheet.ts +3 -1
- package/server/graphql/types/worksheet/index.ts +16 -0
- package/server/graphql/types/worksheet/worksheet-detail-info.ts +1 -0
- package/server/graphql/types/worksheet/worksheet-info.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet-detail-info.js","sourceRoot":"","sources":["../../../../server/graphql/types/worksheet/worksheet-detail-info.ts"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,mBAAmB,GAAG,IAAA,uBAAG,EAAA
|
|
1
|
+
{"version":3,"file":"worksheet-detail-info.js","sourceRoot":"","sources":["../../../../server/graphql/types/worksheet/worksheet-detail-info.ts"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,mBAAmB,GAAG,IAAA,uBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DrC,CAAA"}
|
|
@@ -4,6 +4,7 @@ exports.WorksheetInfo = void 0;
|
|
|
4
4
|
const apollo_server_koa_1 = require("apollo-server-koa");
|
|
5
5
|
exports.WorksheetInfo = (0, apollo_server_koa_1.gql) `
|
|
6
6
|
type WorksheetInfo {
|
|
7
|
+
arrivalNotice: ArrivalNotice
|
|
7
8
|
releaseGood: ReleaseGood
|
|
8
9
|
returnOrder: ReturnOrder
|
|
9
10
|
bizplaceName: String
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet-info.js","sourceRoot":"","sources":["../../../../server/graphql/types/worksheet/worksheet-info.ts"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,aAAa,GAAG,IAAA,uBAAG,EAAA
|
|
1
|
+
{"version":3,"file":"worksheet-info.js","sourceRoot":"","sources":["../../../../server/graphql/types/worksheet/worksheet-info.ts"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,aAAa,GAAG,IAAA,uBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.35",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"@things-factory/document-template-base": "^4.1.28",
|
|
30
30
|
"@things-factory/id-rule-base": "^4.1.28",
|
|
31
31
|
"@things-factory/integration-lmd": "^4.1.28",
|
|
32
|
-
"@things-factory/integration-marketplace": "^4.1.
|
|
33
|
-
"@things-factory/integration-sellercraft": "^4.1.
|
|
32
|
+
"@things-factory/integration-marketplace": "^4.1.35",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^4.1.35",
|
|
34
34
|
"@things-factory/integration-sftp": "^4.1.28",
|
|
35
|
-
"@things-factory/marketplace-base": "^4.1.
|
|
35
|
+
"@things-factory/marketplace-base": "^4.1.35",
|
|
36
36
|
"@things-factory/notification": "^4.1.28",
|
|
37
|
-
"@things-factory/sales-base": "^4.1.
|
|
37
|
+
"@things-factory/sales-base": "^4.1.35",
|
|
38
38
|
"@things-factory/setting-base": "^4.1.28",
|
|
39
39
|
"@things-factory/shell": "^4.1.28",
|
|
40
40
|
"@things-factory/transport-base": "^4.1.28",
|
|
41
|
-
"@things-factory/warehouse-base": "^4.1.
|
|
41
|
+
"@things-factory/warehouse-base": "^4.1.35"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a7e4a62c6ab05d18879ab945ac0f10be440a5f34"
|
|
44
44
|
}
|
|
@@ -22,9 +22,11 @@ import {
|
|
|
22
22
|
import { Domain } from '@things-factory/shell'
|
|
23
23
|
import {
|
|
24
24
|
Inventory,
|
|
25
|
+
INVENTORY_ITEM_SOURCE,
|
|
25
26
|
INVENTORY_STATUS,
|
|
26
27
|
INVENTORY_TRANSACTION_TYPE,
|
|
27
28
|
InventoryHistory,
|
|
29
|
+
InventoryItem,
|
|
28
30
|
InventoryNoGenerator,
|
|
29
31
|
Location,
|
|
30
32
|
Pallet,
|
|
@@ -33,7 +35,7 @@ import {
|
|
|
33
35
|
|
|
34
36
|
import { RULE_TYPE, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
35
37
|
import { Worksheet, WorksheetDetail } from '../../entities'
|
|
36
|
-
import { DateGenerator } from '../../utils'
|
|
38
|
+
import { DateGenerator, generateInventoryHistory } from '../../utils'
|
|
37
39
|
import { VasWorksheetController } from '../vas/vas-worksheet-controller'
|
|
38
40
|
|
|
39
41
|
export type UnloadingWorksheetDetail = Partial<WorksheetDetail> & {
|
|
@@ -241,6 +243,189 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
|
|
246
|
+
async scanSerialNumberUnload(
|
|
247
|
+
worksheetDetailName: string,
|
|
248
|
+
serialNumber: string,
|
|
249
|
+
inventory: Partial<Inventory>
|
|
250
|
+
): Promise<void> {
|
|
251
|
+
const worksheetDetail: WorksheetDetail = await this.trxMgr.getRepository(WorksheetDetail).findOne({
|
|
252
|
+
where: {
|
|
253
|
+
name: worksheetDetailName,
|
|
254
|
+
status: Not(Equal(WORKSHEET_STATUS.DEACTIVATED))
|
|
255
|
+
},
|
|
256
|
+
relations: [
|
|
257
|
+
'bizplace',
|
|
258
|
+
'worksheet',
|
|
259
|
+
'worksheet.arrivalNotice',
|
|
260
|
+
'worksheet.returnOrder',
|
|
261
|
+
'worksheet.bufferLocation',
|
|
262
|
+
'worksheet.bufferLocation.warehouse',
|
|
263
|
+
'targetProduct',
|
|
264
|
+
'targetProduct.product',
|
|
265
|
+
'targetProduct.product.productDetails',
|
|
266
|
+
'targetProduct.product.productDetails.childProductDetail',
|
|
267
|
+
'targetInventory',
|
|
268
|
+
'targetInventory.product',
|
|
269
|
+
'targetInventory.product.productDetails',
|
|
270
|
+
'targetInventory.product.productDetails.childProductDetail'
|
|
271
|
+
]
|
|
272
|
+
})
|
|
273
|
+
if (!worksheetDetail) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(worksheetDetailName))
|
|
274
|
+
|
|
275
|
+
if (!inventory?.palletId)
|
|
276
|
+
inventory.palletId = await generateId({
|
|
277
|
+
domain: this.domain,
|
|
278
|
+
type: RULE_TYPE.LOT_NUMBER_ID,
|
|
279
|
+
seed: { date: DateGenerator.generateDate() }
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
const bizplace: Bizplace = worksheetDetail.bizplace
|
|
283
|
+
const worksheet: Worksheet = worksheetDetail.worksheet
|
|
284
|
+
const arrivalNotice: ArrivalNotice = worksheet.arrivalNotice
|
|
285
|
+
const returnOrder: ReturnOrder = worksheet.returnOrder
|
|
286
|
+
const targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
287
|
+
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
288
|
+
const product: Product = Boolean(arrivalNotice) ? targetProduct.product : targetInventory.product
|
|
289
|
+
const packingType: string = Boolean(arrivalNotice) ? targetProduct.packingType : targetInventory.packingType
|
|
290
|
+
const packingSize: number = Boolean(arrivalNotice) ? targetProduct.packingSize : targetInventory.packingSize
|
|
291
|
+
const batchId: string = Boolean(arrivalNotice) ? targetProduct.batchId : targetInventory.batchId
|
|
292
|
+
let qty: number = 0
|
|
293
|
+
let uom: string = Boolean(arrivalNotice) ? targetProduct.uom : targetInventory.uom
|
|
294
|
+
const cartonId: string = inventory.cartonId
|
|
295
|
+
const orderId: string = Boolean(arrivalNotice) ? arrivalNotice.id : returnOrder.id
|
|
296
|
+
await this.checkSerialNumberDuplication(serialNumber, product)
|
|
297
|
+
|
|
298
|
+
qty++
|
|
299
|
+
|
|
300
|
+
const invQb: SelectQueryBuilder<Inventory> = await this.trxMgr
|
|
301
|
+
.getRepository(Inventory)
|
|
302
|
+
.createQueryBuilder('INV')
|
|
303
|
+
.where('INV.domain_id = :domainId', { domainId: this.domain.id })
|
|
304
|
+
.andWhere('INV.bizplace_id = :bizplaceId', { bizplaceId: bizplace.id })
|
|
305
|
+
.andWhere('INV.product_id = :productId', { productId: product.id })
|
|
306
|
+
.andWhere('INV.batch_id = :batchId', { batchId: batchId })
|
|
307
|
+
.andWhere('INV.packing_type = :packingType', { packingType: packingType })
|
|
308
|
+
.andWhere('INV.packing_size = :packingSize', { packingSize: packingSize })
|
|
309
|
+
|
|
310
|
+
if (arrivalNotice) invQb.andWhere('INV.ref_order_id = :arrivalNoticeId', { arrivalNoticeId: arrivalNotice.id })
|
|
311
|
+
else if (returnOrder) invQb.andWhere('INV.ref_order_id = :returnOrderId', { returnOrderId: returnOrder.id })
|
|
312
|
+
|
|
313
|
+
if (inventory?.expirationDate) {
|
|
314
|
+
invQb.andWhere('INV.expiration_date = :expirationDate', {
|
|
315
|
+
expirationDate: inventory.expirationDate
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (inventory?.cartonId) invQb.andWhere('INV.carton_id = :cartonId', { cartonId: inventory.cartonId })
|
|
320
|
+
else invQb.andWhere('INV.pallet_id = :palletId', { palletId: inventory.palletId })
|
|
321
|
+
|
|
322
|
+
let foundInventory: Inventory = await invQb.getOne()
|
|
323
|
+
|
|
324
|
+
const batchIdRef: string = Boolean(arrivalNotice) ? targetProduct.batchIdRef : null
|
|
325
|
+
const remark: string = Boolean(arrivalNotice) ? targetProduct.remark : targetInventory.remark
|
|
326
|
+
const manufactureDate: number = Boolean(arrivalNotice) ? targetProduct.manufactureDate : null
|
|
327
|
+
const location: Location = worksheet.bufferLocation
|
|
328
|
+
const warehouse: Warehouse = location.warehouse
|
|
329
|
+
const zone: string = location.zone
|
|
330
|
+
const unitCost: number = Boolean(arrivalNotice)
|
|
331
|
+
? targetProduct?.unitPrice
|
|
332
|
+
? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
|
|
333
|
+
(1 + targetProduct.taxRate / 100)) /
|
|
334
|
+
targetProduct.packQty
|
|
335
|
+
: 0
|
|
336
|
+
: null
|
|
337
|
+
|
|
338
|
+
if (!foundInventory) {
|
|
339
|
+
let newInventory: Partial<Inventory> = new Inventory()
|
|
340
|
+
newInventory.bizplace = bizplace
|
|
341
|
+
newInventory.domain = this.domain
|
|
342
|
+
newInventory.name = InventoryNoGenerator.inventoryName()
|
|
343
|
+
newInventory.palletId = inventory.palletId
|
|
344
|
+
newInventory.cartonId = inventory.cartonId
|
|
345
|
+
newInventory.batchId = batchId
|
|
346
|
+
newInventory.batchIdRef = batchIdRef
|
|
347
|
+
newInventory.product = product
|
|
348
|
+
newInventory.packingType = packingType
|
|
349
|
+
newInventory.packingSize = packingSize
|
|
350
|
+
newInventory.uom = uom
|
|
351
|
+
newInventory.remark = remark
|
|
352
|
+
newInventory.qty = qty
|
|
353
|
+
newInventory.uomValue =
|
|
354
|
+
Math.round(
|
|
355
|
+
qty *
|
|
356
|
+
(Boolean(arrivalNotice)
|
|
357
|
+
? targetProduct.uomValue
|
|
358
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
359
|
+
100
|
|
360
|
+
) / 100
|
|
361
|
+
newInventory.manufactureDate = manufactureDate
|
|
362
|
+
newInventory.refOrderId = orderId
|
|
363
|
+
newInventory.unitCost = unitCost
|
|
364
|
+
if (inventory.reusablePallet?.id) {
|
|
365
|
+
newInventory.reusablePallet = await this.trxMgr.getRepository(Pallet).findOne(inventory.reusablePallet.id)
|
|
366
|
+
}
|
|
367
|
+
newInventory.orderProductId = Boolean(arrivalNotice) ? targetProduct.id : null
|
|
368
|
+
newInventory.orderInventoryId = Boolean(returnOrder) ? targetInventory.id : null
|
|
369
|
+
newInventory.warehouse = warehouse
|
|
370
|
+
newInventory.location = location
|
|
371
|
+
newInventory.zone = zone
|
|
372
|
+
newInventory.status = INVENTORY_STATUS.CHECKED
|
|
373
|
+
newInventory.creator = this.user
|
|
374
|
+
|
|
375
|
+
if (inventory?.expirationDate) {
|
|
376
|
+
newInventory.expirationDate = new Date(inventory.expirationDate)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (arrivalNotice) {
|
|
380
|
+
targetProduct.actualPalletQty++
|
|
381
|
+
targetProduct.actualPackQty = Boolean(targetProduct.actualPackQty) ? targetProduct.actualPackQty + qty : qty
|
|
382
|
+
} else if (returnOrder) {
|
|
383
|
+
targetInventory.actualPalletQty++
|
|
384
|
+
targetInventory.actualPackQty = Boolean(targetInventory.actualPackQty)
|
|
385
|
+
? targetInventory.actualPackQty + qty
|
|
386
|
+
: qty
|
|
387
|
+
}
|
|
388
|
+
foundInventory = await this.trxMgr.getRepository(Inventory).save(newInventory)
|
|
389
|
+
} else {
|
|
390
|
+
const updatedQty: number = foundInventory.qty + qty
|
|
391
|
+
foundInventory.expirationDate = new Date(foundInventory.expirationDate)
|
|
392
|
+
foundInventory.qty = updatedQty
|
|
393
|
+
foundInventory.uomValue +=
|
|
394
|
+
Math.round(
|
|
395
|
+
qty *
|
|
396
|
+
(Boolean(arrivalNotice)
|
|
397
|
+
? targetProduct.uomValue
|
|
398
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
399
|
+
100
|
|
400
|
+
) / 100
|
|
401
|
+
if (arrivalNotice) targetProduct.actualPackQty = targetProduct.actualPackQty + qty
|
|
402
|
+
else if (returnOrder) targetInventory.actualPackQty = targetInventory.actualPackQty + qty
|
|
403
|
+
foundInventory = await this.trxMgr.getRepository(Inventory).save(foundInventory)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
let inventoryItem: InventoryItem = new InventoryItem()
|
|
407
|
+
inventoryItem.name = InventoryNoGenerator.inventoryItemName()
|
|
408
|
+
inventoryItem.serialNumber = serialNumber
|
|
409
|
+
inventoryItem.status = foundInventory.status
|
|
410
|
+
inventoryItem.inboundOrderId = foundInventory.refOrderId
|
|
411
|
+
inventoryItem.product = product
|
|
412
|
+
inventoryItem.inventory = foundInventory
|
|
413
|
+
inventoryItem.source = INVENTORY_ITEM_SOURCE.INBOUND
|
|
414
|
+
inventoryItem.domain = this.domain
|
|
415
|
+
inventoryItem.creator = this.user
|
|
416
|
+
inventoryItem.updater = this.user
|
|
417
|
+
|
|
418
|
+
await this.trxMgr.getRepository(InventoryItem).save(inventoryItem)
|
|
419
|
+
|
|
420
|
+
if (arrivalNotice) {
|
|
421
|
+
targetProduct.updater = this.user
|
|
422
|
+
this.updateOrderTargets([targetProduct])
|
|
423
|
+
} else if (returnOrder) {
|
|
424
|
+
targetInventory.updater = this.user
|
|
425
|
+
this.updateOrderTargets([targetInventory])
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
244
429
|
async scanProductUnload(
|
|
245
430
|
worksheetDetailName: string,
|
|
246
431
|
productBarcode: string,
|
|
@@ -656,6 +841,60 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
656
841
|
}
|
|
657
842
|
}
|
|
658
843
|
|
|
844
|
+
async undoSerialNumberUnload(worksheetDetailName: string, inventoryItemId: string): Promise<void> {
|
|
845
|
+
const worksheetDetail: WorksheetDetail = await this.trxMgr.getRepository(WorksheetDetail).findOne({
|
|
846
|
+
where: { name: worksheetDetailName, domain: this.domain, status: Not(Equal(WORKSHEET_STATUS.DEACTIVATED)) },
|
|
847
|
+
relations: [
|
|
848
|
+
'worksheet',
|
|
849
|
+
'worksheet.arrivalNotice',
|
|
850
|
+
'worksheet.returnOrder',
|
|
851
|
+
'targetProduct',
|
|
852
|
+
'targetProduct.product'
|
|
853
|
+
]
|
|
854
|
+
})
|
|
855
|
+
|
|
856
|
+
let worksheet: Worksheet = worksheetDetail.worksheet
|
|
857
|
+
let arrivalNotice: ArrivalNotice = worksheet.arrivalNotice
|
|
858
|
+
let returnOrder: ReturnOrder = worksheet.returnOrder
|
|
859
|
+
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
860
|
+
let targetProduct: OrderProduct = worksheetDetail.targetProduct
|
|
861
|
+
let inventoryItem: InventoryItem = await this.trxMgr.getRepository(InventoryItem).findOne({
|
|
862
|
+
where: { domain: this.domain, id: inventoryItemId },
|
|
863
|
+
relations: ['inventory', 'product']
|
|
864
|
+
})
|
|
865
|
+
let inventory: Inventory = inventoryItem.inventory
|
|
866
|
+
|
|
867
|
+
await this.trxMgr.getRepository(InventoryItem).delete(inventoryItem.id)
|
|
868
|
+
|
|
869
|
+
inventory.qty--
|
|
870
|
+
inventory.uomValue =
|
|
871
|
+
Math.round(
|
|
872
|
+
inventory.qty *
|
|
873
|
+
(Boolean(arrivalNotice)
|
|
874
|
+
? targetProduct.uomValue
|
|
875
|
+
: targetInventory.returnUomValue / targetInventory.returnQty) *
|
|
876
|
+
100
|
|
877
|
+
) / 100
|
|
878
|
+
await this.trxMgr
|
|
879
|
+
.getRepository(Inventory)
|
|
880
|
+
.update({ id: inventory.id }, { qty: inventory.qty, uomValue: inventory.uomValue })
|
|
881
|
+
|
|
882
|
+
targetProduct.actualPackQty--
|
|
883
|
+
|
|
884
|
+
const inventoryItems: InventoryItem[] = await this.trxMgr.getRepository(InventoryItem).find({
|
|
885
|
+
where: { domain: this.domain, inboundOrderId: arrivalNotice.id, inventory }
|
|
886
|
+
})
|
|
887
|
+
|
|
888
|
+
if (inventoryItems?.length == 0) {
|
|
889
|
+
await this.trxMgr.getRepository(Inventory).delete(inventory.id)
|
|
890
|
+
|
|
891
|
+
targetProduct.actualPalletQty--
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
targetProduct.updater = this.user
|
|
895
|
+
await this.updateOrderTargets([targetProduct])
|
|
896
|
+
}
|
|
897
|
+
|
|
659
898
|
async activateUnloading(
|
|
660
899
|
worksheetNo: string,
|
|
661
900
|
unloadingWorksheetDetails: UnloadingWorksheetDetail[]
|
|
@@ -785,6 +1024,43 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
785
1024
|
await this.completeWorksheet(worksheet)
|
|
786
1025
|
}
|
|
787
1026
|
|
|
1027
|
+
const inventories: Inventory[] = await this.trxMgr.getRepository(Inventory).find({
|
|
1028
|
+
where: {
|
|
1029
|
+
domain: this.domain,
|
|
1030
|
+
refOrderId: arrivalNotice.id,
|
|
1031
|
+
status: In([INVENTORY_STATUS.UNLOADED, INVENTORY_STATUS.CHECKED])
|
|
1032
|
+
},
|
|
1033
|
+
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
|
|
1034
|
+
})
|
|
1035
|
+
|
|
1036
|
+
for (let inventory of inventories) {
|
|
1037
|
+
let inventoryItems: InventoryItem[] = await this.trxMgr.getRepository(InventoryItem).find({
|
|
1038
|
+
where: { domain: this.domain, inventory }
|
|
1039
|
+
})
|
|
1040
|
+
|
|
1041
|
+
if (inventoryItems?.length) {
|
|
1042
|
+
inventory.status = INVENTORY_STATUS.STORED
|
|
1043
|
+
|
|
1044
|
+
await Promise.all(
|
|
1045
|
+
inventoryItems.map(async inventoryItem => {
|
|
1046
|
+
await this.trxMgr
|
|
1047
|
+
.getRepository(InventoryItem)
|
|
1048
|
+
.update({ id: inventoryItem.id }, { status: INVENTORY_STATUS.STORED })
|
|
1049
|
+
})
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1052
|
+
await generateInventoryHistory(
|
|
1053
|
+
inventory,
|
|
1054
|
+
arrivalNotice,
|
|
1055
|
+
INVENTORY_TRANSACTION_TYPE.UNLOADING,
|
|
1056
|
+
inventory.qty,
|
|
1057
|
+
inventory.uomValue,
|
|
1058
|
+
this.user,
|
|
1059
|
+
this.trxMgr
|
|
1060
|
+
)
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
788
1064
|
let vasWorksheet: Worksheet = await this.trxMgr.getRepository(Worksheet).findOne({
|
|
789
1065
|
where: {
|
|
790
1066
|
arrivalNotice,
|