@things-factory/worksheet-base 4.3.516 → 4.3.520

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 (22) hide show
  1. package/dist-server/controllers/outbound/packing-worksheet-controller.js +7 -0
  2. package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
  3. package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +11 -4
  4. package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
  5. package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +3 -0
  6. package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
  7. package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +13 -12
  8. package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
  9. package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +17 -14
  10. package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
  11. package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +56 -69
  12. package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
  13. package/dist-server/graphql/resolvers/worksheet/putaway-return/complete-putaway-return.js +7 -2
  14. package/dist-server/graphql/resolvers/worksheet/putaway-return/complete-putaway-return.js.map +1 -1
  15. package/package.json +18 -18
  16. package/server/controllers/outbound/packing-worksheet-controller.ts +8 -0
  17. package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +15 -6
  18. package/server/graphql/resolvers/worksheet/packing-worksheet.ts +4 -1
  19. package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +17 -14
  20. package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +21 -18
  21. package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +67 -87
  22. package/server/graphql/resolvers/worksheet/putaway-return/complete-putaway-return.ts +8 -4
@@ -1,9 +1,10 @@
1
- import { EntityManager } from 'typeorm'
1
+ import { EntityManager, In } from 'typeorm'
2
2
 
3
3
  import { Application, ApplicationType, User } from '@things-factory/auth-base'
4
4
  import { MarketplaceStore } from '@things-factory/integration-marketplace'
5
5
  import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
6
6
  import { ArrivalNotice, PowrupController } from '@things-factory/sales-base'
7
+ import { WebspertController } from '@things-factory/warehouse-base'
7
8
  import { Domain } from '@things-factory/shell'
8
9
  import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
9
10
 
@@ -13,92 +14,71 @@ import { Worksheet } from '../../../../entities'
13
14
 
14
15
  export const completePutawayResolver = {
15
16
  async completePutaway(_: any, { arrivalNoticeNo }, context: any) {
16
- const { tx, user, domain }: { tx: EntityManager; user: User; domain: Domain } = context.state
17
- await completePutaway(tx, domain, user, arrivalNoticeNo)
18
-
19
- const arrivalNotice: ArrivalNotice = await tx.getRepository(ArrivalNotice).findOne({
20
- where: { domain, name: arrivalNoticeNo },
21
- relations: [
22
- 'purchaseOrder',
23
- 'bizplace',
24
- 'bizplace.domain',
25
- 'bizplace.company',
26
- 'bizplace.company.domain',
27
- 'orderProducts',
28
- 'orderProducts.product',
29
- 'orderProducts.product.productDetails',
30
- 'orderProducts.product.productDetails.childProductDetail',
31
- 'orderProducts.productDetail'
32
- ]
33
- })
34
-
35
- // search for any active marketplace connection
36
- const companyDomain: Domain = arrivalNotice.bizplace.company.domain
37
- const customerDomain: Domain = arrivalNotice.bizplace.domain
38
- const customerBizplaceId: string = arrivalNotice.bizplace.id
39
- const companyBizplace: Bizplace = await getCompanyBizplace(domain, null, customerBizplaceId, tx)
40
-
41
- // const orderSource: string = arrivalNotice.source
42
- // switch (orderSource) {
43
- // case ApplicationType.SELLERCRAFT:
44
- // const sellercraft: Sellercraft = await tx
45
- // .getRepository(Sellercraft)
46
- // .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
47
-
48
- // if (sellercraft) {
49
- // const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
50
- // await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
51
- // }
52
- // break
53
-
54
- // case ApplicationType.MMS:
55
- // const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
56
- // where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
57
- // relations: ['marketplaceDistributors']
58
- // })
59
-
60
- // if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
61
- // const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
62
- // await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
63
- // }
64
- // break
65
-
66
- // default:
67
- // break
68
- // }
69
-
70
- const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
71
- where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
72
- relations: ['marketplaceDistributors']
73
- })
74
-
75
- const sellercraft: Sellercraft = await tx
76
- .getRepository(Sellercraft)
77
- .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
78
-
79
- const application: Application = await tx
80
- .getRepository(Application)
81
- .findOne({ domain: companyBizplace.domain, status: 'ACTIVE', type: ApplicationType.POWRUP })
82
-
83
- if (sellercraft) {
84
- const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
85
-
86
- // allow async run to skip user wait time
87
- sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
88
- }
89
-
90
- if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
91
- const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
92
-
93
- // allow async run to skip user wait time
94
- ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
95
- }
96
-
97
- if (application) {
98
- const powrupController: PowrupController = new PowrupController()
99
-
100
- // allow async run to skip user wait time
101
- powrupController.updateStock(arrivalNotice.orderProducts, customerDomain, user)
17
+ try {
18
+ const { tx, user, domain }: { tx: EntityManager; user: User; domain: Domain } = context.state
19
+ await completePutaway(tx, domain, user, arrivalNoticeNo)
20
+
21
+ const arrivalNotice: ArrivalNotice = await tx.getRepository(ArrivalNotice).findOne({
22
+ where: { domain, name: arrivalNoticeNo },
23
+ relations: [
24
+ 'purchaseOrder',
25
+ 'bizplace',
26
+ 'bizplace.domain',
27
+ 'bizplace.company',
28
+ 'bizplace.company.domain',
29
+ 'orderProducts',
30
+ 'orderProducts.product',
31
+ 'orderProducts.product.productDetails',
32
+ 'orderProducts.product.productDetails.childProductDetail',
33
+ 'orderProducts.productDetail'
34
+ ]
35
+ })
36
+
37
+ // search for any active marketplace connection
38
+ const companyDomain: Domain = arrivalNotice.bizplace.company.domain
39
+ const customerDomain: Domain = arrivalNotice.bizplace.domain
40
+ const customerBizplaceId: string = arrivalNotice.bizplace.id
41
+ const companyBizplace: Bizplace = await getCompanyBizplace(domain, null, customerBizplaceId, tx)
42
+
43
+ const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
44
+ where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
45
+ relations: ['marketplaceDistributors']
46
+ })
47
+
48
+ const sellercraft: Sellercraft = await tx
49
+ .getRepository(Sellercraft)
50
+ .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
51
+
52
+ if (sellercraft) {
53
+ const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
54
+
55
+ // allow async run to skip user wait time
56
+ sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
57
+ }
58
+
59
+ if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
60
+ const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
61
+
62
+ // allow async run to skip user wait time
63
+ ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
64
+ }
65
+
66
+ const application: Application[] = await tx.getRepository(Application).find({
67
+ domain: companyBizplace.domain,
68
+ status: 'ACTIVE',
69
+ type: In([ApplicationType.POWRUP, ApplicationType.WEBSPERT])
70
+ })
71
+
72
+ if (application.find(app => app.type == ApplicationType.POWRUP)) {
73
+ const powrupController: PowrupController = new PowrupController()
74
+ powrupController.updateStock(arrivalNotice.orderProducts, customerDomain, user)
75
+ }
76
+ if (application.find(app => app.type == ApplicationType.WEBSPERT)) {
77
+ WebspertController.updateStock(arrivalNotice.orderProducts.map(op => op.productDetail), arrivalNotice.bizplace, domain, user, tx)
78
+ }
79
+
80
+ } catch (error) {
81
+ throw error
102
82
  }
103
83
  }
104
84
  }
@@ -1,8 +1,9 @@
1
- import { EntityManager } from 'typeorm'
1
+ import { EntityManager, In } from 'typeorm'
2
2
 
3
3
  import { Application, ApplicationType, User } from '@things-factory/auth-base'
4
4
  import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
5
5
  import { ReturnOrder, PowrupController } from '@things-factory/sales-base'
6
+ import { WebspertController } from '@things-factory/warehouse-base'
6
7
  import { Domain } from '@things-factory/shell'
7
8
  import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
8
9
 
@@ -35,19 +36,22 @@ export const completePutawayReturnResolver = {
35
36
 
36
37
  const customerBizplaceId: string = returnOrder.bizplace.id
37
38
  const companyBizplace: Bizplace = await getCompanyBizplace(domain, null, customerBizplaceId, tx)
38
- const application: Application = await tx
39
+ const application: Application[] = await tx
39
40
  .getRepository(Application)
40
- .findOne({ domain: companyBizplace.domain, status: 'ACTIVE', type: ApplicationType.POWRUP })
41
+ .find({ domain: companyBizplace.domain, status: 'ACTIVE', type: In([ApplicationType.POWRUP, ApplicationType.WEBSPERT]) })
41
42
 
42
43
  if (sellercraft) {
43
44
  const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
44
45
  await sellercraftCtrl.registerProductReturn(sellercraft, returnOrder)
45
46
  }
46
47
 
47
- if (application) {
48
+ if (application.find(app => app.type == ApplicationType.POWRUP)) {
48
49
  const powrupController: PowrupController = new PowrupController()
49
50
  powrupController.updateStock(returnOrder.orderInventories, customerDomain, user, tx)
50
51
  }
52
+ if (application.find(app => app.type == ApplicationType.WEBSPERT)) {
53
+ WebspertController.updateStock(returnOrder.orderInventories.map(oi => oi.productDetail), returnOrder.bizplace, domain, user, tx)
54
+ }
51
55
  }
52
56
  }
53
57