@things-factory/worksheet-base 4.3.82 → 4.3.87
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/controllers/inbound/unloading-worksheet-controller.js +49 -49
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +4 -2
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +4 -10
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +20 -22
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +154 -71
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +14 -12
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +2 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +37 -2
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/worksheet-detail.js +2 -1
- package/dist-server/entities/worksheet-detail.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +0 -6
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +6 -6
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +1 -2
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js +28 -67
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js +8 -23
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js +7 -30
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +8 -23
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +8 -25
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +12 -59
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +25 -51
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +118 -262
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js +38 -36
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js +4 -7
- package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +2 -3
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js +4 -6
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +14 -39
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/transfer.js +9 -9
- package/dist-server/graphql/resolvers/worksheet/transfer.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js +17 -17
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js +4 -4
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +0 -1
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +98 -1
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/inbound/unloading-worksheet-controller.ts +70 -49
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +4 -2
- package/server/controllers/outbound/loading-worksheet-controller.ts +3 -9
- package/server/controllers/outbound/packing-worksheet-controller.ts +31 -23
- package/server/controllers/outbound/picking-worksheet-controller.ts +219 -88
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +49 -5
- package/server/entities/worksheet-detail.ts +5 -0
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +0 -6
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +2 -1
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +1 -3
- package/server/graphql/resolvers/worksheet/loading/complete-loading.ts +33 -77
- package/server/graphql/resolvers/worksheet/packing/activate-packing.ts +9 -26
- package/server/graphql/resolvers/worksheet/packing/complete-packing.ts +9 -34
- package/server/graphql/resolvers/worksheet/packing/packing.ts +9 -26
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +9 -28
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +13 -68
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +30 -60
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +2 -2
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +130 -288
- package/server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.ts +42 -41
- package/server/graphql/resolvers/worksheet/picking/scan-product-picking.ts +10 -30
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +2 -3
- package/server/graphql/resolvers/worksheet/proceed-extra-products.ts +4 -5
- package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +15 -45
- package/server/graphql/resolvers/worksheet/transfer.ts +16 -18
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +2 -3
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +1 -4
- package/server/graphql/types/worksheet-detail/index.ts +0 -1
- package/server/utils/inventory-util.ts +126 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EntityManager,
|
|
1
|
+
import { EntityManager, getConnection } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import {
|
|
4
|
+
import { OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
5
5
|
import { Setting } from '@things-factory/setting-base'
|
|
6
6
|
import { Domain } from '@things-factory/shell'
|
|
7
7
|
|
|
@@ -20,15 +20,14 @@ export const fetchAndAssignPickingTaskResolver = {
|
|
|
20
20
|
|
|
21
21
|
if (!assignee) throw new Error('failed to find target user')
|
|
22
22
|
|
|
23
|
-
let worksheet:
|
|
23
|
+
let worksheet: Worksheet
|
|
24
24
|
let worksheetQb = await tx
|
|
25
25
|
.getRepository(Worksheet)
|
|
26
26
|
.createQueryBuilder('ws')
|
|
27
27
|
.select('ws.id')
|
|
28
28
|
.addSelect('ws.name')
|
|
29
29
|
.addSelect('ws.status')
|
|
30
|
-
.
|
|
31
|
-
.innerJoin('ws.releaseGood', 'rg')
|
|
30
|
+
.innerJoinAndSelect('ws.releaseGood', 'rg')
|
|
32
31
|
.where(
|
|
33
32
|
'(ws.domain_id = :domain_id AND ws.type = :type AND ws.assignee_id =:assignee AND (ws.status = :status1 OR ws.status = :status2))',
|
|
34
33
|
{
|
|
@@ -53,48 +52,50 @@ export const fetchAndAssignPickingTaskResolver = {
|
|
|
53
52
|
})
|
|
54
53
|
.orderBy('"rg"."created_at"', 'ASC')
|
|
55
54
|
|
|
56
|
-
worksheet = await worksheetQb.
|
|
55
|
+
worksheet = await worksheetQb.getOne()
|
|
57
56
|
|
|
58
57
|
if (!worksheet) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
domain_id
|
|
71
|
-
type
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
// update and return updated worksheet id
|
|
59
|
+
let updatedWorksheets = await getConnection().transaction(async (tx2: EntityManager) => {
|
|
60
|
+
let x = await tx2.getRepository(Worksheet).query(
|
|
61
|
+
`
|
|
62
|
+
UPDATE worksheets ws SET assignee_id = $2,
|
|
63
|
+
updated_at = NOW(),
|
|
64
|
+
updater_id = $2
|
|
65
|
+
FROM (
|
|
66
|
+
SELECT ws.id, ws.name, ws.status, ws.release_good_id FROM worksheets ws
|
|
67
|
+
INNER JOIN release_goods rg ON rg.id = ws.release_good_id
|
|
68
|
+
WHERE
|
|
69
|
+
ws.domain_id = $1 AND
|
|
70
|
+
ws.type = 'PICKING' AND
|
|
71
|
+
ws.assignee_id IS NULL AND
|
|
72
|
+
(ws.status = 'EXECUTING' OR ws.status = 'DEACTIVATED') AND
|
|
73
|
+
NOT EXISTS (
|
|
74
|
+
SELECT count(id) AS "totalPS"
|
|
75
|
+
FROM order_inventories oi
|
|
76
|
+
WHERE oi.release_good_id = ws.release_good_id AND
|
|
77
|
+
oi.status = 'PENDING_SPLIT'
|
|
78
|
+
GROUP BY oi.release_good_id
|
|
79
|
+
HAVING count(id) > 0
|
|
80
|
+
)
|
|
81
|
+
ORDER BY rg.release_date, rg.created_at LIMIT 1
|
|
82
|
+
) src where src.id = ws.id
|
|
83
|
+
RETURNING ws.id;
|
|
84
|
+
`,
|
|
85
|
+
[domain.id, assignee.id]
|
|
75
86
|
)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.subQuery()
|
|
79
|
-
.select('COUNT(*) AS totalPS')
|
|
80
|
-
.from(OrderInventory, 'OrderInventory')
|
|
81
|
-
.where('OrderInventory.release_good_id = ws.release_good_id')
|
|
82
|
-
.andWhere(`OrderInventory.status = 'PENDING_SPLIT'`)
|
|
83
|
-
.groupBy('OrderInventory.release_good_id')
|
|
84
|
-
.having('COUNT(*) > 0')
|
|
85
|
-
.getQuery()
|
|
86
|
-
return 'NOT EXISTS ' + subQuery
|
|
87
|
-
})
|
|
88
|
-
.orderBy('"rg"."created_at"', 'ASC')
|
|
87
|
+
return x[0]
|
|
88
|
+
})
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
if (updatedWorksheets.length == 0) throw new Error('no suitable worksheet found')
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
// relace worksheet with newly assigned worksheet
|
|
93
|
+
worksheet = await tx
|
|
94
|
+
.getRepository(Worksheet)
|
|
95
|
+
.findOne({ where: { id: updatedWorksheets[0].id }, relations: ['releaseGood'] })
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
if (worksheet.
|
|
97
|
-
await activatePicking(tx, domain, user, worksheet.ws_name)
|
|
98
|
+
if (worksheet.status == WORKSHEET_STATUS.DEACTIVATED) await activatePicking(tx, domain, user, worksheet.name)
|
|
98
99
|
|
|
99
100
|
const locationSortingRules: Setting = await tx.getRepository(Setting).findOne({
|
|
100
101
|
where: { domain, name: 'rule-for-picking-product' }
|
|
@@ -105,7 +106,7 @@ export const fetchAndAssignPickingTaskResolver = {
|
|
|
105
106
|
return { name: field, desc: sortingRule[field] === 'DESC' }
|
|
106
107
|
})
|
|
107
108
|
|
|
108
|
-
const releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne(worksheet.
|
|
109
|
+
const releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne(worksheet.releaseGood.id)
|
|
109
110
|
|
|
110
111
|
return await pickingWorksheet(domain, releaseGood.name, locationSortingRule, tx)
|
|
111
112
|
} catch (error) {
|
|
@@ -3,6 +3,9 @@ import { Domain } from '@things-factory/shell'
|
|
|
3
3
|
import { EntityManager } from 'typeorm'
|
|
4
4
|
import { PickingWorksheetController } from '../../../../controllers'
|
|
5
5
|
|
|
6
|
+
import { pickingWorksheet } from '../picking-worksheet'
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
export const scanProductPickingResolver = {
|
|
7
10
|
async scanProductPicking(
|
|
8
11
|
_: any,
|
|
@@ -10,10 +13,9 @@ export const scanProductPickingResolver = {
|
|
|
10
13
|
context: any
|
|
11
14
|
) {
|
|
12
15
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
user,
|
|
16
|
+
|
|
17
|
+
const worksheetController: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
|
|
18
|
+
let ws = await worksheetController.scanProductPicking(
|
|
17
19
|
worksheetDetailName,
|
|
18
20
|
worksheetType,
|
|
19
21
|
productBarcode,
|
|
@@ -23,31 +25,9 @@ export const scanProductPickingResolver = {
|
|
|
23
25
|
toteNo,
|
|
24
26
|
pickingQty
|
|
25
27
|
)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
worksheetDetailName: string,
|
|
34
|
-
worksheetType: string,
|
|
35
|
-
productBarcode: string,
|
|
36
|
-
cartonId: string,
|
|
37
|
-
binLocation?: string,
|
|
38
|
-
serialNumber?: string,
|
|
39
|
-
toteNo?: string,
|
|
40
|
-
pickingQty?: number
|
|
41
|
-
) {
|
|
42
|
-
const worksheetController: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
|
|
43
|
-
await worksheetController.scanProductPicking(
|
|
44
|
-
worksheetDetailName,
|
|
45
|
-
worksheetType,
|
|
46
|
-
productBarcode,
|
|
47
|
-
cartonId,
|
|
48
|
-
binLocation,
|
|
49
|
-
serialNumber,
|
|
50
|
-
toteNo,
|
|
51
|
-
pickingQty
|
|
52
|
-
)
|
|
29
|
+
|
|
30
|
+
// return await pickingWorksheet(domain, releaseGoodNo, locationSortingRule, tx)
|
|
31
|
+
|
|
32
|
+
}
|
|
53
33
|
}
|
|
@@ -76,7 +76,6 @@ export async function pickingWorksheet(
|
|
|
76
76
|
.leftJoinAndSelect('T_INV.binLocation', 'BIN_LOC')
|
|
77
77
|
.leftJoinAndSelect('T_INV.inventory', 'INV')
|
|
78
78
|
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
79
|
-
.leftJoinAndSelect('T_INV.productDetail', 'PROD_DET')
|
|
80
79
|
.leftJoinAndSelect('INV.location', 'LOC')
|
|
81
80
|
|
|
82
81
|
if (locationSortingRules?.length > 0) {
|
|
@@ -115,8 +114,8 @@ export async function pickingWorksheet(
|
|
|
115
114
|
const inventoryChangesCount: number = await tx.getRepository(InventoryChange).count({
|
|
116
115
|
where: {
|
|
117
116
|
inventory: inventory.id,
|
|
118
|
-
status:
|
|
119
|
-
transactionType:
|
|
117
|
+
status: "PENDING",
|
|
118
|
+
transactionType: "MISSING"
|
|
120
119
|
},
|
|
121
120
|
relations: ['inventory', 'product']
|
|
122
121
|
})
|
|
@@ -73,7 +73,7 @@ export const proceedExtraProductsResolver = {
|
|
|
73
73
|
if (editedApprovedProducts?.length > 0) {
|
|
74
74
|
editedApprovedProducts.map((editedApprovedProd: OrderProduct) => {
|
|
75
75
|
const selectedOrderProduct: OrderProduct = storedOrderProducts.find(
|
|
76
|
-
(op: OrderProduct) => op.
|
|
76
|
+
(op: OrderProduct) => op.id === editedApprovedProd.id
|
|
77
77
|
)
|
|
78
78
|
|
|
79
79
|
updatedOrderProducts.push({
|
|
@@ -115,7 +115,7 @@ export const proceedExtraProductsResolver = {
|
|
|
115
115
|
if (addedApprovedProducts?.length > 0) {
|
|
116
116
|
addedApprovedProducts.map((addedApprovedProd: OrderProduct) => {
|
|
117
117
|
const selectedOrderProduct: OrderProduct = storedOrderProducts.find(
|
|
118
|
-
(op: OrderProduct) => op.
|
|
118
|
+
(op: OrderProduct) => op.id === addedApprovedProd.id
|
|
119
119
|
)
|
|
120
120
|
updatedOrderProducts.push({
|
|
121
121
|
...selectedOrderProduct,
|
|
@@ -173,7 +173,7 @@ export const proceedExtraProductsResolver = {
|
|
|
173
173
|
if (editedRejectedProducts?.length > 0) {
|
|
174
174
|
editedRejectedProducts = editedRejectedProducts.map((editedRejectProduct: OrderProduct) => {
|
|
175
175
|
const selectedOrderProduct: OrderProduct = storedOrderProducts.find(
|
|
176
|
-
(op: OrderProduct) => op.
|
|
176
|
+
(op: OrderProduct) => op.id === editedRejectProduct.id
|
|
177
177
|
)
|
|
178
178
|
|
|
179
179
|
return {
|
|
@@ -194,8 +194,7 @@ export const proceedExtraProductsResolver = {
|
|
|
194
194
|
let deleteOrderProducts: OrderProduct[] = []
|
|
195
195
|
addedRejectedProducts.map(rejectedOp => {
|
|
196
196
|
const selectedOrderProduct: OrderProduct[] = storedOrderProducts.find(
|
|
197
|
-
|
|
198
|
-
(op: OrderProduct) => op.productDetailId === rejectedOp.productDetailId
|
|
197
|
+
(op: OrderProduct) => op.id === rejectedOp.id
|
|
199
198
|
)
|
|
200
199
|
deleteOrderProducts.push(selectedOrderProduct)
|
|
201
200
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityManager } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { 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 } from '@things-factory/sales-base'
|
|
@@ -33,54 +33,24 @@ export const completePutawayResolver = {
|
|
|
33
33
|
// search for any active marketplace connection
|
|
34
34
|
const companyDomain: Domain = arrivalNotice.bizplace.company.domain
|
|
35
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
|
+
})
|
|
36
40
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const sellercraft: Sellercraft = await tx
|
|
41
|
-
.getRepository(Sellercraft)
|
|
42
|
-
.findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
|
|
43
|
-
|
|
44
|
-
if (sellercraft) {
|
|
45
|
-
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
46
|
-
await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
|
|
47
|
-
}
|
|
48
|
-
break
|
|
49
|
-
|
|
50
|
-
case ApplicationType.MMS:
|
|
51
|
-
const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
52
|
-
where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
|
|
53
|
-
relations: ['marketplaceDistributors']
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
57
|
-
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
58
|
-
await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
|
|
59
|
-
}
|
|
60
|
-
break
|
|
41
|
+
const sellercraft: Sellercraft = await tx
|
|
42
|
+
.getRepository(Sellercraft)
|
|
43
|
+
.findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
|
|
61
44
|
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
if (sellercraft) {
|
|
46
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
47
|
+
await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
|
|
64
48
|
}
|
|
65
49
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// const sellercraft: Sellercraft = await tx
|
|
72
|
-
// .getRepository(Sellercraft)
|
|
73
|
-
// .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
|
|
74
|
-
|
|
75
|
-
// if (sellercraft) {
|
|
76
|
-
// const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
77
|
-
// await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
// if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
81
|
-
// const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
82
|
-
// await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
|
|
83
|
-
// }
|
|
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
|
+
}
|
|
84
54
|
}
|
|
85
55
|
}
|
|
86
56
|
|
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
1
|
import { User } from '@things-factory/auth-base'
|
|
4
2
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { ORDER_PRODUCT_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
6
3
|
import { Domain } from '@things-factory/shell'
|
|
4
|
+
import { OrderInventory, ORDER_PRODUCT_STATUS } from '@things-factory/sales-base'
|
|
7
5
|
import {
|
|
8
6
|
Inventory,
|
|
9
|
-
INVENTORY_STATUS,
|
|
10
|
-
INVENTORY_TRANSACTION_TYPE,
|
|
11
7
|
InventoryHistory,
|
|
12
|
-
InventoryNoGenerator
|
|
8
|
+
InventoryNoGenerator,
|
|
9
|
+
INVENTORY_STATUS,
|
|
10
|
+
INVENTORY_TRANSACTION_TYPE
|
|
13
11
|
} from '@things-factory/warehouse-base'
|
|
14
|
-
|
|
12
|
+
import { EntityManager } from 'typeorm'
|
|
15
13
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
16
14
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
17
15
|
|
|
18
16
|
export const transfer = {
|
|
19
17
|
async transfer(_: any, { palletId, toPalletId, qty }, context: any) {
|
|
20
|
-
const {
|
|
21
|
-
|
|
18
|
+
const {
|
|
19
|
+
tx,
|
|
20
|
+
domain,
|
|
21
|
+
bizplace,
|
|
22
|
+
user
|
|
23
|
+
}: { tx: EntityManager; domain: Domain; bizplace: Bizplace; user: User } = context.state
|
|
22
24
|
|
|
23
25
|
// 1. get to inventory
|
|
24
26
|
let toInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
25
27
|
where: { domain: domain, palletId: toPalletId },
|
|
26
|
-
relations: ['bizplace', 'product', '
|
|
28
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
27
29
|
})
|
|
28
30
|
if (!toInventory) throw new Error(`to pallet doesn't exists`)
|
|
29
31
|
|
|
30
32
|
// 2. get from inventory
|
|
31
33
|
let fromInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
32
34
|
where: { domain: domain, palletId },
|
|
33
|
-
relations: ['bizplace', 'product', '
|
|
35
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
34
36
|
})
|
|
35
37
|
if (!fromInventory) throw new Error(`from pallet doesn't exists`)
|
|
36
38
|
if (toInventory.batchId !== fromInventory.batchId) throw new Error(`Can't transfer to different batch`)
|
|
@@ -72,7 +74,6 @@ export const transfer = {
|
|
|
72
74
|
domain: domain,
|
|
73
75
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
74
76
|
product: toInventory.product,
|
|
75
|
-
productDetail: toInventory.productDetail,
|
|
76
77
|
warehouse: toInventory.warehouse,
|
|
77
78
|
location: toInventory.location,
|
|
78
79
|
seq: toInventory.lastSeq,
|
|
@@ -96,7 +97,7 @@ export const transfer = {
|
|
|
96
97
|
|
|
97
98
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
98
99
|
where: { id: fromInventory.id },
|
|
99
|
-
relations: ['bizplace', 'product', '
|
|
100
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
100
101
|
})
|
|
101
102
|
|
|
102
103
|
// - add inventory history
|
|
@@ -104,7 +105,6 @@ export const transfer = {
|
|
|
104
105
|
...fromInventory,
|
|
105
106
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
106
107
|
product: fromInventory.product,
|
|
107
|
-
productDetail: fromInventory.productDetail,
|
|
108
108
|
warehouse: fromInventory.warehouse,
|
|
109
109
|
location: fromInventory.location,
|
|
110
110
|
seq: fromInventory.lastSeq,
|
|
@@ -131,7 +131,7 @@ export const transfer = {
|
|
|
131
131
|
|
|
132
132
|
toInventory = await tx.getRepository(Inventory).findOne({
|
|
133
133
|
where: { id: toInventory.id },
|
|
134
|
-
relations: ['bizplace', 'product', '
|
|
134
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
135
135
|
})
|
|
136
136
|
// - add inventory history
|
|
137
137
|
delete toInventory.id
|
|
@@ -140,7 +140,6 @@ export const transfer = {
|
|
|
140
140
|
domain,
|
|
141
141
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
142
142
|
product: toInventory.product,
|
|
143
|
-
productDetail: toInventory.productDetail,
|
|
144
143
|
warehouse: toInventory.warehouse,
|
|
145
144
|
location: toInventory.location,
|
|
146
145
|
seq: toInventory.lastSeq,
|
|
@@ -158,7 +157,7 @@ export const transfer = {
|
|
|
158
157
|
|
|
159
158
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
160
159
|
where: { id: fromInventory.id },
|
|
161
|
-
relations: ['bizplace', 'product', '
|
|
160
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
162
161
|
})
|
|
163
162
|
|
|
164
163
|
// - add inventory history
|
|
@@ -166,7 +165,6 @@ export const transfer = {
|
|
|
166
165
|
...fromInventory,
|
|
167
166
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
168
167
|
product: fromInventory.product,
|
|
169
|
-
productDetail: fromInventory.productDetail,
|
|
170
168
|
warehouse: fromInventory.warehouse,
|
|
171
169
|
location: fromInventory.location,
|
|
172
170
|
seq: fromInventory.lastSeq,
|
|
@@ -19,13 +19,12 @@ import {
|
|
|
19
19
|
InventoryNoGenerator,
|
|
20
20
|
Location,
|
|
21
21
|
Pallet,
|
|
22
|
-
Warehouse
|
|
23
|
-
generateInventoryHistory
|
|
22
|
+
Warehouse
|
|
24
23
|
} from '@things-factory/warehouse-base'
|
|
25
24
|
|
|
26
25
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../../constants'
|
|
27
26
|
import { Worksheet, WorksheetDetail } from '../../../../entities'
|
|
28
|
-
import { WorksheetNoGenerator } from '../../../../utils'
|
|
27
|
+
import { generateInventoryHistory, WorksheetNoGenerator } from '../../../../utils'
|
|
29
28
|
import {
|
|
30
29
|
OperationGuideInterface,
|
|
31
30
|
PackingUnits,
|
package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { WorksheetNoGenerator } from '../../../utils'
|
|
|
19
19
|
export const regenerateReleaseGoodWorksheetDetailsResolver = {
|
|
20
20
|
async regenerateReleaseGoodWorksheetDetails(
|
|
21
21
|
_: any,
|
|
22
|
-
{ worksheetNo, batchId, productId,
|
|
22
|
+
{ worksheetNo, batchId, productId, packingType, packingSize, orderProductId, worksheetDetails },
|
|
23
23
|
context: any
|
|
24
24
|
): Promise<void> {
|
|
25
25
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
@@ -30,7 +30,6 @@ export const regenerateReleaseGoodWorksheetDetailsResolver = {
|
|
|
30
30
|
worksheetNo,
|
|
31
31
|
batchId,
|
|
32
32
|
productId,
|
|
33
|
-
productDetailId,
|
|
34
33
|
packingType,
|
|
35
34
|
packingSize,
|
|
36
35
|
orderProductId,
|
|
@@ -46,7 +45,6 @@ export async function regenerateReleaseGoodWorksheetDetails(
|
|
|
46
45
|
worksheetNo: string,
|
|
47
46
|
batchId: string,
|
|
48
47
|
productId: string,
|
|
49
|
-
productDetailId: string,
|
|
50
48
|
packingType: string,
|
|
51
49
|
packingSize: number,
|
|
52
50
|
orderProductId: string,
|
|
@@ -117,7 +115,6 @@ export async function regenerateReleaseGoodWorksheetDetails(
|
|
|
117
115
|
batchIdRef: inventory.batchIdRef,
|
|
118
116
|
status: ORDER_INVENTORY_STATUS.READY_TO_PICK,
|
|
119
117
|
product: await tx.getRepository(Product).findOne(productId),
|
|
120
|
-
productDetail: productDetailId,
|
|
121
118
|
packingType,
|
|
122
119
|
packingSize,
|
|
123
120
|
orderProduct: targetProduct,
|
|
@@ -4,9 +4,134 @@ import { User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
5
|
import { Product } from '@things-factory/product-base'
|
|
6
6
|
import { Domain } from '@things-factory/shell'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Inventory,
|
|
9
|
+
INVENTORY_STATUS,
|
|
10
|
+
InventoryHistory,
|
|
11
|
+
InventoryNoGenerator,
|
|
12
|
+
Location,
|
|
13
|
+
LOCATION_STATUS,
|
|
14
|
+
LOCATION_TYPE
|
|
15
|
+
} from '@things-factory/warehouse-base'
|
|
8
16
|
|
|
9
17
|
/**
|
|
18
|
+
* @description It will insert new record into inventory histories table.
|
|
19
|
+
* seq will be calculated based on number of records for one specific pallet id (provided by inventory object)
|
|
20
|
+
*/
|
|
21
|
+
export async function generateInventoryHistory(
|
|
22
|
+
inventory: Inventory,
|
|
23
|
+
refOrder: any,
|
|
24
|
+
transactionType: string,
|
|
25
|
+
qty: number = 0,
|
|
26
|
+
uomValue: number = 0,
|
|
27
|
+
user: User,
|
|
28
|
+
trxMgr?: EntityManager,
|
|
29
|
+
targetInventory: Inventory = {}
|
|
30
|
+
): Promise<InventoryHistory> {
|
|
31
|
+
const invHistoryRepo: Repository<InventoryHistory> =
|
|
32
|
+
trxMgr?.getRepository(InventoryHistory) || getRepository(InventoryHistory)
|
|
33
|
+
const invRepo: Repository<Inventory> = trxMgr?.getRepository(Inventory) || getRepository(Inventory)
|
|
34
|
+
|
|
35
|
+
if (!inventory?.id) throw new Error(`Can't find out ID of inventory.`)
|
|
36
|
+
if (!refOrder?.id || !refOrder.name) throw new Error(`Can't find out ID or Name of Reference Order`)
|
|
37
|
+
if (
|
|
38
|
+
!inventory?.domain ||
|
|
39
|
+
!inventory?.bizplace ||
|
|
40
|
+
!inventory?.product?.id ||
|
|
41
|
+
!inventory?.warehouse?.id ||
|
|
42
|
+
!inventory?.location?.id
|
|
43
|
+
) {
|
|
44
|
+
inventory = await invRepo.findOne({
|
|
45
|
+
where: { id: inventory.id },
|
|
46
|
+
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const domain: Domain = inventory.domain
|
|
51
|
+
const location: Location = inventory.location
|
|
52
|
+
|
|
53
|
+
const seq: number = await invHistoryRepo.count({ domain: inventory.domain, palletId: inventory.palletId })
|
|
54
|
+
let openingQty: number = 0
|
|
55
|
+
let openingUomValue: number = 0
|
|
56
|
+
|
|
57
|
+
if (seq) {
|
|
58
|
+
const lastInvHistory: InventoryHistory = await invHistoryRepo.findOne({
|
|
59
|
+
domain: inventory.domain,
|
|
60
|
+
palletId: inventory.palletId,
|
|
61
|
+
seq: seq - 1
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
openingQty = lastInvHistory.openingQty + lastInvHistory.qty
|
|
65
|
+
openingUomValue = lastInvHistory.openingUomValue + lastInvHistory.uomValue
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (transactionType == 'PICKING' || transactionType == 'UNLOADING') {
|
|
69
|
+
const [findSameOrderHistory, total]: InventoryHistory = await invHistoryRepo.findAndCount({
|
|
70
|
+
domain: inventory.domain,
|
|
71
|
+
palletId: inventory.palletId,
|
|
72
|
+
refOrderId: refOrder.id
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
if (findSameOrderHistory) {
|
|
76
|
+
let prevTotalQty = 0
|
|
77
|
+
let prevTotalUomValue = 0
|
|
78
|
+
for (let oh of findSameOrderHistory) {
|
|
79
|
+
prevTotalQty += oh.qty
|
|
80
|
+
prevTotalUomValue += oh.uomValue
|
|
81
|
+
}
|
|
82
|
+
qty -= prevTotalQty
|
|
83
|
+
uomValue -= prevTotalUomValue
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let inventoryHistory: InventoryHistory = new InventoryHistory()
|
|
88
|
+
inventoryHistory.name = InventoryNoGenerator.inventoryHistoryName()
|
|
89
|
+
inventoryHistory.description = inventory.description
|
|
90
|
+
inventoryHistory.seq = seq
|
|
91
|
+
inventoryHistory.palletId = inventory.palletId
|
|
92
|
+
inventoryHistory.cartonId = inventory.cartonId
|
|
93
|
+
inventoryHistory.batchId = inventory.batchId
|
|
94
|
+
inventoryHistory.batchIdRef = inventory.batchIdRef
|
|
95
|
+
inventoryHistory.status = inventory.status
|
|
96
|
+
inventoryHistory.transactionType = transactionType
|
|
97
|
+
inventoryHistory.refOrderId = refOrder?.id || null
|
|
98
|
+
inventoryHistory.orderNo = refOrder?.name || null
|
|
99
|
+
inventoryHistory.orderRefNo = refOrder?.refNo || null
|
|
100
|
+
inventoryHistory.inventory = inventory
|
|
101
|
+
inventoryHistory.targetInventory = targetInventory
|
|
102
|
+
inventoryHistory.product = inventory.product
|
|
103
|
+
inventoryHistory.reusablePallet = inventory.reusablePallet
|
|
104
|
+
inventoryHistory.zone = inventory.zone
|
|
105
|
+
inventoryHistory.warehouse = inventory.warehouse
|
|
106
|
+
inventoryHistory.location = inventory.location
|
|
107
|
+
inventoryHistory.expirationDate = inventory.expirationDate
|
|
108
|
+
inventoryHistory.packingType = inventory.packingType
|
|
109
|
+
inventoryHistory.packingSize = inventory.packingSize
|
|
110
|
+
inventoryHistory.uom = inventory.uom
|
|
111
|
+
inventoryHistory.qty = qty
|
|
112
|
+
inventoryHistory.openingQty = openingQty
|
|
113
|
+
inventoryHistory.uomValue = uomValue
|
|
114
|
+
inventoryHistory.openingUomValue = openingUomValue
|
|
115
|
+
inventoryHistory.unitCost = inventory.unitCost
|
|
116
|
+
inventoryHistory.domain = inventory.domain
|
|
117
|
+
inventoryHistory.bizplace = inventory.bizplace
|
|
118
|
+
inventoryHistory.creator = user
|
|
119
|
+
inventoryHistory.updater = user
|
|
120
|
+
|
|
121
|
+
inventoryHistory = await invHistoryRepo.save(inventoryHistory)
|
|
122
|
+
|
|
123
|
+
if (inventory.lastSeq !== seq) {
|
|
124
|
+
await invRepo.save({
|
|
125
|
+
id: inventory.id,
|
|
126
|
+
lastSeq: inventoryHistory.seq,
|
|
127
|
+
updater: user
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await switchLocationStatus(domain, location, user, trxMgr)
|
|
132
|
+
return inventoryHistory
|
|
133
|
+
}
|
|
134
|
+
|
|
10
135
|
/**
|
|
11
136
|
* @description: Check location emptiness and update status of location
|
|
12
137
|
* @param domain
|