@things-factory/sales-base 4.3.79-alpha.1 → 4.3.79

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.
Files changed (61) hide show
  1. package/dist-server/service/arrival-notice/arrival-notice.js +0 -5
  2. package/dist-server/service/arrival-notice/arrival-notice.js.map +1 -1
  3. package/dist-server/service/draft-release-good/draft-release-good-mutation.js +8 -3
  4. package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
  5. package/dist-server/service/draft-release-good/draft-release-good-query.js +7 -4
  6. package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
  7. package/dist-server/service/draft-release-good/draft-release-good.js +0 -5
  8. package/dist-server/service/draft-release-good/draft-release-good.js.map +1 -1
  9. package/dist-server/service/invoice-product/invoice-product.js +3 -8
  10. package/dist-server/service/invoice-product/invoice-product.js.map +1 -1
  11. package/dist-server/service/order-inventory/order-inventory-types.js +10 -18
  12. package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
  13. package/dist-server/service/order-inventory/order-inventory.js +3 -8
  14. package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
  15. package/dist-server/service/order-product/order-product-query.js +0 -1
  16. package/dist-server/service/order-product/order-product-query.js.map +1 -1
  17. package/dist-server/service/order-product/order-product-types.js +10 -14
  18. package/dist-server/service/order-product/order-product-types.js.map +1 -1
  19. package/dist-server/service/order-vas/order-vas.js +3 -8
  20. package/dist-server/service/order-vas/order-vas.js.map +1 -1
  21. package/dist-server/service/others/other-query.js +32 -21
  22. package/dist-server/service/others/other-query.js.map +1 -1
  23. package/dist-server/service/others/other-types.js +0 -4
  24. package/dist-server/service/others/other-types.js.map +1 -1
  25. package/dist-server/service/purchase-order/purchase-order-mutation.js +2 -10
  26. package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
  27. package/dist-server/service/purchase-order/purchase-order-query.js +0 -1
  28. package/dist-server/service/purchase-order/purchase-order-query.js.map +1 -1
  29. package/dist-server/service/release-good/release-good-mutation.js +49 -187
  30. package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
  31. package/dist-server/service/release-good/release-good-query.js +6 -4
  32. package/dist-server/service/release-good/release-good-query.js.map +1 -1
  33. package/dist-server/service/release-good/release-good-types.js +4 -8
  34. package/dist-server/service/release-good/release-good-types.js.map +1 -1
  35. package/dist-server/service/release-good/release-good.js +0 -5
  36. package/dist-server/service/release-good/release-good.js.map +1 -1
  37. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +3 -8
  38. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
  39. package/dist-server/utils/inventory-util.js +102 -33
  40. package/dist-server/utils/inventory-util.js.map +1 -1
  41. package/package.json +13 -13
  42. package/server/service/arrival-notice/arrival-notice.ts +0 -4
  43. package/server/service/draft-release-good/draft-release-good-mutation.ts +12 -10
  44. package/server/service/draft-release-good/draft-release-good-query.ts +5 -5
  45. package/server/service/draft-release-good/draft-release-good.ts +0 -4
  46. package/server/service/invoice-product/invoice-product.ts +1 -5
  47. package/server/service/order-inventory/order-inventory-types.ts +0 -6
  48. package/server/service/order-inventory/order-inventory.ts +1 -5
  49. package/server/service/order-product/order-product-query.ts +0 -1
  50. package/server/service/order-product/order-product-types.ts +0 -3
  51. package/server/service/order-vas/order-vas.ts +1 -6
  52. package/server/service/others/other-query.ts +43 -34
  53. package/server/service/others/other-types.ts +0 -3
  54. package/server/service/purchase-order/purchase-order-mutation.ts +1 -10
  55. package/server/service/purchase-order/purchase-order-query.ts +0 -1
  56. package/server/service/release-good/release-good-mutation.ts +50 -221
  57. package/server/service/release-good/release-good-query.ts +7 -4
  58. package/server/service/release-good/release-good-types.ts +3 -4
  59. package/server/service/release-good/release-good.ts +6 -8
  60. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +1 -5
  61. package/server/utils/inventory-util.ts +147 -67
@@ -102,7 +102,6 @@ async function getPurchaseOrderFunction(_, name, context, tx) {
102
102
  'supplier',
103
103
  'orderProducts',
104
104
  'orderProducts.product',
105
- 'orderProducts.productDetail',
106
105
  'otherCharges',
107
106
  'bufferLocation',
108
107
  'bizplace',
@@ -1 +1 @@
1
- {"version":3,"file":"purchase-order-query.js","sourceRoot":"","sources":["../../../server/service/purchase-order/purchase-order-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAA4D;AAC5D,yDAAgD;AAChD,uDAA4E;AAC5E,iDAAuF;AACvF,+CAA6E;AAC7E,qCAA0D;AAC1D,2BAAuC;AACvC,+CAAiD;AACjD,qDAAgD;AAGhD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAE7B,KAAK,CAAC,cAAc,CACX,OAAY,EACmC,OAAkB,EACb,UAAuB,EAC1B,QAAoB;QAE5E,MAAM,YAAY,GAAG,IAAA,uBAAa,EAAC,8BAAa,CAAC,CAAC,kBAAkB,EAAE,CAAA;QACtE,IAAA,kBAAU,EAAC,YAAY,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAA;QACpE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY;aACtC,iBAAiB,CAAC,wBAAwB,EAAE,UAAU,CAAC;aACvD,iBAAiB,CAAC,sBAAsB,EAAE,QAAQ,CAAC;aACnD,iBAAiB,CAAC,uBAAuB,EAAE,SAAS,CAAC;aACrD,iBAAiB,CAAC,uBAAuB,EAAE,SAAS,CAAC;aACrD,iBAAiB,CAAC,6BAA6B,EAAE,eAAe,CAAC;aACjE,eAAe,EAAE,CAAA;QAEpB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGD,KAAK,CAAC,aAAa,CAAc,IAAY,EAAS,OAAY;QAChE,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;QACnD,OAAO,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EA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KAAK,EAAE;YACL,MAAM;YACN,KAAK,EAAE,MAAM,CAAC,EAAE;YAChB,QAAQ,EAAE,2BAAe,CAAC,EAAE;SAC7B;KACF,CAAC,CAAA;IAEF,uCACK,MAAM,KACT,UAAU,EAAE,gBAAgB,IAC7B;AACH,CAAC;AAlCD,4DAkCC"}
1
+ {"version":3,"file":"purchase-order-query.js","sourceRoot":"","sources":["../../../server/service/purchase-order/purchase-order-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAA4D;AAC5D,yDAAgD;AAChD,uDAA4E;AAC5E,iDAAuF;AACvF,+CAA6E;AAC7E,qCAA0D;AAC1D,2BAAuC;AACvC,+CAAiD;AACjD,qDAAgD;AAGhD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAE7B,KAAK,CAAC,cAAc,CACX,OAAY,EACmC,OAAkB,EACb,UAAuB,EAC1B,QAAoB;QAE5E,MAAM,YAAY,GAAG,IAAA,uBAAa,EAAC,8BAAa,CAAC,CAAC,kBAAkB,EAAE,CAAA;QACtE,IAAA,kBAAU,EAAC,YAAY,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAA;QACpE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY;aACtC,iBAAiB,CAAC,wBAAwB,EAAE,UAAU,CAAC;aACvD,iBAAiB,CAAC,sBAAsB,EAAE,QAAQ,CAAC;aACnD,iBAAiB,CAAC,uBAAuB,EAAE,SAAS,CAAC;aACrD,iBAAiB,CAAC,uBAAuB,EAAE,SAAS,CAAC;aACrD,iBAAiB,CAAC,6BAA6B,EAAE,eAAe,CAAC;aACjE,eAAe,EAAE,CAAA;QAEpB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGD,KAAK,CAAC,aAAa,CAAc,IAAY,EAAS,OAAY;QAChE,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK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AAA,uBAAa,EAAC,4BAAU,CAAC,CAAC,IAAI,CAAC;QAC1E,KAAK,EAAE;YACL,MAAM;YACN,KAAK,EAAE,MAAM,CAAC,EAAE;YAChB,QAAQ,EAAE,2BAAe,CAAC,EAAE;SAC7B;KACF,CAAC,CAAA;IAEF,uCACK,MAAM,KACT,UAAU,EAAE,gBAAgB,IAC7B;AACH,CAAC;AAjCD,4DAiCC"}
@@ -23,6 +23,7 @@ const biz_base_1 = require("@things-factory/biz-base");
23
23
  const id_rule_base_1 = require("@things-factory/id-rule-base");
24
24
  const integration_marketplace_1 = require("@things-factory/integration-marketplace");
25
25
  const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
26
+ const integration_sftp_1 = require("@things-factory/integration-sftp");
26
27
  const marketplace_base_1 = require("@things-factory/marketplace-base");
27
28
  // import { sendNotification } from '@things-factory/notification'
28
29
  const product_base_1 = require("@things-factory/product-base");
@@ -417,16 +418,20 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, shippi
417
418
  /** Validate Release Order Product Quantity */
418
419
  await utils_1.InventoryUtil.validateWarehousePartnersProductsQuantity(domain, bizplace, orderInventories, context, tx);
419
420
  /** End Validate Release Order Product Quantity Section */
420
- const orderSource = releaseGood.source;
421
- switch (orderSource) {
422
- case auth_base_1.ApplicationType.SELLERCRAFT:
423
- const sellercraft = await tx
424
- .getRepository(integration_sellercraft_1.Sellercraft)
425
- .findOne({ domain: bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
421
+ if (releaseGood.type == 'b2c') {
422
+ const sellercraft = await tx
423
+ .getRepository(integration_sellercraft_1.Sellercraft)
424
+ .findOne({ domain: bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
425
+ let customerAvailableSftp = await tx.getRepository(integration_sftp_1.Sftp).findOne({
426
+ where: { domain: bizplace.domain }
427
+ });
428
+ if (sellercraft) {
426
429
  const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
427
430
  await sellercraftCtrl.checkExistingReleaseGood(sellercraft, releaseGood);
428
- break;
429
- case auth_base_1.ApplicationType.MMS:
431
+ }
432
+ else if (customerAvailableSftp) {
433
+ }
434
+ else {
430
435
  const refNo = releaseGood.refNo;
431
436
  const foundReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).findOne({
432
437
  where: {
@@ -459,54 +464,8 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, shippi
459
464
  throw new Error('Existing release order found');
460
465
  }
461
466
  }
462
- break;
463
- default:
464
- break;
467
+ }
465
468
  }
466
- // if (releaseGood.type == 'b2c') {
467
- // const sellercraft: Sellercraft = await tx
468
- // .getRepository(Sellercraft)
469
- // .findOne({ domain: bizplace.domain, status: SellercraftStatus.ACTIVE })
470
- // let customerAvailableSftp: Sftp = await tx.getRepository(Sftp).findOne({
471
- // where: { domain: bizplace.domain }
472
- // })
473
- // if (sellercraft) {
474
- // const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
475
- // await sellercraftCtrl.checkExistingReleaseGood(sellercraft, releaseGood)
476
- // } else if (customerAvailableSftp) {
477
- // } else {
478
- // const refNo: string = releaseGood.refNo
479
- // const foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
480
- // where: {
481
- // domain: warehouseDomain,
482
- // refNo,
483
- // status: Not(In([ORDER_STATUS.CANCELLED, ORDER_STATUS.PENDING_CANCEL]))
484
- // },
485
- // relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
486
- // })
487
- // if (foundReleaseGood) {
488
- // const customerCompanyDomain: Domain = foundReleaseGood.bizplace.company.domain
489
- // const marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
490
- // where: { orderNo: refNo, domain: customerCompanyDomain }
491
- // })
492
- // // Need to restructure the validation
493
- // if (marketplaceOrder?.isSplitted) {
494
- // const refNo2: string = releaseGood.refNo2
495
- // const foundSplittedReleaseGood = await tx.getRepository(ReleaseGood).findOne({
496
- // where: {
497
- // domain: warehouseDomain,
498
- // refNo2,
499
- // status: Not(In([ORDER_STATUS.CANCELLED, ORDER_STATUS.PENDING_CANCEL]))
500
- // },
501
- // relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
502
- // })
503
- // if (foundSplittedReleaseGood) throw new Error('Existing release order found')
504
- // } else {
505
- // throw new Error('Existing release order found')
506
- // }
507
- // }
508
- // }
509
- // }
510
469
  let newReleaseGood = new release_good_1.ReleaseGood();
511
470
  /** Generate Shipping Order */
512
471
  if (shippingOrder) {
@@ -561,15 +520,13 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, shippi
561
520
  let splitOI = null;
562
521
  const pbSettings = await tx.getRepository(product_base_1.ProductBundleSetting).find({
563
522
  where: { productBundle: oi.product.id },
564
- relations: ['product', 'productBundle', 'productDetail']
523
+ relations: ['product', 'productBundle']
565
524
  });
566
525
  pbSettings.forEach(pbs => {
567
526
  splitOI = Object.assign(Object.assign({}, oi), { releaseQty: oi.releaseQty * pbs.bundleQty, releaseUomValue: oi.releaseUomValue * pbs.bundleQty * pbs.product.primaryValue, packingType: pbs.product.packingType, batchId: '', product: {
568
527
  id: pbs.product.id,
569
528
  name: pbs.product.name,
570
529
  groupType: constants_1.PRODUCT_GROUP_TYPE.SINGLE
571
- }, productDetail: {
572
- id: pbs.productDetail.id
573
530
  } });
574
531
  splitBundleOIs.push(splitOI);
575
532
  });
@@ -579,11 +536,8 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, shippi
579
536
  newReleaseGood.noOfItems = orderInventories.length;
580
537
  newReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(newReleaseGood);
581
538
  for (let oi of orderInventories) {
582
- let productDetail = await tx
583
- .getRepository(product_base_1.ProductDetail)
584
- .findOne(oi.productDetail.id, { relations: ['product'] });
585
539
  let newOrderInv = Object.assign({}, oi);
586
- newOrderInv = Object.assign(Object.assign({}, newOrderInv), { domain: warehouseDomain, bizplace: bizplace, status: constants_1.ORDER_INVENTORY_STATUS.PENDING, name: utils_1.OrderNoGenerator.orderInventory(), releaseGood: newReleaseGood, product: productDetail.product, productDetail, creator: user, updater: user });
540
+ newOrderInv = Object.assign(Object.assign({}, newOrderInv), { domain: warehouseDomain, bizplace: bizplace, status: constants_1.ORDER_INVENTORY_STATUS.PENDING, name: utils_1.OrderNoGenerator.orderInventory(), releaseGood: newReleaseGood, product: await tx.getRepository(product_base_1.Product).findOne(oi.product.id), creator: user, updater: user });
587
541
  let newOrderProduct = Object.assign(new order_product_1.OrderProduct(), newOrderInv);
588
542
  newOrderProduct = Object.assign(Object.assign({}, newOrderProduct), { packQty: 0, actualPackQty: 0, palletQty: 0, actualPalletQty: 0, status: constants_1.ORDER_PRODUCT_STATUS.ASSIGNED });
589
543
  newOrderProduct = await tx.getRepository(order_product_1.OrderProduct).save(newOrderProduct);
@@ -605,7 +559,7 @@ async function generateReleaseGoodFunction(_, releaseGood, shippingOrder, shippi
605
559
  locationSortingRules.push({ name: key, desc: locationSetting[key] == 'ASC' ? false : true });
606
560
  }
607
561
  }
608
- let assignedOrderInventories = await utils_1.InventoryUtil.autoAssignInventoryForRelease(oi, productDetail.product, productDetail, locationSortingRules, bizplace, warehouseDomain, tx, oi.batchId);
562
+ let assignedOrderInventories = await utils_1.InventoryUtil.autoAssignInventoryForRelease(newOrderInv.product, oi, oi.packingType, locationSortingRules, bizplace, warehouseDomain, tx, oi.batchId);
609
563
  assignedOrderInventories = assignedOrderInventories.map(aoi => {
610
564
  return Object.assign(Object.assign({}, aoi), { orderProduct: newOrderProduct });
611
565
  });
@@ -695,22 +649,16 @@ async function confirmReleaseGood(name, context, tx) {
695
649
  let foundOVs = foundReleaseGood.orderVass;
696
650
  let customerBizplace = foundReleaseGood.bizplace;
697
651
  const companyDomain = customerBizplace === null || customerBizplace === void 0 ? void 0 : customerBizplace.company.domain;
698
- const orderSource = foundReleaseGood.source;
699
- switch (orderSource) {
700
- case auth_base_1.ApplicationType.SELLERCRAFT:
701
- const sellercraft = await tx.getRepository(integration_sellercraft_1.Sellercraft).findOne({
702
- where: { domain: foundReleaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE },
703
- relations: ['domain']
704
- });
652
+ const sellercraft = await tx.getRepository(integration_sellercraft_1.Sellercraft).findOne({
653
+ where: { domain: foundReleaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE },
654
+ relations: ['domain']
655
+ });
656
+ if (foundReleaseGood.type == 'b2c') {
657
+ if (sellercraft) {
705
658
  const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
706
- if (foundReleaseGood.type == 'b2c') {
707
- foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, Object.assign(Object.assign({}, foundReleaseGood), { orderProducts: foundOPs }));
708
- }
709
- else if (foundReleaseGood.type == 'b2b') {
710
- await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER');
711
- }
712
- break;
713
- case auth_base_1.ApplicationType.MMS:
659
+ foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, Object.assign(Object.assign({}, foundReleaseGood), { orderProducts: foundOPs }));
660
+ }
661
+ else {
714
662
  // find for any existing marketplace store connections
715
663
  let marketplaceStores = await tx.getRepository(integration_marketplace_1.MarketplaceStore).find({
716
664
  where: { domain: companyDomain, status: 'ACTIVE' },
@@ -761,81 +709,14 @@ async function confirmReleaseGood(name, context, tx) {
761
709
  const ecommerceCtrl = new controllers_1.EcommerceController(tx, domain, user);
762
710
  await ecommerceCtrl.updateProductVariationStock(marketplaceStores, productIds, companyDomain);
763
711
  }
764
- break;
765
- default:
766
- break;
712
+ }
713
+ }
714
+ if (foundReleaseGood.type == 'b2b') {
715
+ if (sellercraft) {
716
+ const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
717
+ await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER');
718
+ }
767
719
  }
768
- // const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
769
- // where: { domain: foundReleaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE },
770
- // relations: ['domain']
771
- // })
772
- // if (foundReleaseGood.type == 'b2c') {
773
- // if (sellercraft) {
774
- // const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
775
- // foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, { ...foundReleaseGood, orderProducts: foundOPs })
776
- // } else {
777
- // // find for any existing marketplace store connections
778
- // let marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
779
- // where: { domain: companyDomain, status: 'ACTIVE' },
780
- // relations: ['marketplaceDistributors']
781
- // })
782
- // const foundMarketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
783
- // where: { domain: companyDomain, orderNo: foundReleaseGood.refNo },
784
- // relations: ['marketplaceStore']
785
- // })
786
- // let matchedMarketplaceStore: MarketplaceStore
787
- // if (foundMarketplaceOrder) {
788
- // matchedMarketplaceStore = marketplaceStores.filter(
789
- // marketplaceStore => marketplaceStore.id == foundMarketplaceOrder.marketplaceStore.id
790
- // )[0]
791
- // }
792
- // let combinedOrderInventories: any[] = foundOIs.map(oi => {
793
- // return {
794
- // sku: oi.product.sku,
795
- // releaseQty: oi.releaseQty
796
- // }
797
- // })
798
- // if (foundBundleInfo?.length) {
799
- // foundBundleInfo.map(bundle => {
800
- // combinedOrderInventories.push({
801
- // sku: bundle.sku,
802
- // releaseQty: bundle.releaseQty
803
- // })
804
- // })
805
- // }
806
- // for (let oi of combinedOrderInventories) {
807
- // let foundMarketplaceProductVariations: MarketplaceProductVariation[] = await tx
808
- // .getRepository(MarketplaceProductVariation)
809
- // .find({
810
- // where: { domain: companyDomain, sku: oi.sku },
811
- // relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
812
- // })
813
- // if (foundMarketplaceProductVariations) {
814
- // await Promise.all(
815
- // foundMarketplaceProductVariations.map(async variation => {
816
- // if (variation.marketplaceProduct.marketplaceStore.reserveEnabled) {
817
- // variation.reserveQty -= oi.releaseQty
818
- // }
819
- // await tx.getRepository(MarketplaceProductVariation).save(variation)
820
- // })
821
- // )
822
- // }
823
- // }
824
- // if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
825
- // marketplaceStores = marketplaceStores.filter(marketplaceStore => marketplaceStore.isAutoUpdateStockQty)
826
- // let productIds: string[] = foundOIs.map(oi => oi.product.id)
827
- // productIds = Array.from(new Set([...productIds]))
828
- // const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
829
- // await ecommerceCtrl.updateProductVariationStock(marketplaceStores, productIds, companyDomain)
830
- // }
831
- // }
832
- // }
833
- // if (foundReleaseGood.type == 'b2b') {
834
- // if (sellercraft) {
835
- // const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
836
- // await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER')
837
- // }
838
- // }
839
720
  // 1. RO Status change (PENDING => PENDING_RECEIVE)
840
721
  const releaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(Object.assign(Object.assign({}, foundReleaseGood), { status: constants_1.ORDER_STATUS.PENDING_RECEIVE, updater: user }));
841
722
  // 1. Update status of order inventories
@@ -992,27 +873,13 @@ async function rejectReleaseGood(tx, context, name, remark) {
992
873
  })));
993
874
  }
994
875
  if (foundOPs && foundOPs.length) {
995
- const orderSource = releaseGood.source;
996
- switch (orderSource) {
997
- case auth_base_1.ApplicationType.SELLERCRAFT:
998
- const sellercraft = await tx
999
- .getRepository(integration_sellercraft_1.Sellercraft)
1000
- .findOne({ domain: releaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
1001
- if (sellercraft) {
1002
- const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
1003
- await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER');
1004
- }
1005
- break;
1006
- default:
1007
- break;
876
+ const sellercraft = await tx
877
+ .getRepository(integration_sellercraft_1.Sellercraft)
878
+ .findOne({ domain: releaseGood.bizplace.domain, status: integration_sellercraft_1.SellercraftStatus.ACTIVE });
879
+ if (sellercraft) {
880
+ const sellercraftCtrl = new controllers_1.SellercraftController(tx, domain, user);
881
+ await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER');
1008
882
  }
1009
- // const sellercraft: Sellercraft = await tx
1010
- // .getRepository(Sellercraft)
1011
- // .findOne({ domain: releaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE })
1012
- // if (sellercraft) {
1013
- // const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
1014
- // await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER')
1015
- // }
1016
883
  await tx.getRepository(order_product_1.OrderProduct).save(await Promise.all(foundOPs.map(async (op) => {
1017
884
  op.status = constants_1.ORDER_PRODUCT_STATUS.REJECTED;
1018
885
  op.updater = user;
@@ -1063,14 +930,14 @@ async function rejectReleaseGood(tx, context, name, remark) {
1063
930
  }
1064
931
  exports.rejectReleaseGood = rejectReleaseGood;
1065
932
  async function bulkGenerateReleaseGood(releaseGood, bizplaceId, roNoSetting, domain, user, tx) {
1066
- var _a, _b, _c, _d;
933
+ var _a, _b;
1067
934
  try {
1068
935
  let warehouseDomain = domain;
1069
936
  let { orderInventories, shippingOrder } = releaseGood;
1070
937
  let bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(bizplaceId);
1071
938
  let newReleaseGood = Object.assign(Object.assign({}, releaseGood), { name: roNoSetting
1072
939
  ? await (0, id_rule_base_1.generateId)({ domain, type: constants_1.ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
1073
- : utils_1.OrderNoGenerator.releaseGood(), domain: warehouseDomain, bizplace: bizplace, deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null, deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null, deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null, deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null, attentionTo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionTo) || null, attentionCompany: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionCompany) || null, city: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.city) || null, state: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.state) || null, postalCode: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode) || null, country: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) || null, phone1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone1) || null, phone2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone2) || null, email: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.email) || null, source: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.source) || null, airwayBill: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.airwayBill, refNo: releaseGood.refNo, refNo2: releaseGood.refNo2, refNo3: releaseGood.refNo3, releaseDate: releaseGood.releaseDate, ownTransport: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.ownTransport) || false, orderMethod: constants_1.ORDER_METHOD.SELECT_BY_PRODUCT, status: constants_1.ORDER_STATUS.PENDING, creator: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.creator) || user, updater: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.updater) || user });
940
+ : utils_1.OrderNoGenerator.releaseGood(), domain: warehouseDomain, bizplace: bizplace, deliveryAddress1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress1) || null, deliveryAddress2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress2) || null, deliveryAddress3: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress3) || null, deliveryAddress4: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.deliveryAddress4) || null, attentionTo: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionTo) || null, attentionCompany: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.attentionCompany) || null, city: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.city) || null, state: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.state) || null, postalCode: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.postalCode) || null, country: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.country) || null, phone1: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone1) || null, phone2: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.phone2) || null, email: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.email) || null, airwayBill: releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.airwayBill, refNo: releaseGood.refNo, refNo2: releaseGood.refNo2, refNo3: releaseGood.refNo3, releaseDate: releaseGood.releaseDate, ownTransport: (releaseGood === null || releaseGood === void 0 ? void 0 : releaseGood.ownTransport) || false, orderMethod: constants_1.ORDER_METHOD.SELECT_BY_PRODUCT, status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user });
1074
941
  newReleaseGood = await tx.getRepository(release_good_1.ReleaseGood).save(newReleaseGood);
1075
942
  /** Generate Shipping Order */
1076
943
  if (shippingOrder) {
@@ -1096,20 +963,15 @@ async function bulkGenerateReleaseGood(releaseGood, bizplaceId, roNoSetting, dom
1096
963
  locationSortingRules.push({ name: key, desc: locationSetting[key] == 'ASC' ? false : true });
1097
964
  }
1098
965
  }
1099
- let productDetail = (_a = oi.orderProduct) === null || _a === void 0 ? void 0 : _a.productDetail;
1100
- let product = (_b = oi.orderProduct) === null || _b === void 0 ? void 0 : _b.product;
1101
- if (!productDetail) {
1102
- productDetail = await tx.getRepository(product_base_1.ProductDetail).findOne(oi.productDetailId, { relations: ['product'] });
1103
- product = productDetail.product;
1104
- }
1105
- let assignedResult = await utils_1.InventoryUtil.autoAssignInventoryForRelease(oi, product, productDetail, locationSortingRules, bizplace, warehouseDomain, tx);
966
+ const product = await tx.getRepository(product_base_1.Product).findOne(oi.productId);
967
+ let assignedResult = await utils_1.InventoryUtil.autoAssignInventoryForRelease(product, oi, oi.packingType, locationSortingRules, bizplace, warehouseDomain, tx);
1106
968
  finalOrderInventories.push(...assignedResult.map(itm => {
1107
969
  return Object.assign(Object.assign({}, itm), { orderProduct: oi === null || oi === void 0 ? void 0 : oi.orderProduct });
1108
970
  }));
1109
971
  }
1110
972
  for (let oi of finalOrderInventories) {
1111
973
  let generatedOI = Object.assign(new order_inventory_1.OrderInventory(), oi);
1112
- generatedOI = Object.assign(Object.assign({}, generatedOI), { domain: warehouseDomain, bizplace, status: constants_1.ORDER_INVENTORY_STATUS.PENDING, name: utils_1.OrderNoGenerator.orderInventory(), releaseGood: newReleaseGood, creator: (newReleaseGood === null || newReleaseGood === void 0 ? void 0 : newReleaseGood.creator) || user, updater: (newReleaseGood === null || newReleaseGood === void 0 ? void 0 : newReleaseGood.updater) || user });
974
+ generatedOI = Object.assign(Object.assign({}, generatedOI), { domain: warehouseDomain, bizplace, status: constants_1.ORDER_INVENTORY_STATUS.PENDING, name: utils_1.OrderNoGenerator.orderInventory(), releaseGood: newReleaseGood, creator: user, updater: user });
1113
975
  let newOrderProduct;
1114
976
  if (!(oi === null || oi === void 0 ? void 0 : oi.orderProduct)) {
1115
977
  newOrderProduct = {
@@ -1129,19 +991,19 @@ async function bulkGenerateReleaseGood(releaseGood, bizplaceId, roNoSetting, dom
1129
991
  actualPalletQty: 0,
1130
992
  status: constants_1.ORDER_PRODUCT_STATUS.ASSIGNED,
1131
993
  releaseGood: newReleaseGood,
1132
- creator: (newReleaseGood === null || newReleaseGood === void 0 ? void 0 : newReleaseGood.creator) || user,
1133
- updater: (newReleaseGood === null || newReleaseGood === void 0 ? void 0 : newReleaseGood.updater) || user
994
+ creator: user,
995
+ updater: user
1134
996
  };
1135
997
  newOrderProduct = await tx.getRepository(order_product_1.OrderProduct).save(newOrderProduct);
1136
998
  }
1137
999
  else {
1138
- newOrderProduct = await tx.getRepository(order_product_1.OrderProduct).save(Object.assign(Object.assign({}, oi.orderProduct), { totalUomValue: `${oi.orderProduct.releaseUomValue} ${oi.orderProduct.uom}`, status: constants_1.ORDER_PRODUCT_STATUS.ASSIGNED, updater: (newReleaseGood === null || newReleaseGood === void 0 ? void 0 : newReleaseGood.updater) || user }));
1000
+ newOrderProduct = await tx.getRepository(order_product_1.OrderProduct).save(Object.assign(Object.assign({}, oi.orderProduct), { totalUomValue: `${oi.orderProduct.releaseUomValue} ${oi.orderProduct.uom}`, status: constants_1.ORDER_PRODUCT_STATUS.ASSIGNED, updater: user }));
1139
1001
  }
1140
1002
  await tx.getRepository(order_inventory_1.OrderInventory).save(Object.assign(Object.assign({}, generatedOI), { orderProduct: newOrderProduct }));
1141
1003
  // update inventory locked qty and uom value
1142
1004
  await tx.getRepository(warehouse_base_1.Inventory).update(oi.inventory.id, {
1143
- lockedQty: (((_c = oi.inventory) === null || _c === void 0 ? void 0 : _c.lockedQty) || 0) + generatedOI.releaseQty,
1144
- lockedUomValue: (((_d = oi.inventory) === null || _d === void 0 ? void 0 : _d.lockedUomValue) || 0) + generatedOI.releaseUomValue,
1005
+ lockedQty: (((_a = oi.inventory) === null || _a === void 0 ? void 0 : _a.lockedQty) || 0) + generatedOI.releaseQty,
1006
+ lockedUomValue: (((_b = oi.inventory) === null || _b === void 0 ? void 0 : _b.lockedUomValue) || 0) + generatedOI.releaseUomValue,
1145
1007
  updater: user
1146
1008
  });
1147
1009
  }