@things-factory/worksheet-base 4.3.27 → 4.3.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/worksheet-base",
3
- "version": "4.3.27",
3
+ "version": "4.3.28",
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.3.27",
30
30
  "@things-factory/id-rule-base": "^4.3.27",
31
31
  "@things-factory/integration-lmd": "^4.3.27",
32
- "@things-factory/integration-marketplace": "^4.3.27",
33
- "@things-factory/integration-sellercraft": "^4.3.27",
32
+ "@things-factory/integration-marketplace": "^4.3.28",
33
+ "@things-factory/integration-sellercraft": "^4.3.28",
34
34
  "@things-factory/integration-sftp": "^4.3.27",
35
- "@things-factory/marketplace-base": "^4.3.27",
35
+ "@things-factory/marketplace-base": "^4.3.28",
36
36
  "@things-factory/notification": "^4.3.27",
37
- "@things-factory/sales-base": "^4.3.27",
37
+ "@things-factory/sales-base": "^4.3.28",
38
38
  "@things-factory/setting-base": "^4.3.27",
39
39
  "@things-factory/shell": "^4.3.27",
40
40
  "@things-factory/transport-base": "^4.3.27",
41
- "@things-factory/warehouse-base": "^4.3.27"
41
+ "@things-factory/warehouse-base": "^4.3.28"
42
42
  },
43
- "gitHead": "52398bed65c4cf97263cd983c2c518e882ddbcde"
43
+ "gitHead": "f1af695e2848b49871ca1d4f1661a5620ed428da"
44
44
  }
@@ -5,6 +5,7 @@ import { generateId } from '@things-factory/id-rule-base'
5
5
  import { Product, ProductDetail } from '@things-factory/product-base'
6
6
  import {
7
7
  ORDER_INVENTORY_STATUS,
8
+ ORDER_PRODUCT_STATUS,
8
9
  ORDER_STATUS,
9
10
  OrderInventory,
10
11
  OrderNoGenerator,
@@ -344,7 +345,8 @@ export class PickingWorksheetController extends VasWorksheetController {
344
345
  'worksheetDetails',
345
346
  'worksheetDetails.targetInventory',
346
347
  'worksheetDetails.targetInventory.inventory',
347
- 'worksheetDetails.targetInventory.product'
348
+ 'worksheetDetails.targetInventory.product',
349
+ 'worksheetDetails.targetInventory.orderProduct'
348
350
  ])
349
351
 
350
352
  const worksheetDetails: WorksheetDetail[] = await this.extractMatchedWorksheetDetails(
@@ -353,7 +355,7 @@ export class PickingWorksheetController extends VasWorksheetController {
353
355
  productId,
354
356
  packingType,
355
357
  packingSize,
356
- ['targetInventory', 'targetInventory.inventory']
358
+ ['targetInventory', 'targetInventory.inventory', 'targetInventory.orderProduct']
357
359
  )
358
360
 
359
361
  let worksheetDetailIds: string[] = []
@@ -370,6 +372,13 @@ export class PickingWorksheetController extends VasWorksheetController {
370
372
  inventory.lockedQty = inventory.lockedQty - targetInventory.releaseQty
371
373
  inventory.lockedUomValue = inventory.lockedUomValue - targetInventory.releaseUomValue
372
374
  await this.updateInventory(inventory)
375
+
376
+ await this.trxMgr
377
+ .getRepository(OrderProduct)
378
+ .update(
379
+ { id: targetInventory.orderProduct.id },
380
+ { status: ORDER_PRODUCT_STATUS.PENDING_ASSIGN, updater: this.user }
381
+ )
373
382
  }
374
383
 
375
384
  await this.trxMgr.getRepository(WorksheetDetail).delete(worksheetDetailIds)
@@ -1,13 +1,56 @@
1
+ import { EntityManager } from 'typeorm'
2
+
1
3
  import { User } from '@things-factory/auth-base'
4
+ import { MarketplaceStore } from '@things-factory/integration-marketplace'
5
+ import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
6
+ import { ArrivalNotice } from '@things-factory/sales-base'
2
7
  import { Domain } from '@things-factory/shell'
3
- import { EntityManager } from 'typeorm'
8
+
4
9
  import { PutawayWorksheetController } from '../../../../controllers'
10
+ import { EcommerceController, SellercraftController } from '../../../../controllers/ecommerce'
5
11
  import { Worksheet } from '../../../../entities'
6
12
 
7
13
  export const completePutawayResolver = {
8
14
  async completePutaway(_: any, { arrivalNoticeNo }, context: any) {
9
15
  const { tx, user, domain }: { tx: EntityManager; user: User; domain: Domain } = context.state
10
16
  await completePutaway(tx, domain, user, arrivalNoticeNo)
17
+
18
+ const arrivalNotice: ArrivalNotice = await tx.getRepository(ArrivalNotice).findOne({
19
+ where: { domain, name: arrivalNoticeNo },
20
+ relations: [
21
+ 'purchaseOrder',
22
+ 'bizplace',
23
+ 'bizplace.domain',
24
+ 'bizplace.company',
25
+ 'bizplace.company.domain',
26
+ 'orderProducts',
27
+ 'orderProducts.product',
28
+ 'orderProducts.product.productDetails',
29
+ 'orderProducts.product.productDetails.childProductDetail'
30
+ ]
31
+ })
32
+
33
+ // search for any active marketplace connection
34
+ const companyDomain: Domain = arrivalNotice.bizplace.company.domain
35
+ const customerDomain: Domain = arrivalNotice.bizplace.domain
36
+ const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
37
+ where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
38
+ relations: ['marketplaceDistributors']
39
+ })
40
+
41
+ const sellercraft: Sellercraft = await tx
42
+ .getRepository(Sellercraft)
43
+ .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
44
+
45
+ if (sellercraft) {
46
+ const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
47
+ await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
48
+ }
49
+
50
+ if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
51
+ const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
52
+ await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
53
+ }
11
54
  }
12
55
  }
13
56
 
@@ -28,4 +71,4 @@ export async function completePutaway(
28
71
  relations: ['bizplace', 'arrivalNotice']
29
72
  })
30
73
  }
31
- }
74
+ }
@@ -2,15 +2,12 @@ import { EntityManager, In } from 'typeorm'
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Bizplace } from '@things-factory/biz-base'
5
- import { MarketplaceStore } from '@things-factory/integration-marketplace'
6
- import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
7
5
  import { ArrivalNotice, generateGoodsReceivalNote } from '@things-factory/sales-base'
8
6
  import { Domain } from '@things-factory/shell'
9
7
  import { Inventory, INVENTORY_STATUS } from '@things-factory/warehouse-base'
10
8
 
11
9
  import { WORKSHEET_STATUS } from '../../../../constants'
12
10
  import { PutawayWorksheetController, UnloadingWorksheetController } from '../../../../controllers'
13
- import { EcommerceController, SellercraftController } from '../../../../controllers/ecommerce'
14
11
  import { Worksheet, WorksheetDetail } from '../../../../entities'
15
12
 
16
13
  export const completeUnloadingResolver = {
@@ -40,28 +37,6 @@ export const completeUnloadingResolver = {
40
37
  where: { domain, refOrderId: arrivalNotice.id, status: In([INVENTORY_STATUS.UNLOADED, INVENTORY_STATUS.CHECKED]) }
41
38
  })
42
39
 
43
- // search for any active marketplace connection
44
- const companyDomain: Domain = arrivalNotice.bizplace.company.domain
45
- const customerDomain: Domain = arrivalNotice.bizplace.domain
46
- const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
47
- where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
48
- relations: ['marketplaceDistributors']
49
- })
50
-
51
- const sellercraft: Sellercraft = await tx
52
- .getRepository(Sellercraft)
53
- .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
54
-
55
- if (sellercraft) {
56
- const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
57
- await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
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
-
65
40
  putawayWorksheet = await putawayWSCtrl.generatePutawayWorksheet(arrivalNotice.name, inventories)
66
41
 
67
42
  if (putawayWorksheet.status === WORKSHEET_STATUS.DEACTIVATED) {
@@ -3,6 +3,7 @@ import { EntityManager, getRepository } from 'typeorm'
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import {
5
5
  ORDER_INVENTORY_STATUS,
6
+ ORDER_PRODUCT_STATUS,
6
7
  ORDER_TYPES,
7
8
  OrderInventory,
8
9
  OrderNoGenerator,
@@ -126,6 +127,14 @@ export const generateBatchPickingWorksheetDetailsByBulkResolver = {
126
127
  .where('id = :id', { id: targetInventory.id })
127
128
  await qbInv.execute()
128
129
 
130
+ // update order product status to ASSIGNED
131
+ await tx
132
+ .getRepository(OrderProduct)
133
+ .update(
134
+ { id: orderInventory.orderProduct.id },
135
+ { status: ORDER_PRODUCT_STATUS.ASSIGNED, updater: user }
136
+ )
137
+
129
138
  // Create new order inventory with status -> READY_TO_PICK, type -> RELEASE_OF_GOODS
130
139
  let newTargetInventory: OrderInventory = new OrderInventory()
131
140
  newTargetInventory = {
@@ -1,12 +1,20 @@
1
+ import { EntityManager } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
1
4
  import { Product } from '@things-factory/product-base'
2
- import { OrderInventory, OrderNoGenerator, ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
5
+ import {
6
+ ORDER_INVENTORY_STATUS,
7
+ ORDER_PRODUCT_STATUS,
8
+ OrderInventory,
9
+ OrderNoGenerator,
10
+ OrderProduct
11
+ } from '@things-factory/sales-base'
12
+ import { Domain } from '@things-factory/shell'
3
13
  import { Inventory } from '@things-factory/warehouse-base'
4
- import { EntityManager } from 'typeorm'
14
+
5
15
  import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
6
16
  import { Worksheet, WorksheetDetail } from '../../../entities'
7
17
  import { WorksheetNoGenerator } from '../../../utils'
8
- import { User } from '@things-factory/auth-base'
9
- import { Domain } from '@things-factory/shell'
10
18
 
11
19
  export const generateBatchPickingWorksheetDetailsResolver = {
12
20
  async generateBatchPickingWorksheetDetails(
@@ -124,6 +132,11 @@ export const generateBatchPickingWorksheetDetailsResolver = {
124
132
  }
125
133
  )
126
134
 
135
+ // update order product status to ASSIGNED
136
+ await tx
137
+ .getRepository(OrderProduct)
138
+ .update({ id: prevOrdInv.orderProduct.id }, { status: ORDER_PRODUCT_STATUS.ASSIGNED, updater: user })
139
+
127
140
  // Generate Worksheet Detail
128
141
  let newWorksheetDetail: WorksheetDetail = new WorksheetDetail()
129
142
  newWorksheetDetail = {
@@ -3,12 +3,13 @@ import { EntityManager } from 'typeorm'
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import {
5
5
  ORDER_INVENTORY_STATUS,
6
+ ORDER_PRODUCT_STATUS,
6
7
  ORDER_TYPES,
7
8
  OrderInventory,
8
9
  OrderInventoryPatch,
9
10
  OrderNoGenerator,
10
- ReleaseGood,
11
- OrderProduct
11
+ OrderProduct,
12
+ ReleaseGood
12
13
  } from '@things-factory/sales-base'
13
14
  import { Setting } from '@things-factory/setting-base'
14
15
  import { Domain } from '@things-factory/shell'
@@ -117,6 +118,11 @@ export const generatePickingWorksheetDetailsResolver = {
117
118
  .where('id = :id', { id: targetInventory.inventory.id })
118
119
  .execute()
119
120
 
121
+ // update order product status to ASSIGNED
122
+ await tx
123
+ .getRepository(OrderProduct)
124
+ .update({ id: targetInventory.orderProduct.id }, { status: ORDER_PRODUCT_STATUS.ASSIGNED, updater: user })
125
+
120
126
  // 7. collect new worksheet details records
121
127
  const worksheetDetail: WorksheetDetail = Object.assign(new WorksheetDetail(), {
122
128
  domain,
@@ -2,7 +2,13 @@ import { EntityManager } from 'typeorm'
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Product } from '@things-factory/product-base'
5
- import { ORDER_INVENTORY_STATUS, OrderInventory, OrderNoGenerator, OrderProduct } from '@things-factory/sales-base'
5
+ import {
6
+ ORDER_INVENTORY_STATUS,
7
+ ORDER_PRODUCT_STATUS,
8
+ OrderInventory,
9
+ OrderNoGenerator,
10
+ OrderProduct
11
+ } from '@things-factory/sales-base'
6
12
  import { Domain } from '@things-factory/shell'
7
13
  import { Inventory } from '@things-factory/warehouse-base'
8
14
 
@@ -110,6 +116,11 @@ export async function generateReleaseGoodWorksheetDetails(
110
116
  updater: user
111
117
  })
112
118
 
119
+ // update order product status to ASSIGNED
120
+ await tx
121
+ .getRepository(OrderProduct)
122
+ .update({ id: targetProduct.id }, { status: ORDER_PRODUCT_STATUS.ASSIGNED, updater: user })
123
+
113
124
  // 3. Create worksheet details
114
125
  await tx.getRepository(WorksheetDetail).save({
115
126
  ...wsd,