@things-factory/sales-base 4.3.82 → 4.3.83
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/service/arrival-notice/arrival-notice-mutation.js +5 -6
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice.js +0 -5
- package/dist-server/service/arrival-notice/arrival-notice.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +8 -3
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-query.js +7 -4
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good.js +0 -5
- package/dist-server/service/draft-release-good/draft-release-good.js.map +1 -1
- package/dist-server/service/invoice-product/invoice-product.js +3 -8
- package/dist-server/service/invoice-product/invoice-product.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +1 -2
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +10 -18
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +3 -12
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-product/order-product-query.js +0 -1
- package/dist-server/service/order-product/order-product-query.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +10 -18
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-vas/order-vas.js +3 -8
- package/dist-server/service/order-vas/order-vas.js.map +1 -1
- package/dist-server/service/others/other-query.js +21 -17
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +0 -4
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-mutation.js +2 -10
- package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-query.js +0 -1
- package/dist-server/service/purchase-order/purchase-order-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +49 -187
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +6 -4
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +4 -8
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +0 -5
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/return-order/return-order-mutation.js +0 -2
- package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
- package/dist-server/service/return-order/return-order-types.js.map +1 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +3 -8
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
- package/dist-server/utils/inventory-util.js +102 -33
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +13 -13
- package/server/service/arrival-notice/arrival-notice-mutation.ts +3 -6
- package/server/service/arrival-notice/arrival-notice.ts +0 -4
- package/server/service/draft-release-good/draft-release-good-mutation.ts +12 -10
- package/server/service/draft-release-good/draft-release-good-query.ts +5 -5
- package/server/service/draft-release-good/draft-release-good.ts +0 -4
- package/server/service/invoice-product/invoice-product.ts +1 -5
- package/server/service/order-inventory/order-inventory-query.ts +0 -2
- package/server/service/order-inventory/order-inventory-types.ts +0 -6
- package/server/service/order-inventory/order-inventory.ts +1 -8
- package/server/service/order-product/order-product-query.ts +0 -1
- package/server/service/order-product/order-product-types.ts +0 -6
- package/server/service/order-vas/order-vas.ts +1 -6
- package/server/service/others/other-query.ts +31 -30
- package/server/service/others/other-types.ts +0 -3
- package/server/service/purchase-order/purchase-order-mutation.ts +1 -10
- package/server/service/purchase-order/purchase-order-query.ts +0 -1
- package/server/service/release-good/release-good-mutation.ts +50 -221
- package/server/service/release-good/release-good-query.ts +7 -4
- package/server/service/release-good/release-good-types.ts +3 -4
- package/server/service/release-good/release-good.ts +6 -8
- package/server/service/return-order/return-order-mutation.ts +1 -3
- package/server/service/return-order/return-order-types.ts +0 -1
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +1 -5
- package/server/utils/inventory-util.ts +147 -67
|
@@ -3,7 +3,7 @@ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
|
3
3
|
import { EntityManager, getConnection, getRepository, In, Not, Repository } from 'typeorm'
|
|
4
4
|
|
|
5
5
|
import { Attachment, createAttachments } from '@things-factory/attachment-base'
|
|
6
|
-
import {
|
|
6
|
+
import { Partner, Role, User } from '@things-factory/auth-base'
|
|
7
7
|
import {
|
|
8
8
|
Bizplace,
|
|
9
9
|
getDomainUsers,
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
import { generateId } from '@things-factory/id-rule-base'
|
|
15
15
|
import { MarketplaceStore } from '@things-factory/integration-marketplace'
|
|
16
16
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
17
|
+
import { Sftp } from '@things-factory/integration-sftp'
|
|
17
18
|
import { MarketplaceOrder, MarketplaceProductVariation } from '@things-factory/marketplace-base'
|
|
18
19
|
// import { sendNotification } from '@things-factory/notification'
|
|
19
|
-
import { Product, ProductBundleSetting
|
|
20
|
+
import { Product, ProductBundleSetting } from '@things-factory/product-base'
|
|
20
21
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
21
22
|
import { Domain } from '@things-factory/shell'
|
|
22
23
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
@@ -484,18 +485,20 @@ export async function generateReleaseGoodFunction(
|
|
|
484
485
|
await InventoryUtil.validateWarehousePartnersProductsQuantity(domain, bizplace, orderInventories, context, tx)
|
|
485
486
|
/** End Validate Release Order Product Quantity Section */
|
|
486
487
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
.getRepository(Sellercraft)
|
|
492
|
-
.findOne({ domain: bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
488
|
+
if (releaseGood.type == 'b2c') {
|
|
489
|
+
const sellercraft: Sellercraft = await tx
|
|
490
|
+
.getRepository(Sellercraft)
|
|
491
|
+
.findOne({ domain: bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
493
492
|
|
|
493
|
+
let customerAvailableSftp: Sftp = await tx.getRepository(Sftp).findOne({
|
|
494
|
+
where: { domain: bizplace.domain }
|
|
495
|
+
})
|
|
496
|
+
|
|
497
|
+
if (sellercraft) {
|
|
494
498
|
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
495
499
|
await sellercraftCtrl.checkExistingReleaseGood(sellercraft, releaseGood)
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
case ApplicationType.MMS:
|
|
500
|
+
} else if (customerAvailableSftp) {
|
|
501
|
+
} else {
|
|
499
502
|
const refNo: string = releaseGood.refNo
|
|
500
503
|
const foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
501
504
|
where: {
|
|
@@ -529,62 +532,9 @@ export async function generateReleaseGoodFunction(
|
|
|
529
532
|
throw new Error('Existing release order found')
|
|
530
533
|
}
|
|
531
534
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
default:
|
|
535
|
-
break
|
|
535
|
+
}
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
// if (releaseGood.type == 'b2c') {
|
|
539
|
-
// const sellercraft: Sellercraft = await tx
|
|
540
|
-
// .getRepository(Sellercraft)
|
|
541
|
-
// .findOne({ domain: bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
542
|
-
|
|
543
|
-
// let customerAvailableSftp: Sftp = await tx.getRepository(Sftp).findOne({
|
|
544
|
-
// where: { domain: bizplace.domain }
|
|
545
|
-
// })
|
|
546
|
-
|
|
547
|
-
// if (sellercraft) {
|
|
548
|
-
// const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
549
|
-
// await sellercraftCtrl.checkExistingReleaseGood(sellercraft, releaseGood)
|
|
550
|
-
// } else if (customerAvailableSftp) {
|
|
551
|
-
// } else {
|
|
552
|
-
// const refNo: string = releaseGood.refNo
|
|
553
|
-
// const foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
554
|
-
// where: {
|
|
555
|
-
// domain: warehouseDomain,
|
|
556
|
-
// refNo,
|
|
557
|
-
// status: Not(In([ORDER_STATUS.CANCELLED, ORDER_STATUS.PENDING_CANCEL]))
|
|
558
|
-
// },
|
|
559
|
-
// relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
560
|
-
// })
|
|
561
|
-
|
|
562
|
-
// if (foundReleaseGood) {
|
|
563
|
-
// const customerCompanyDomain: Domain = foundReleaseGood.bizplace.company.domain
|
|
564
|
-
// const marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
565
|
-
// where: { orderNo: refNo, domain: customerCompanyDomain }
|
|
566
|
-
// })
|
|
567
|
-
|
|
568
|
-
// // Need to restructure the validation
|
|
569
|
-
// if (marketplaceOrder?.isSplitted) {
|
|
570
|
-
// const refNo2: string = releaseGood.refNo2
|
|
571
|
-
// const foundSplittedReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
572
|
-
// where: {
|
|
573
|
-
// domain: warehouseDomain,
|
|
574
|
-
// refNo2,
|
|
575
|
-
// status: Not(In([ORDER_STATUS.CANCELLED, ORDER_STATUS.PENDING_CANCEL]))
|
|
576
|
-
// },
|
|
577
|
-
// relations: ['bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain']
|
|
578
|
-
// })
|
|
579
|
-
|
|
580
|
-
// if (foundSplittedReleaseGood) throw new Error('Existing release order found')
|
|
581
|
-
// } else {
|
|
582
|
-
// throw new Error('Existing release order found')
|
|
583
|
-
// }
|
|
584
|
-
// }
|
|
585
|
-
// }
|
|
586
|
-
// }
|
|
587
|
-
|
|
588
538
|
let newReleaseGood: ReleaseGood = new ReleaseGood()
|
|
589
539
|
|
|
590
540
|
/** Generate Shipping Order */
|
|
@@ -722,7 +672,7 @@ export async function generateReleaseGoodFunction(
|
|
|
722
672
|
|
|
723
673
|
const pbSettings: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({
|
|
724
674
|
where: { productBundle: oi.product.id },
|
|
725
|
-
relations: ['product', 'productBundle'
|
|
675
|
+
relations: ['product', 'productBundle']
|
|
726
676
|
})
|
|
727
677
|
|
|
728
678
|
pbSettings.forEach(pbs => {
|
|
@@ -736,9 +686,6 @@ export async function generateReleaseGoodFunction(
|
|
|
736
686
|
id: pbs.product.id,
|
|
737
687
|
name: pbs.product.name,
|
|
738
688
|
groupType: PRODUCT_GROUP_TYPE.SINGLE
|
|
739
|
-
},
|
|
740
|
-
productDetail: {
|
|
741
|
-
id: pbs.productDetail.id
|
|
742
689
|
}
|
|
743
690
|
}
|
|
744
691
|
splitBundleOIs.push(splitOI)
|
|
@@ -753,10 +700,6 @@ export async function generateReleaseGoodFunction(
|
|
|
753
700
|
newReleaseGood = await tx.getRepository(ReleaseGood).save(newReleaseGood)
|
|
754
701
|
|
|
755
702
|
for (let oi of orderInventories) {
|
|
756
|
-
let productDetail: any = await tx
|
|
757
|
-
.getRepository(ProductDetail)
|
|
758
|
-
.findOne(oi.productDetail.id, { relations: ['product'] })
|
|
759
|
-
|
|
760
703
|
let newOrderInv: OrderInventory = Object.assign({}, oi)
|
|
761
704
|
newOrderInv = {
|
|
762
705
|
...newOrderInv,
|
|
@@ -765,8 +708,7 @@ export async function generateReleaseGoodFunction(
|
|
|
765
708
|
status: ORDER_INVENTORY_STATUS.PENDING,
|
|
766
709
|
name: OrderNoGenerator.orderInventory(),
|
|
767
710
|
releaseGood: newReleaseGood,
|
|
768
|
-
product:
|
|
769
|
-
productDetail,
|
|
711
|
+
product: await tx.getRepository(Product).findOne(oi.product.id),
|
|
770
712
|
creator: user,
|
|
771
713
|
updater: user
|
|
772
714
|
}
|
|
@@ -804,9 +746,9 @@ export async function generateReleaseGoodFunction(
|
|
|
804
746
|
}
|
|
805
747
|
|
|
806
748
|
let assignedOrderInventories: OrderInventory[] = await InventoryUtil.autoAssignInventoryForRelease(
|
|
749
|
+
newOrderInv.product,
|
|
807
750
|
oi,
|
|
808
|
-
|
|
809
|
-
productDetail,
|
|
751
|
+
oi.packingType,
|
|
810
752
|
locationSortingRules,
|
|
811
753
|
bizplace,
|
|
812
754
|
warehouseDomain,
|
|
@@ -945,28 +887,16 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
945
887
|
let foundOVs: OrderVas[] = foundReleaseGood.orderVass
|
|
946
888
|
let customerBizplace: Bizplace = foundReleaseGood.bizplace
|
|
947
889
|
const companyDomain: Domain = customerBizplace?.company.domain
|
|
890
|
+
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
891
|
+
where: { domain: foundReleaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE },
|
|
892
|
+
relations: ['domain']
|
|
893
|
+
})
|
|
948
894
|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
case ApplicationType.SELLERCRAFT:
|
|
952
|
-
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
953
|
-
where: { domain: foundReleaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE },
|
|
954
|
-
relations: ['domain']
|
|
955
|
-
})
|
|
956
|
-
|
|
895
|
+
if (foundReleaseGood.type == 'b2c') {
|
|
896
|
+
if (sellercraft) {
|
|
957
897
|
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
...foundReleaseGood,
|
|
961
|
-
orderProducts: foundOPs
|
|
962
|
-
})
|
|
963
|
-
} else if (foundReleaseGood.type == 'b2b') {
|
|
964
|
-
await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER')
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
break
|
|
968
|
-
|
|
969
|
-
case ApplicationType.MMS:
|
|
898
|
+
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, { ...foundReleaseGood, orderProducts: foundOPs })
|
|
899
|
+
} else {
|
|
970
900
|
// find for any existing marketplace store connections
|
|
971
901
|
let marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
972
902
|
where: { domain: companyDomain, status: 'ACTIVE' },
|
|
@@ -1029,93 +959,15 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
1029
959
|
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
1030
960
|
await ecommerceCtrl.updateProductVariationStock(marketplaceStores, productIds, companyDomain)
|
|
1031
961
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
default:
|
|
1035
|
-
break
|
|
962
|
+
}
|
|
1036
963
|
}
|
|
1037
964
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
// if (sellercraft) {
|
|
1045
|
-
// const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
1046
|
-
// foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, { ...foundReleaseGood, orderProducts: foundOPs })
|
|
1047
|
-
// } else {
|
|
1048
|
-
// // find for any existing marketplace store connections
|
|
1049
|
-
// let marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
1050
|
-
// where: { domain: companyDomain, status: 'ACTIVE' },
|
|
1051
|
-
// relations: ['marketplaceDistributors']
|
|
1052
|
-
// })
|
|
1053
|
-
|
|
1054
|
-
// const foundMarketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
1055
|
-
// where: { domain: companyDomain, orderNo: foundReleaseGood.refNo },
|
|
1056
|
-
// relations: ['marketplaceStore']
|
|
1057
|
-
// })
|
|
1058
|
-
|
|
1059
|
-
// let matchedMarketplaceStore: MarketplaceStore
|
|
1060
|
-
// if (foundMarketplaceOrder) {
|
|
1061
|
-
// matchedMarketplaceStore = marketplaceStores.filter(
|
|
1062
|
-
// marketplaceStore => marketplaceStore.id == foundMarketplaceOrder.marketplaceStore.id
|
|
1063
|
-
// )[0]
|
|
1064
|
-
// }
|
|
1065
|
-
|
|
1066
|
-
// let combinedOrderInventories: any[] = foundOIs.map(oi => {
|
|
1067
|
-
// return {
|
|
1068
|
-
// sku: oi.product.sku,
|
|
1069
|
-
// releaseQty: oi.releaseQty
|
|
1070
|
-
// }
|
|
1071
|
-
// })
|
|
1072
|
-
|
|
1073
|
-
// if (foundBundleInfo?.length) {
|
|
1074
|
-
// foundBundleInfo.map(bundle => {
|
|
1075
|
-
// combinedOrderInventories.push({
|
|
1076
|
-
// sku: bundle.sku,
|
|
1077
|
-
// releaseQty: bundle.releaseQty
|
|
1078
|
-
// })
|
|
1079
|
-
// })
|
|
1080
|
-
// }
|
|
1081
|
-
|
|
1082
|
-
// for (let oi of combinedOrderInventories) {
|
|
1083
|
-
// let foundMarketplaceProductVariations: MarketplaceProductVariation[] = await tx
|
|
1084
|
-
// .getRepository(MarketplaceProductVariation)
|
|
1085
|
-
// .find({
|
|
1086
|
-
// where: { domain: companyDomain, sku: oi.sku },
|
|
1087
|
-
// relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
1088
|
-
// })
|
|
1089
|
-
|
|
1090
|
-
// if (foundMarketplaceProductVariations) {
|
|
1091
|
-
// await Promise.all(
|
|
1092
|
-
// foundMarketplaceProductVariations.map(async variation => {
|
|
1093
|
-
// if (variation.marketplaceProduct.marketplaceStore.reserveEnabled) {
|
|
1094
|
-
// variation.reserveQty -= oi.releaseQty
|
|
1095
|
-
// }
|
|
1096
|
-
|
|
1097
|
-
// await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
1098
|
-
// })
|
|
1099
|
-
// )
|
|
1100
|
-
// }
|
|
1101
|
-
// }
|
|
1102
|
-
|
|
1103
|
-
// if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
1104
|
-
// marketplaceStores = marketplaceStores.filter(marketplaceStore => marketplaceStore.isAutoUpdateStockQty)
|
|
1105
|
-
// let productIds: string[] = foundOIs.map(oi => oi.product.id)
|
|
1106
|
-
// productIds = Array.from(new Set([...productIds]))
|
|
1107
|
-
// const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
1108
|
-
// await ecommerceCtrl.updateProductVariationStock(marketplaceStores, productIds, companyDomain)
|
|
1109
|
-
// }
|
|
1110
|
-
// }
|
|
1111
|
-
// }
|
|
1112
|
-
|
|
1113
|
-
// if (foundReleaseGood.type == 'b2b') {
|
|
1114
|
-
// if (sellercraft) {
|
|
1115
|
-
// const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
1116
|
-
// await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER')
|
|
1117
|
-
// }
|
|
1118
|
-
// }
|
|
965
|
+
if (foundReleaseGood.type == 'b2b') {
|
|
966
|
+
if (sellercraft) {
|
|
967
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
968
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'CONFIRM_ORDER')
|
|
969
|
+
}
|
|
970
|
+
}
|
|
1119
971
|
|
|
1120
972
|
// 1. RO Status change (PENDING => PENDING_RECEIVE)
|
|
1121
973
|
const releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).save({
|
|
@@ -1331,32 +1183,15 @@ export async function rejectReleaseGood(
|
|
|
1331
1183
|
}
|
|
1332
1184
|
|
|
1333
1185
|
if (foundOPs && foundOPs.length) {
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
const sellercraft: Sellercraft = await tx
|
|
1338
|
-
.getRepository(Sellercraft)
|
|
1339
|
-
.findOne({ domain: releaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
1340
|
-
|
|
1341
|
-
if (sellercraft) {
|
|
1342
|
-
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
1343
|
-
await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER')
|
|
1344
|
-
}
|
|
1345
|
-
break
|
|
1186
|
+
const sellercraft: Sellercraft = await tx
|
|
1187
|
+
.getRepository(Sellercraft)
|
|
1188
|
+
.findOne({ domain: releaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
1346
1189
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1190
|
+
if (sellercraft) {
|
|
1191
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
1192
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER')
|
|
1349
1193
|
}
|
|
1350
1194
|
|
|
1351
|
-
// const sellercraft: Sellercraft = await tx
|
|
1352
|
-
// .getRepository(Sellercraft)
|
|
1353
|
-
// .findOne({ domain: releaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
1354
|
-
|
|
1355
|
-
// if (sellercraft) {
|
|
1356
|
-
// const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
1357
|
-
// await sellercraftCtrl.updateSellercraftStock(sellercraft, foundOPs, 'REJECT_ORDER')
|
|
1358
|
-
// }
|
|
1359
|
-
|
|
1360
1195
|
await tx.getRepository(OrderProduct).save(
|
|
1361
1196
|
await Promise.all(
|
|
1362
1197
|
foundOPs.map(async (op: OrderProduct) => {
|
|
@@ -1453,7 +1288,6 @@ export async function bulkGenerateReleaseGood(
|
|
|
1453
1288
|
phone1: releaseGood?.phone1 || null,
|
|
1454
1289
|
phone2: releaseGood?.phone2 || null,
|
|
1455
1290
|
email: releaseGood?.email || null,
|
|
1456
|
-
source: releaseGood?.source || null,
|
|
1457
1291
|
airwayBill: releaseGood?.airwayBill,
|
|
1458
1292
|
refNo: releaseGood.refNo,
|
|
1459
1293
|
refNo2: releaseGood.refNo2,
|
|
@@ -1462,8 +1296,8 @@ export async function bulkGenerateReleaseGood(
|
|
|
1462
1296
|
ownTransport: releaseGood?.ownTransport || false,
|
|
1463
1297
|
orderMethod: ORDER_METHOD.SELECT_BY_PRODUCT,
|
|
1464
1298
|
status: ORDER_STATUS.PENDING,
|
|
1465
|
-
creator:
|
|
1466
|
-
updater:
|
|
1299
|
+
creator: user,
|
|
1300
|
+
updater: user
|
|
1467
1301
|
}
|
|
1468
1302
|
|
|
1469
1303
|
newReleaseGood = await tx.getRepository(ReleaseGood).save(newReleaseGood)
|
|
@@ -1505,17 +1339,12 @@ export async function bulkGenerateReleaseGood(
|
|
|
1505
1339
|
}
|
|
1506
1340
|
}
|
|
1507
1341
|
|
|
1508
|
-
|
|
1509
|
-
let product = oi.orderProduct?.product
|
|
1510
|
-
if (!productDetail) {
|
|
1511
|
-
productDetail = await tx.getRepository(ProductDetail).findOne(oi.productDetailId, { relations: ['product'] })
|
|
1512
|
-
product = productDetail.product
|
|
1513
|
-
}
|
|
1342
|
+
const product: Product = await tx.getRepository(Product).findOne(oi.productId)
|
|
1514
1343
|
|
|
1515
1344
|
let assignedResult = await InventoryUtil.autoAssignInventoryForRelease(
|
|
1516
|
-
oi,
|
|
1517
1345
|
product,
|
|
1518
|
-
|
|
1346
|
+
oi,
|
|
1347
|
+
oi.packingType,
|
|
1519
1348
|
locationSortingRules,
|
|
1520
1349
|
bizplace,
|
|
1521
1350
|
warehouseDomain,
|
|
@@ -1541,8 +1370,8 @@ export async function bulkGenerateReleaseGood(
|
|
|
1541
1370
|
status: ORDER_INVENTORY_STATUS.PENDING,
|
|
1542
1371
|
name: OrderNoGenerator.orderInventory(),
|
|
1543
1372
|
releaseGood: newReleaseGood,
|
|
1544
|
-
creator:
|
|
1545
|
-
updater:
|
|
1373
|
+
creator: user,
|
|
1374
|
+
updater: user
|
|
1546
1375
|
}
|
|
1547
1376
|
|
|
1548
1377
|
let newOrderProduct: Partial<OrderProduct>
|
|
@@ -1564,8 +1393,8 @@ export async function bulkGenerateReleaseGood(
|
|
|
1564
1393
|
actualPalletQty: 0,
|
|
1565
1394
|
status: ORDER_PRODUCT_STATUS.ASSIGNED,
|
|
1566
1395
|
releaseGood: newReleaseGood,
|
|
1567
|
-
creator:
|
|
1568
|
-
updater:
|
|
1396
|
+
creator: user,
|
|
1397
|
+
updater: user
|
|
1569
1398
|
}
|
|
1570
1399
|
|
|
1571
1400
|
newOrderProduct = await tx.getRepository(OrderProduct).save(newOrderProduct)
|
|
@@ -1574,7 +1403,7 @@ export async function bulkGenerateReleaseGood(
|
|
|
1574
1403
|
...oi.orderProduct,
|
|
1575
1404
|
totalUomValue: `${oi.orderProduct.releaseUomValue} ${oi.orderProduct.uom}`,
|
|
1576
1405
|
status: ORDER_PRODUCT_STATUS.ASSIGNED,
|
|
1577
|
-
updater:
|
|
1406
|
+
updater: user
|
|
1578
1407
|
})
|
|
1579
1408
|
}
|
|
1580
1409
|
|
|
@@ -196,7 +196,6 @@ export class ReleaseGoodQuery {
|
|
|
196
196
|
.createQueryBuilder('oi')
|
|
197
197
|
.leftJoinAndSelect('oi.inventory', 'inventory')
|
|
198
198
|
.leftJoinAndSelect('oi.product', 'product')
|
|
199
|
-
.leftJoinAndSelect('oi.productDetail', 'productDetail')
|
|
200
199
|
.leftJoinAndSelect('inventory.location', 'location')
|
|
201
200
|
.where('oi.domain_id = :domainId', { domainId: domain.id })
|
|
202
201
|
.andWhere('oi.release_good_id = :releaseGoodId', { releaseGoodId: releaseGood.id })
|
|
@@ -227,7 +226,6 @@ export class ReleaseGoodQuery {
|
|
|
227
226
|
batchIdRef: inventory.batchIdRef,
|
|
228
227
|
palletId: inventory.palletId,
|
|
229
228
|
product: orderInv.product,
|
|
230
|
-
productDetail: orderInv.productDetail,
|
|
231
229
|
productIdRef: orderInv.product.id,
|
|
232
230
|
productName: `${orderInv.product.name} (${orderInv.product.description})`,
|
|
233
231
|
packingType: orderInv.packingType,
|
|
@@ -377,7 +375,10 @@ export class ReleaseGoodQuery {
|
|
|
377
375
|
params.filters.push({
|
|
378
376
|
name: typeFilter == 'b2c' ? 'releaseDate' : 'createdAt',
|
|
379
377
|
operator: 'gte',
|
|
380
|
-
value:
|
|
378
|
+
value:
|
|
379
|
+
typeFilter == 'b2c'
|
|
380
|
+
? releaseDateFrom
|
|
381
|
+
: fromDateVal.toISOString(),
|
|
381
382
|
relation: false
|
|
382
383
|
})
|
|
383
384
|
}
|
|
@@ -392,7 +393,9 @@ export class ReleaseGoodQuery {
|
|
|
392
393
|
name: typeFilter == 'b2c' ? 'releaseDate' : 'createdAt',
|
|
393
394
|
operator: typeFilter == 'b2c' ? 'lte' : 'lt',
|
|
394
395
|
value:
|
|
395
|
-
typeFilter == 'b2c'
|
|
396
|
+
typeFilter == 'b2c'
|
|
397
|
+
? releaseDateTo
|
|
398
|
+
: new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
|
|
396
399
|
relation: false
|
|
397
400
|
})
|
|
398
401
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
2
|
|
|
3
|
-
import { Product
|
|
3
|
+
import { Product } from '@things-factory/product-base'
|
|
4
4
|
import { ObjectRef } from '@things-factory/shell'
|
|
5
5
|
import { Location } from '@things-factory/warehouse-base'
|
|
6
6
|
|
|
@@ -77,9 +77,6 @@ export class InventoryInfos {
|
|
|
77
77
|
@Field(type => Product, { nullable: true })
|
|
78
78
|
product?: Product
|
|
79
79
|
|
|
80
|
-
@Field(type => ProductDetail, { nullable: true })
|
|
81
|
-
productDetail?: ProductDetail
|
|
82
|
-
|
|
83
80
|
@Field({ nullable: true })
|
|
84
81
|
packingType?: string
|
|
85
82
|
|
|
@@ -188,6 +185,8 @@ export class NewReleaseGood {
|
|
|
188
185
|
@Field({ nullable: true })
|
|
189
186
|
orderMethod: string
|
|
190
187
|
|
|
188
|
+
|
|
189
|
+
|
|
191
190
|
@Field({ nullable: true })
|
|
192
191
|
collectionOrderNo: string
|
|
193
192
|
|
|
@@ -95,8 +95,8 @@ export class ReleaseGood {
|
|
|
95
95
|
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
96
96
|
? 'enum'
|
|
97
97
|
: DATABASE_TYPE == 'oracle'
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
? 'varchar2'
|
|
99
|
+
: 'smallint',
|
|
100
100
|
enum: ReleaseOrderType,
|
|
101
101
|
default: ReleaseOrderType.B2B
|
|
102
102
|
})
|
|
@@ -167,13 +167,15 @@ export class ReleaseGood {
|
|
|
167
167
|
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
168
168
|
? 'enum'
|
|
169
169
|
: DATABASE_TYPE == 'oracle'
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
? 'varchar2'
|
|
171
|
+
: 'smallint',
|
|
172
172
|
enum: DispatchmentStatus,
|
|
173
173
|
default: DispatchmentStatus.READY_TO_DISPATCH
|
|
174
174
|
})
|
|
175
175
|
dispatchmentStatus: DispatchmentStatus
|
|
176
176
|
|
|
177
|
+
|
|
178
|
+
|
|
177
179
|
@Column({ nullable: true })
|
|
178
180
|
@Field({ nullable: true })
|
|
179
181
|
refNo: String
|
|
@@ -441,10 +443,6 @@ export class ReleaseGood {
|
|
|
441
443
|
@Field({ nullable: true })
|
|
442
444
|
stopId: string
|
|
443
445
|
|
|
444
|
-
@Column({ nullable: true })
|
|
445
|
-
@Field({ nullable: true })
|
|
446
|
-
source: string
|
|
447
|
-
|
|
448
446
|
@Column({ nullable: true })
|
|
449
447
|
@Field({ nullable: true })
|
|
450
448
|
manifestedAt: Date
|
|
@@ -6,7 +6,7 @@ import { Attachment, createAttachments } from '@things-factory/attachment-base'
|
|
|
6
6
|
import { Role, User } from '@things-factory/auth-base'
|
|
7
7
|
import { Bizplace, getDomainUsers } from '@things-factory/biz-base'
|
|
8
8
|
import { sendNotification } from '@things-factory/notification'
|
|
9
|
-
import { Product
|
|
9
|
+
import { Product } from '@things-factory/product-base'
|
|
10
10
|
import { Domain } from '@things-factory/shell'
|
|
11
11
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
12
12
|
|
|
@@ -59,7 +59,6 @@ export class ReturnOrderMutation {
|
|
|
59
59
|
itm =>
|
|
60
60
|
itm.product.id === curr.product.id &&
|
|
61
61
|
itm.packingType === curr.packingType &&
|
|
62
|
-
itm.productDetailId === curr.product.productDetailId &&
|
|
63
62
|
itm.batchId === curr.batchId &&
|
|
64
63
|
itm.packingSize === curr.packingSize
|
|
65
64
|
)
|
|
@@ -100,7 +99,6 @@ export class ReturnOrderMutation {
|
|
|
100
99
|
newOrderInv.name = OrderNoGenerator.orderInventory()
|
|
101
100
|
newOrderInv.returnOrder = createdReturnOrder
|
|
102
101
|
newOrderInv.product = await tx.getRepository(Product).findOne(moi.product.id)
|
|
103
|
-
newOrderInv.productDetail = await tx.getRepository(ProductDetail).findOne(moi.productDetail.id)
|
|
104
102
|
newOrderInv.creator = user
|
|
105
103
|
newOrderInv.updater = user
|
|
106
104
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { User } from '@things-factory/auth-base'
|
|
14
14
|
import { Bizplace } from '@things-factory/biz-base'
|
|
15
|
-
import { Product
|
|
15
|
+
import { Product } from '@things-factory/product-base'
|
|
16
16
|
import { Domain } from '@things-factory/shell'
|
|
17
17
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
18
18
|
|
|
@@ -127,10 +127,6 @@ export class ReverseKittingOrderInventory {
|
|
|
127
127
|
@Field({ nullable: true })
|
|
128
128
|
updatedAt?: Date
|
|
129
129
|
|
|
130
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
131
|
-
@Field({ nullable: true })
|
|
132
|
-
productDetail: ProductDetail
|
|
133
|
-
|
|
134
130
|
@ManyToOne(type => User, { nullable: true })
|
|
135
131
|
@Field({ nullable: true })
|
|
136
132
|
creator?: User
|