@things-factory/worksheet-base 6.2.151 → 6.2.152

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.
@@ -83,8 +83,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
83
83
  const zone = location.zone;
84
84
  const unitCost = Boolean(arrivalNotice)
85
85
  ? (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.unitPrice)
86
- ? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
87
- (1 + targetProduct.taxRate / 100)) /
86
+ ? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) * (1 + targetProduct.taxRate / 100)) /
88
87
  targetProduct.packQty
89
88
  : 0
90
89
  : null;
@@ -125,11 +124,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
125
124
  qty;
126
125
  }
127
126
  }
128
- const uomValue = Math.round(qty *
129
- (Boolean(arrivalNotice)
130
- ? targetProduct.uomValue
131
- : targetInventory.returnUomValue / targetInventory.returnQty) *
132
- 100) / 100;
127
+ const uomValue = Math.round(qty * (Boolean(arrivalNotice) ? targetProduct.uomValue : targetInventory.returnUomValue / targetInventory.returnQty) * 100) / 100;
133
128
  let newInventory = new warehouse_base_1.Inventory();
134
129
  newInventory.bizplace = bizplace;
135
130
  newInventory.name = warehouse_base_1.InventoryNoGenerator.inventoryName();
@@ -146,9 +141,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
146
141
  newInventory.refOrderId = orderId;
147
142
  newInventory.unitCost = unitCost;
148
143
  if ((_b = inventory.reusablePallet) === null || _b === void 0 ? void 0 : _b.id) {
149
- newInventory.reusablePallet = await this.trxMgr
150
- .getRepository(warehouse_base_1.Pallet)
151
- .findOneBy({ id: inventory.reusablePallet.id });
144
+ newInventory.reusablePallet = await this.trxMgr.getRepository(warehouse_base_1.Pallet).findOneBy({ id: inventory.reusablePallet.id });
152
145
  }
153
146
  if (arrivalNotice) {
154
147
  if (manufactureDate) {
@@ -274,8 +267,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
274
267
  const zone = location.zone;
275
268
  const unitCost = Boolean(arrivalNotice)
276
269
  ? (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.unitPrice)
277
- ? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
278
- (1 + targetProduct.taxRate / 100)) /
270
+ ? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) * (1 + targetProduct.taxRate / 100)) /
279
271
  targetProduct.packQty
280
272
  : 0
281
273
  : null;
@@ -294,19 +286,12 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
294
286
  newInventory.uom = uom;
295
287
  newInventory.remark = remark;
296
288
  newInventory.qty = qty;
297
- newInventory.uomValue =
298
- Math.round(qty *
299
- (Boolean(arrivalNotice)
300
- ? targetProduct.uomValue
301
- : targetInventory.returnUomValue / targetInventory.returnQty) *
302
- 100) / 100;
289
+ newInventory.uomValue = Math.round(qty * (Boolean(arrivalNotice) ? targetProduct.uomValue : targetInventory.returnUomValue / targetInventory.returnQty) * 100) / 100;
303
290
  newInventory.manufactureDate = manufactureDate;
304
291
  newInventory.refOrderId = orderId;
305
292
  newInventory.unitCost = unitCost;
306
293
  if ((_a = inventory.reusablePallet) === null || _a === void 0 ? void 0 : _a.id) {
307
- newInventory.reusablePallet = await this.trxMgr
308
- .getRepository(warehouse_base_1.Pallet)
309
- .findOneBy({ id: inventory.reusablePallet.id });
294
+ newInventory.reusablePallet = await this.trxMgr.getRepository(warehouse_base_1.Pallet).findOneBy({ id: inventory.reusablePallet.id });
310
295
  }
311
296
  newInventory.orderProductId = Boolean(arrivalNotice) ? targetProduct.id : null;
312
297
  newInventory.orderInventoryId = Boolean(returnOrder) ? targetInventory.id : null;
@@ -324,9 +309,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
324
309
  }
325
310
  else if (returnOrder) {
326
311
  targetInventory.actualPalletQty++;
327
- targetInventory.actualPackQty = Boolean(targetInventory.actualPackQty)
328
- ? targetInventory.actualPackQty + qty
329
- : qty;
312
+ targetInventory.actualPackQty = Boolean(targetInventory.actualPackQty) ? targetInventory.actualPackQty + qty : qty;
330
313
  }
331
314
  foundInventory = await this.trxMgr.getRepository(warehouse_base_1.Inventory).save(newInventory);
332
315
  }
@@ -335,11 +318,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
335
318
  foundInventory.expirationDate = foundInventory.expirationDate ? new Date(foundInventory.expirationDate) : null;
336
319
  foundInventory.qty = updatedQty;
337
320
  foundInventory.uomValue +=
338
- Math.round(qty *
339
- (Boolean(arrivalNotice)
340
- ? targetProduct.uomValue
341
- : targetInventory.returnUomValue / targetInventory.returnQty) *
342
- 100) / 100;
321
+ Math.round(qty * (Boolean(arrivalNotice) ? targetProduct.uomValue : targetInventory.returnUomValue / targetInventory.returnQty) * 100) / 100;
343
322
  if (arrivalNotice)
344
323
  targetProduct.actualPackQty = targetProduct.actualPackQty + qty;
345
324
  else if (returnOrder)
@@ -470,8 +449,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
470
449
  const zone = location.zone;
471
450
  const unitCost = Boolean(arrivalNotice)
472
451
  ? (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.unitPrice)
473
- ? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) *
474
- (1 + targetProduct.taxRate / 100)) /
452
+ ? ((targetProduct.packQty * targetProduct.unitPrice + targetProduct.miscAmt - targetProduct.discountAmt) * (1 + targetProduct.taxRate / 100)) /
475
453
  targetProduct.packQty
476
454
  : 0
477
455
  : null;
@@ -490,19 +468,12 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
490
468
  newInventory.uom = uom;
491
469
  newInventory.remark = remark;
492
470
  newInventory.qty = qty;
493
- newInventory.uomValue =
494
- Math.round(qty *
495
- (Boolean(arrivalNotice)
496
- ? targetProduct.uomValue
497
- : targetInventory.returnUomValue / targetInventory.returnQty) *
498
- 100) / 100;
471
+ newInventory.uomValue = Math.round(qty * (Boolean(arrivalNotice) ? targetProduct.uomValue : targetInventory.returnUomValue / targetInventory.returnQty) * 100) / 100;
499
472
  newInventory.manufactureDate = manufactureDate;
500
473
  newInventory.refOrderId = orderId;
501
474
  newInventory.unitCost = unitCost;
502
475
  if ((_a = inventory.reusablePallet) === null || _a === void 0 ? void 0 : _a.id) {
503
- newInventory.reusablePallet = await this.trxMgr
504
- .getRepository(warehouse_base_1.Pallet)
505
- .findOneBy({ id: inventory.reusablePallet.id });
476
+ newInventory.reusablePallet = await this.trxMgr.getRepository(warehouse_base_1.Pallet).findOneBy({ id: inventory.reusablePallet.id });
506
477
  }
507
478
  newInventory.orderProductId = Boolean(arrivalNotice) ? targetProduct.id : null;
508
479
  newInventory.orderInventoryId = Boolean(returnOrder) ? targetInventory.id : null;
@@ -520,9 +491,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
520
491
  }
521
492
  else if (returnOrder) {
522
493
  targetInventory.actualPalletQty++;
523
- targetInventory.actualPackQty = Boolean(targetInventory.actualPackQty)
524
- ? targetInventory.actualPackQty + qty
525
- : qty;
494
+ targetInventory.actualPackQty = Boolean(targetInventory.actualPackQty) ? targetInventory.actualPackQty + qty : qty;
526
495
  }
527
496
  await this.trxMgr.getRepository(warehouse_base_1.Inventory).save(newInventory);
528
497
  }
@@ -531,11 +500,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
531
500
  foundInventory.expirationDate = foundInventory.expirationDate ? new Date(foundInventory.expirationDate) : null;
532
501
  foundInventory.qty = updatedQty;
533
502
  foundInventory.uomValue +=
534
- Math.round(qty *
535
- (Boolean(arrivalNotice)
536
- ? targetProduct.uomValue
537
- : targetInventory.returnUomValue / targetInventory.returnQty) *
538
- 100) / 100;
503
+ Math.round(qty * (Boolean(arrivalNotice) ? targetProduct.uomValue : targetInventory.returnUomValue / targetInventory.returnQty) * 100) / 100;
539
504
  if (arrivalNotice)
540
505
  targetProduct.actualPackQty = targetProduct.actualPackQty + qty;
541
506
  else if (returnOrder)
@@ -637,9 +602,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
637
602
  where: { domain: { id: this.domain.id }, name: orderNo },
638
603
  relations: ['orderProducts', 'orderProducts.product']
639
604
  });
640
- targetProduct = arrivalNotice.orderProducts.find(op => op.batchId == inventory.batchId &&
641
- op.packingType == inventory.packingType &&
642
- op.product.id === inventory.product.id);
605
+ targetProduct = arrivalNotice.orderProducts.find(op => op.id === inventory.orderProductId);
643
606
  if (inventory.status == warehouse_base_1.INVENTORY_STATUS.UNLOADED) {
644
607
  targetProduct.actualPackQty -= qty;
645
608
  targetProduct.actualPalletQty--;
@@ -653,9 +616,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
653
616
  }
654
617
  targetProduct.updater = this.user;
655
618
  await this.updateOrderTargets([targetProduct]);
656
- worksheetDetail = await this.trxMgr
657
- .getRepository(entities_1.WorksheetDetail)
658
- .findOne({ where: { domain: { id: this.domain.id }, targetProduct: { id: targetProduct.id } } });
619
+ worksheetDetail = await this.trxMgr.getRepository(entities_1.WorksheetDetail).findOne({ where: { domain: { id: this.domain.id }, targetProduct: { id: targetProduct.id } } });
659
620
  }
660
621
  else {
661
622
  returnOrder = await this.trxMgr.getRepository(sales_base_1.ReturnOrder).findOne({
@@ -684,11 +645,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
684
645
  if (inventory.status == warehouse_base_1.INVENTORY_STATUS.CHECKED) {
685
646
  inventory.qty--;
686
647
  inventory.uomValue =
687
- Math.round(inventory.qty *
688
- (Boolean(orderType === sales_base_1.ORDER_TYPES.ARRIVAL_NOTICE)
689
- ? targetProduct.uomValue
690
- : targetInventory.returnUomValue) *
691
- 100) / 100;
648
+ Math.round(inventory.qty * (Boolean(orderType === sales_base_1.ORDER_TYPES.ARRIVAL_NOTICE) ? targetProduct.uomValue : targetInventory.returnUomValue) * 100) / 100;
692
649
  inventory.updater = this.user;
693
650
  await this.trxMgr.getRepository(warehouse_base_1.Inventory).save(inventory);
694
651
  if (inventory.qty == 0) {
@@ -727,13 +684,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
727
684
  domain: { id: this.domain.id },
728
685
  status: (0, typeorm_1.Not)((0, typeorm_1.Equal)(constants_1.WORKSHEET_STATUS.DEACTIVATED))
729
686
  },
730
- relations: [
731
- 'worksheet',
732
- 'worksheet.arrivalNotice',
733
- 'worksheet.returnOrder',
734
- 'targetProduct',
735
- 'targetProduct.product'
736
- ]
687
+ relations: ['worksheet', 'worksheet.arrivalNotice', 'worksheet.returnOrder', 'targetProduct', 'targetProduct.product']
737
688
  });
738
689
  let worksheet = worksheetDetail.worksheet;
739
690
  let arrivalNotice = worksheet.arrivalNotice;
@@ -748,14 +699,8 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
748
699
  await this.trxMgr.getRepository(warehouse_base_1.InventoryItem).delete(inventoryItem.id);
749
700
  inventory.qty--;
750
701
  inventory.uomValue =
751
- Math.round(inventory.qty *
752
- (Boolean(arrivalNotice)
753
- ? targetProduct.uomValue
754
- : targetInventory.returnUomValue / targetInventory.returnQty) *
755
- 100) / 100;
756
- await this.trxMgr
757
- .getRepository(warehouse_base_1.Inventory)
758
- .update({ id: inventory.id }, { qty: inventory.qty, uomValue: inventory.uomValue });
702
+ Math.round(inventory.qty * (Boolean(arrivalNotice) ? targetProduct.uomValue : targetInventory.returnUomValue / targetInventory.returnQty) * 100) / 100;
703
+ await this.trxMgr.getRepository(warehouse_base_1.Inventory).update({ id: inventory.id }, { qty: inventory.qty, uomValue: inventory.uomValue });
759
704
  targetProduct.actualPackQty--;
760
705
  const inventoryItems = await this.trxMgr.getRepository(warehouse_base_1.InventoryItem).find({
761
706
  where: { domain: { id: this.domain.id }, inboundOrderId: arrivalNotice.id, inventory: { id: inventory.id } }
@@ -901,10 +846,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
901
846
  if (arrivalNotice.orderProducts.some((op) => op.status === sales_base_1.ORDER_PRODUCT_STATUS.READY_TO_APPROVED)) {
902
847
  throw new Error(`There's non-approved order products`);
903
848
  }
904
- let worksheet = await this.findWorksheetByRefOrder(arrivalNotice, constants_1.WORKSHEET_TYPE.UNLOADING, [
905
- 'worksheetDetails',
906
- 'worksheetDetails.targetProduct'
907
- ]);
849
+ let worksheet = await this.findWorksheetByRefOrder(arrivalNotice, constants_1.WORKSHEET_TYPE.UNLOADING, ['worksheetDetails', 'worksheetDetails.targetProduct']);
908
850
  this.checkRecordValidity(worksheet, { status: constants_1.WORKSHEET_STATUS.EXECUTING });
909
851
  const partiallyUnloadedCnt = await this.trxMgr.getRepository(warehouse_base_1.Inventory).count({
910
852
  where: {
@@ -957,9 +899,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
957
899
  if (inventoryItems === null || inventoryItems === void 0 ? void 0 : inventoryItems.length) {
958
900
  inventory.status = warehouse_base_1.INVENTORY_STATUS.STORED;
959
901
  await Promise.all(inventoryItems.map(async (inventoryItem) => {
960
- await this.trxMgr
961
- .getRepository(warehouse_base_1.InventoryItem)
962
- .update({ id: inventoryItem.id }, { status: warehouse_base_1.INVENTORY_STATUS.STORED });
902
+ await this.trxMgr.getRepository(warehouse_base_1.InventoryItem).update({ id: inventoryItem.id }, { status: warehouse_base_1.INVENTORY_STATUS.STORED });
963
903
  }));
964
904
  await (0, utils_1.generateInventoryHistory)(inventory, arrivalNotice, warehouse_base_1.INVENTORY_TRANSACTION_TYPE.UNLOADING, inventory.qty, inventory.uomValue, this.user, this.trxMgr);
965
905
  }
@@ -1000,10 +940,7 @@ class UnloadingWorksheetController extends vas_worksheet_controller_1.VasWorkshe
1000
940
  name: arrivalNoticeNo,
1001
941
  status: (0, typeorm_1.In)([sales_base_1.ORDER_STATUS.PROCESSING, sales_base_1.ORDER_STATUS.PUTTING_AWAY])
1002
942
  }, ['bizplace', 'bizplace.domain']);
1003
- const worksheet = await this.findWorksheetByRefOrder(arrivalNotice, constants_1.WORKSHEET_TYPE.UNLOADING, [
1004
- 'worksheetDetails',
1005
- 'worksheetDetails.targetProduct'
1006
- ]);
943
+ const worksheet = await this.findWorksheetByRefOrder(arrivalNotice, constants_1.WORKSHEET_TYPE.UNLOADING, ['worksheetDetails', 'worksheetDetails.targetProduct']);
1007
944
  this.checkRecordValidity(worksheet, { status: constants_1.WORKSHEET_STATUS.EXECUTING });
1008
945
  let worksheetDetails = worksheet.worksheetDetails.filter(({ name: itm1 }) => unloadingWorksheetDetail.some(({ name: itm2 }) => itm2 === itm1));
1009
946
  worksheetDetails.forEach((wsds) => {