@things-factory/worksheet-base 4.3.103 → 4.3.105-alpha.0
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 +56 -72
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +2 -4
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +10 -4
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +51 -34
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +78 -48
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +12 -14
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-orientage-do.js +2 -2
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +1 -2
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +3 -8
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +3 -2
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +29 -62
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +1 -2
- 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 +2 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +5 -22
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +39 -59
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.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/unloaded-inventories.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.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/worksheets.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheets.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/index.js +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +1 -98
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/dist-server/utils/worksheet-util.js +1 -3
- package/dist-server/utils/worksheet-util.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/inbound/unloading-worksheet-controller.ts +70 -85
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +2 -4
- package/server/controllers/outbound/loading-worksheet-controller.ts +9 -3
- package/server/controllers/outbound/packing-worksheet-controller.ts +61 -51
- package/server/controllers/outbound/picking-worksheet-controller.ts +98 -66
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/render-orientage-do.ts +2 -3
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +18 -23
- package/server/entities/index.ts +2 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +29 -63
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +6 -0
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +1 -2
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +3 -1
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +5 -24
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +58 -95
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +3 -2
- package/server/graphql/resolvers/worksheet/transfer.ts +18 -16
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +1 -1
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +3 -2
- package/server/graphql/resolvers/worksheet/worksheets.ts +1 -1
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +4 -1
- package/server/graphql/types/worksheet/index.ts +1 -1
- package/server/graphql/types/worksheet-detail/index.ts +1 -0
- package/server/utils/inventory-util.ts +1 -126
- package/server/utils/worksheet-util.ts +1 -3
|
@@ -2,55 +2,23 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
2
2
|
|
|
3
3
|
@ViewEntity({
|
|
4
4
|
expression: `
|
|
5
|
-
select d.name as "
|
|
6
|
-
WITH oi as (
|
|
7
|
-
select
|
|
8
|
-
oi.domain_id,
|
|
9
|
-
oi.bizplace_id,
|
|
10
|
-
SUM(oi.release_qty) AS release_qty,
|
|
11
|
-
SUM(oi.release_uom_value) AS release_uom_value,
|
|
12
|
-
oi.batch_id,
|
|
13
|
-
oi.batch_id_ref,
|
|
14
|
-
oi.product_id,
|
|
15
|
-
oi.packing_type,
|
|
16
|
-
oi.packing_size,
|
|
17
|
-
oi.uom
|
|
18
|
-
FROM
|
|
19
|
-
order_inventories oi
|
|
20
|
-
WHERE
|
|
21
|
-
(oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
|
|
22
|
-
AND oi.batch_id NOTNULL
|
|
23
|
-
AND oi.product_id NOTNULL
|
|
24
|
-
AND oi.packing_type NOTNULL
|
|
25
|
-
AND oi.packing_size NOTNULL
|
|
26
|
-
AND oi.inventory_id IS NULL
|
|
27
|
-
GROUP BY
|
|
28
|
-
oi.domain_id,
|
|
29
|
-
oi.bizplace_id,
|
|
30
|
-
oi.batch_id,
|
|
31
|
-
oi.batch_id_ref,
|
|
32
|
-
oi.product_id,
|
|
33
|
-
oi.packing_type,
|
|
34
|
-
oi.packing_size,
|
|
35
|
-
oi.uom
|
|
36
|
-
)
|
|
5
|
+
select d.name as "domain_name", b.name as "bizplace_name", src.* from (
|
|
37
6
|
-- SINGLE ITEM INVENTORY QUERY
|
|
38
7
|
select
|
|
39
|
-
i.domain_id as "
|
|
40
|
-
i.bizplace_id as "
|
|
41
|
-
i.packing_type as "
|
|
42
|
-
i.packing_size as "
|
|
8
|
+
i.domain_id as "domain_id",
|
|
9
|
+
i.bizplace_id as "bizplace_id",
|
|
10
|
+
i.packing_type as "packing_type",
|
|
11
|
+
i.packing_size as "packing_size",
|
|
43
12
|
i.uom,
|
|
44
|
-
i.product_id as "
|
|
45
|
-
null as "
|
|
46
|
-
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0))
|
|
47
|
-
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0))
|
|
13
|
+
i.product_id as "product_id",
|
|
14
|
+
null as "product_bundle_id",
|
|
15
|
+
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0))) AS "remain_qty",
|
|
16
|
+
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0))) AS "remain_uom_value",
|
|
48
17
|
COALESCE(sum(COALESCE(i.qty, 0::double precision))) AS "qty",
|
|
49
|
-
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "
|
|
50
|
-
'SINGLE' AS "
|
|
18
|
+
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "uom_value",
|
|
19
|
+
'SINGLE' AS "group_type"
|
|
51
20
|
FROM inventories i
|
|
52
21
|
INNER JOIN locations l2 ON i.location_id = l2.id AND i.domain_id = l2.domain_id AND l2.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
53
|
-
LEFT JOIN oi ON i.batch_id = oi.batch_id AND i.product_id = oi.product_id AND i.packing_type = oi.packing_type AND i.packing_size = oi.packing_size AND i.uom = oi.uom
|
|
54
22
|
WHERE i.status = 'STORED'
|
|
55
23
|
GROUP by
|
|
56
24
|
i.domain_id,
|
|
@@ -62,29 +30,28 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
62
30
|
union all
|
|
63
31
|
-- BUNDLE ITEM INVENTORY QUERY
|
|
64
32
|
SELECT
|
|
65
|
-
pbs.domain_id as "
|
|
66
|
-
pbs.bizplace_id as "
|
|
67
|
-
pb.packing_type as "
|
|
68
|
-
pb.packing_size as "
|
|
33
|
+
pbs.domain_id as "domain_id",
|
|
34
|
+
pbs.bizplace_id as "bizplace_id",
|
|
35
|
+
pb.packing_type as "packing_type",
|
|
36
|
+
pb.packing_size as "packing_size",
|
|
69
37
|
'UNIT' AS "uom",
|
|
70
|
-
null as "
|
|
71
|
-
pb.id AS "
|
|
72
|
-
COALESCE(MIN(FLOOR(pbs."
|
|
73
|
-
COALESCE(MIN(FLOOR(pbs."
|
|
38
|
+
null as "product_id",
|
|
39
|
+
pb.id AS "product_bundle_id",
|
|
40
|
+
COALESCE(MIN(FLOOR(pbs."available_qty")),0) AS "remain_qty",
|
|
41
|
+
COALESCE(MIN(FLOOR(pbs."available_uom_value")),0) AS "remain_uom_value",
|
|
74
42
|
COALESCE(MIN(FLOOR(pbs."qty")), 0::double precision) AS "qty",
|
|
75
|
-
COALESCE(MIN(FLOOR(pbs."
|
|
76
|
-
'BUNDLE' AS "
|
|
43
|
+
COALESCE(MIN(FLOOR(pbs."uom_value")), 0::double precision) AS "uom_value",
|
|
44
|
+
'BUNDLE' AS "group_type"
|
|
77
45
|
FROM product_bundles pb
|
|
78
46
|
INNER JOIN (
|
|
79
47
|
SELECT i.domain_id, i.bizplace_id, pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
80
|
-
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0))
|
|
81
|
-
(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0))
|
|
48
|
+
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0))) / min(pbs.bundle_qty) AS "available_qty",
|
|
49
|
+
(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0))) / min(pbs.bundle_qty) AS "available_uom_value",
|
|
82
50
|
(sum(COALESCE(i.qty, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "qty",
|
|
83
|
-
(sum(COALESCE(i.uom_value, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "
|
|
51
|
+
(sum(COALESCE(i.uom_value, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "uom_value"
|
|
84
52
|
FROM product_bundle_settings pbs
|
|
85
53
|
LEFT JOIN inventories i ON i.product_id = pbs.product_id AND i.status = 'STORED'
|
|
86
|
-
INNER JOIN locations l ON i.location_id = l.id AND i.domain_id = l.domain_id AND l.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
87
|
-
LEFT JOIN oi ON oi.product_id = i.product_id
|
|
54
|
+
INNER JOIN locations l ON i.location_id = l.id AND i.domain_id = l.domain_id AND l.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
88
55
|
GROUP by
|
|
89
56
|
i.domain_id,
|
|
90
57
|
i.bizplace_id,
|
|
@@ -101,14 +68,13 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
101
68
|
pb.id
|
|
102
69
|
)
|
|
103
70
|
AS src
|
|
104
|
-
inner join domains d on d.id = src."
|
|
105
|
-
inner join bizplaces b on b.id = src."
|
|
106
|
-
where src."
|
|
71
|
+
inner join domains d on d.id = src."domain_id"
|
|
72
|
+
inner join bizplaces b on b.id = src."bizplace_id"
|
|
73
|
+
where src."remain_qty" >= 0
|
|
107
74
|
and src."qty" > 0
|
|
108
|
-
order by src."
|
|
75
|
+
order by src."domain_id"
|
|
109
76
|
`
|
|
110
77
|
})
|
|
111
|
-
|
|
112
78
|
export class WarehouseBizplaceOnhandInventory {
|
|
113
79
|
@ViewColumn()
|
|
114
80
|
domainName: string
|
|
@@ -32,6 +32,7 @@ export const batchPickingWorksheetResolver = {
|
|
|
32
32
|
.addSelect('"PROD".name', 'productName')
|
|
33
33
|
.addSelect('"PROD".sku', 'productSku')
|
|
34
34
|
.addSelect('"PROD".description', 'productDescription')
|
|
35
|
+
.addSelect('"PROD_DET".id', 'productDetailId')
|
|
35
36
|
.addSelect('"INV".qty', 'qty')
|
|
36
37
|
.addSelect('"INV".packing_type', 'packingType')
|
|
37
38
|
.addSelect('"INV".packing_size', 'packingSize')
|
|
@@ -47,6 +48,7 @@ export const batchPickingWorksheetResolver = {
|
|
|
47
48
|
.leftJoin('WSD.targetInventory', 'T_INV')
|
|
48
49
|
.leftJoin('T_INV.inventory', 'INV')
|
|
49
50
|
.leftJoin('T_INV.product', 'PROD')
|
|
51
|
+
.leftJoin('T_INV.productDetail', 'PROD_DET')
|
|
50
52
|
.leftJoin('T_INV.binLocation', 'BIN_LOC')
|
|
51
53
|
.leftJoin('INV.location', 'LOC')
|
|
52
54
|
.where('"WSD"."worksheet_id" = :worksheetId', { worksheetId: worksheet.id })
|
|
@@ -64,6 +66,7 @@ export const batchPickingWorksheetResolver = {
|
|
|
64
66
|
.addGroupBy('"PROD".name')
|
|
65
67
|
.addGroupBy('"PROD".sku')
|
|
66
68
|
.addGroupBy('"PROD".description')
|
|
69
|
+
.addGroupBy('"PROD_DET".id')
|
|
67
70
|
.addGroupBy('"T_INV".batch_id')
|
|
68
71
|
.addGroupBy('"T_INV".packing_type')
|
|
69
72
|
.addGroupBy('BIN_LOC.name')
|
|
@@ -126,6 +129,9 @@ export const batchPickingWorksheetResolver = {
|
|
|
126
129
|
name: item?.productName,
|
|
127
130
|
description: item?.productDescription,
|
|
128
131
|
sku: item?.productSku
|
|
132
|
+
},
|
|
133
|
+
productDetail: {
|
|
134
|
+
id: item?.productDetailId
|
|
129
135
|
}
|
|
130
136
|
}
|
|
131
137
|
}
|
|
@@ -11,10 +11,9 @@ import {
|
|
|
11
11
|
ReleaseGood
|
|
12
12
|
} from '@things-factory/sales-base'
|
|
13
13
|
import { Domain } from '@things-factory/shell'
|
|
14
|
-
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location } from '@things-factory/warehouse-base'
|
|
14
|
+
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location, generateInventoryHistory } from '@things-factory/warehouse-base'
|
|
15
15
|
|
|
16
16
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
17
|
-
import { generateInventoryHistory } from '../../../utils'
|
|
18
17
|
|
|
19
18
|
export const confirmCancellationReleaseOrder = {
|
|
20
19
|
async confirmCancellationReleaseOrder(_: any, { name }, context: any) {
|
|
@@ -4,12 +4,12 @@ import { User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
5
5
|
import { InventoryCheck, ORDER_INVENTORY_STATUS, ORDER_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
6
6
|
import { Domain } from '@things-factory/shell'
|
|
7
|
-
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location } from '@things-factory/warehouse-base'
|
|
7
|
+
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location, generateInventoryHistory } from '@things-factory/warehouse-base'
|
|
8
8
|
|
|
9
9
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
10
10
|
import { SellercraftController } from '../../../controllers'
|
|
11
11
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
12
|
-
import {
|
|
12
|
+
import { switchLocationStatus } from '../../../utils'
|
|
13
13
|
|
|
14
14
|
export const cycleCountAdjustmentResolver = {
|
|
15
15
|
async cycleCountAdjustment(_: any, { cycleCountNo }, context: any) {
|
|
@@ -40,6 +40,7 @@ export const inventoriesByPalletResolver = {
|
|
|
40
40
|
qb.leftJoinAndSelect('iv.domain', 'domain')
|
|
41
41
|
.leftJoinAndSelect('iv.bizplace', 'bizplace')
|
|
42
42
|
.leftJoinAndSelect('iv.product', 'product')
|
|
43
|
+
.leftJoinAndSelect('iv.productDetail', 'productDetail')
|
|
43
44
|
.leftJoinAndSelect('iv.warehouse', 'warehouse')
|
|
44
45
|
.leftJoinAndSelect('iv.location', 'location')
|
|
45
46
|
.leftJoinAndSelect('iv.creator', 'creator')
|
|
@@ -134,7 +135,8 @@ export const inventoriesByPalletResolver = {
|
|
|
134
135
|
productName: item.product.name,
|
|
135
136
|
productSKU: item.product.sku,
|
|
136
137
|
productBrand: item.product.brand,
|
|
137
|
-
productId: item.product.id
|
|
138
|
+
productId: item.product.id,
|
|
139
|
+
productDetailId: item.productDetail.id
|
|
138
140
|
}
|
|
139
141
|
})
|
|
140
142
|
)
|
|
@@ -11,7 +11,7 @@ import { Worksheet } from '../../../../entities'
|
|
|
11
11
|
export const scanProductPackingResolver = {
|
|
12
12
|
async scanProductPacking(_: any, { worksheetDetailName, productBarcode, serialNumber }, context: any) {
|
|
13
13
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
14
|
-
await scanProductPacking(tx, domain, user, worksheetDetailName, productBarcode, serialNumber)
|
|
14
|
+
return await scanProductPacking(tx, domain, user, worksheetDetailName, productBarcode, serialNumber)
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -24,35 +24,16 @@ export async function scanProductPacking(
|
|
|
24
24
|
serialNumber?: string
|
|
25
25
|
) {
|
|
26
26
|
try {
|
|
27
|
+
console.time('execution time to scan for packing')
|
|
27
28
|
const worksheetController: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
28
|
-
const
|
|
29
|
+
const inventoryItems = await worksheetController.scanProductPacking(
|
|
29
30
|
worksheetDetailName,
|
|
30
31
|
productBarcode,
|
|
31
32
|
serialNumber
|
|
32
33
|
)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const orderSource: string = releaseGood.source
|
|
38
|
-
switch (orderSource) {
|
|
39
|
-
case ApplicationType.SELLERCRAFT:
|
|
40
|
-
if (!releaseGood?.airwayBill) {
|
|
41
|
-
const sellercraft: Sellercraft = await tx
|
|
42
|
-
.getRepository(Sellercraft)
|
|
43
|
-
.findOne({ domain: worksheet.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
44
|
-
|
|
45
|
-
if (sellercraft) {
|
|
46
|
-
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
47
|
-
sellercraftCtrl.fetchOrderDocument(sellercraft, releaseGood)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
break
|
|
52
|
-
|
|
53
|
-
default:
|
|
54
|
-
break
|
|
55
|
-
}
|
|
35
|
+
console.timeEnd('execution time to scan for packing')
|
|
36
|
+
return inventoryItems
|
|
56
37
|
|
|
57
38
|
// if (releaseGood.type === 'b2c' && !releaseGood?.airwayBill) {
|
|
58
39
|
// const sellercraft: Sellercraft = await tx
|
|
@@ -14,10 +14,9 @@ import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
|
14
14
|
import { Domain } from '@things-factory/shell'
|
|
15
15
|
import { Inventory, Location } from '@things-factory/warehouse-base'
|
|
16
16
|
|
|
17
|
-
import { WORKSHEET_TYPE } from '../../../constants'
|
|
17
|
+
import { WORKSHEET_TYPE, WORKSHEET_STATUS } from '../../../constants'
|
|
18
18
|
import { PackingWorksheetController, SellercraftController } from '../../../controllers'
|
|
19
19
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
20
|
-
import { fetchExecutingWorksheet } from '../../../utils'
|
|
21
20
|
|
|
22
21
|
export const packingWorksheetResolver = {
|
|
23
22
|
async packingWorksheet(_: any, { releaseGoodNo }, context: any) {
|
|
@@ -86,28 +85,28 @@ export const packingWorksheetResolver = {
|
|
|
86
85
|
|
|
87
86
|
if (!releaseGood) throw new Error(`Release good do not exist.`)
|
|
88
87
|
|
|
89
|
-
const worksheet: Worksheet = await
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
if (worksheet.status ===
|
|
88
|
+
const worksheet: Worksheet = await tx
|
|
89
|
+
.getRepository(Worksheet)
|
|
90
|
+
.createQueryBuilder('w')
|
|
91
|
+
.innerJoinAndSelect('w.bizplace', 'b')
|
|
92
|
+
.innerJoinAndSelect('b.domain', 'd')
|
|
93
|
+
.innerJoinAndSelect('w.releaseGood', 'rg')
|
|
94
|
+
.innerJoinAndSelect('w.worksheetDetails', 'wd')
|
|
95
|
+
.innerJoinAndSelect('wd.targetInventory', 'oi')
|
|
96
|
+
.innerJoinAndSelect('oi.inventory', 'i')
|
|
97
|
+
.leftJoinAndSelect('oi.binLocation', 'l')
|
|
98
|
+
.innerJoinAndSelect('i.location', 'l2')
|
|
99
|
+
.innerJoinAndSelect('i.product', 'p')
|
|
100
|
+
.innerJoinAndSelect('p.productDetails', 'pd')
|
|
101
|
+
.where('rg.id = :id', { id: releaseGood.id })
|
|
102
|
+
.andWhere('w.type = :type', { type: WORKSHEET_TYPE.PACKING })
|
|
103
|
+
.getOne()
|
|
104
|
+
|
|
105
|
+
if (!worksheet) throw new Error('Worksheet does not exist')
|
|
106
|
+
|
|
107
|
+
if (worksheet.status === WORKSHEET_STATUS.DONE) {
|
|
108
|
+
throw new Error(`Worksheet is completed already`)
|
|
109
|
+
} else if (worksheet.status === WORKSHEET_STATUS.DEACTIVATED) {
|
|
111
110
|
const packingWSCtrl: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
112
111
|
|
|
113
112
|
const directActivatePackingWorksheet: Setting = await tx.getRepository(Setting).findOne({
|
|
@@ -202,54 +201,6 @@ export const packingWorksheetResolver = {
|
|
|
202
201
|
break
|
|
203
202
|
}
|
|
204
203
|
|
|
205
|
-
// if (releaseGood.type === 'b2c') {
|
|
206
|
-
// const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
207
|
-
// domain: worksheet.bizplace.domain,
|
|
208
|
-
// status: SellercraftStatus.ACTIVE
|
|
209
|
-
// })
|
|
210
|
-
|
|
211
|
-
// if (sellercraft) {
|
|
212
|
-
// // asynchronously get document from sellercraft
|
|
213
|
-
// getSellercraftDocument(sellercraft, releaseGood, domain, user)
|
|
214
|
-
// } else {
|
|
215
|
-
// marketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
216
|
-
// where: { orderNo: releaseGood.refNo },
|
|
217
|
-
// relations: [
|
|
218
|
-
// 'domain',
|
|
219
|
-
// 'marketplaceStore',
|
|
220
|
-
// 'marketplaceOrderItems',
|
|
221
|
-
// 'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
222
|
-
// 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
|
|
223
|
-
// ]
|
|
224
|
-
// })
|
|
225
|
-
|
|
226
|
-
// if (!marketplaceOrder) {
|
|
227
|
-
// throw new Error('Failed to retrieve ecommerce information, kindly contact our support team for this issue.')
|
|
228
|
-
// }
|
|
229
|
-
|
|
230
|
-
// let marketplaceOrderShipping: MarketplaceOrderShipping
|
|
231
|
-
// if (marketplaceOrder.isSplitted) {
|
|
232
|
-
// marketplaceOrderShipping = await tx.getRepository(MarketplaceOrderShipping).findOne({
|
|
233
|
-
// where: { subOrderNoRef: worksheet.releaseGood.refNo2 }
|
|
234
|
-
// })
|
|
235
|
-
// } else {
|
|
236
|
-
// marketplaceOrderShipping = await tx.getRepository(MarketplaceOrderShipping).findOne({
|
|
237
|
-
// where: { orderNoRef: worksheet.releaseGood.refNo }
|
|
238
|
-
// })
|
|
239
|
-
// }
|
|
240
|
-
|
|
241
|
-
// trackingNo = marketplaceOrderShipping.ownTrackingNo
|
|
242
|
-
// ? marketplaceOrderShipping.ownTrackingNo
|
|
243
|
-
// : marketplaceOrderShipping.trackingNo
|
|
244
|
-
// shippingProvider = marketplaceOrderShipping.ownTransporter
|
|
245
|
-
// ? marketplaceOrderShipping.ownTransporter
|
|
246
|
-
// : marketplaceOrderShipping.transporter
|
|
247
|
-
|
|
248
|
-
// marketplaceStore = marketplaceOrder?.marketplaceStore
|
|
249
|
-
// marketplaceStatus = marketplaceOrder?.status
|
|
250
|
-
// }
|
|
251
|
-
// }
|
|
252
|
-
|
|
253
204
|
return {
|
|
254
205
|
worksheetInfo: {
|
|
255
206
|
releaseGood,
|
|
@@ -269,29 +220,41 @@ export const packingWorksheetResolver = {
|
|
|
269
220
|
marketplaceStatus: marketplaceStatus ? marketplaceStatus : '',
|
|
270
221
|
marketplaceOrder: marketplaceOrder ? marketplaceOrder : ''
|
|
271
222
|
},
|
|
272
|
-
worksheetDetailInfos: worksheet.worksheetDetails
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
223
|
+
worksheetDetailInfos: worksheet.worksheetDetails
|
|
224
|
+
.map((packingWSD: WorksheetDetail) => {
|
|
225
|
+
const targetInventory: OrderInventory = packingWSD.targetInventory
|
|
226
|
+
const inventory: Inventory = targetInventory.inventory
|
|
227
|
+
return {
|
|
228
|
+
id: packingWSD.id,
|
|
229
|
+
name: packingWSD.name,
|
|
230
|
+
palletId: inventory.palletId,
|
|
231
|
+
cartonId: inventory.cartonId,
|
|
232
|
+
batchId: inventory.batchId,
|
|
233
|
+
batchIdRef: inventory.batchIdRef,
|
|
234
|
+
product: inventory.product,
|
|
235
|
+
sku: inventory.product.sku,
|
|
236
|
+
releaseQty: targetInventory.releaseQty,
|
|
237
|
+
packedQty: targetInventory.packedQty,
|
|
238
|
+
status: packingWSD.status,
|
|
239
|
+
description: packingWSD.description,
|
|
240
|
+
targetName: targetInventory.name,
|
|
241
|
+
packingType: inventory.packingType,
|
|
242
|
+
packingSize: inventory.packingSize,
|
|
243
|
+
binLocation: targetInventory?.binLocation,
|
|
244
|
+
location: inventory.location,
|
|
245
|
+
relatedOrderInv: targetInventory
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
.sort((a, b) => {
|
|
249
|
+
if (a?.binLocation && b?.binLocation) {
|
|
250
|
+
if (a.binLocation.name < b.binLocation.name) return -1
|
|
251
|
+
if (a.binLocation.name > b.binLocation.name) return 1
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (a.sku < b.sku) return -1
|
|
255
|
+
if (a.sku > b.sku) return 1
|
|
256
|
+
return 0
|
|
257
|
+
})
|
|
295
258
|
}
|
|
296
259
|
} catch (error) {
|
|
297
260
|
console.error(error)
|
|
@@ -76,6 +76,7 @@ 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')
|
|
79
80
|
.leftJoinAndSelect('INV.location', 'LOC')
|
|
80
81
|
|
|
81
82
|
if (locationSortingRules?.length > 0) {
|
|
@@ -114,8 +115,8 @@ export async function pickingWorksheet(
|
|
|
114
115
|
const inventoryChangesCount: number = await tx.getRepository(InventoryChange).count({
|
|
115
116
|
where: {
|
|
116
117
|
inventory: inventory.id,
|
|
117
|
-
status:
|
|
118
|
-
transactionType:
|
|
118
|
+
status: 'PENDING',
|
|
119
|
+
transactionType: 'MISSING'
|
|
119
120
|
},
|
|
120
121
|
relations: ['inventory', 'product']
|
|
121
122
|
})
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
2
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
+
import { ORDER_PRODUCT_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
3
6
|
import { Domain } from '@things-factory/shell'
|
|
4
|
-
import { OrderInventory, ORDER_PRODUCT_STATUS } from '@things-factory/sales-base'
|
|
5
7
|
import {
|
|
6
8
|
Inventory,
|
|
7
|
-
InventoryHistory,
|
|
8
|
-
InventoryNoGenerator,
|
|
9
9
|
INVENTORY_STATUS,
|
|
10
|
-
INVENTORY_TRANSACTION_TYPE
|
|
10
|
+
INVENTORY_TRANSACTION_TYPE,
|
|
11
|
+
InventoryHistory,
|
|
12
|
+
InventoryNoGenerator
|
|
11
13
|
} from '@things-factory/warehouse-base'
|
|
12
|
-
|
|
14
|
+
|
|
13
15
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
14
16
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
15
17
|
|
|
16
18
|
export const transfer = {
|
|
17
19
|
async transfer(_: any, { palletId, toPalletId, qty }, context: any) {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
domain,
|
|
21
|
-
bizplace,
|
|
22
|
-
user
|
|
23
|
-
}: { tx: EntityManager; domain: Domain; bizplace: Bizplace; user: User } = context.state
|
|
20
|
+
const { tx, domain, bizplace, user }: { tx: EntityManager; domain: Domain; bizplace: Bizplace; user: User } =
|
|
21
|
+
context.state
|
|
24
22
|
|
|
25
23
|
// 1. get to inventory
|
|
26
24
|
let toInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
27
25
|
where: { domain: domain, palletId: toPalletId },
|
|
28
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
26
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
29
27
|
})
|
|
30
28
|
if (!toInventory) throw new Error(`to pallet doesn't exists`)
|
|
31
29
|
|
|
32
30
|
// 2. get from inventory
|
|
33
31
|
let fromInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
34
32
|
where: { domain: domain, palletId },
|
|
35
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
33
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
36
34
|
})
|
|
37
35
|
if (!fromInventory) throw new Error(`from pallet doesn't exists`)
|
|
38
36
|
if (toInventory.batchId !== fromInventory.batchId) throw new Error(`Can't transfer to different batch`)
|
|
@@ -74,6 +72,7 @@ export const transfer = {
|
|
|
74
72
|
domain: domain,
|
|
75
73
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
76
74
|
product: toInventory.product,
|
|
75
|
+
productDetail: toInventory.productDetail,
|
|
77
76
|
warehouse: toInventory.warehouse,
|
|
78
77
|
location: toInventory.location,
|
|
79
78
|
seq: toInventory.lastSeq,
|
|
@@ -97,7 +96,7 @@ export const transfer = {
|
|
|
97
96
|
|
|
98
97
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
99
98
|
where: { id: fromInventory.id },
|
|
100
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
99
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
101
100
|
})
|
|
102
101
|
|
|
103
102
|
// - add inventory history
|
|
@@ -105,6 +104,7 @@ export const transfer = {
|
|
|
105
104
|
...fromInventory,
|
|
106
105
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
107
106
|
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', 'warehouse', 'location']
|
|
134
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
135
135
|
})
|
|
136
136
|
// - add inventory history
|
|
137
137
|
delete toInventory.id
|
|
@@ -140,6 +140,7 @@ export const transfer = {
|
|
|
140
140
|
domain,
|
|
141
141
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
142
142
|
product: toInventory.product,
|
|
143
|
+
productDetail: toInventory.productDetail,
|
|
143
144
|
warehouse: toInventory.warehouse,
|
|
144
145
|
location: toInventory.location,
|
|
145
146
|
seq: toInventory.lastSeq,
|
|
@@ -157,7 +158,7 @@ export const transfer = {
|
|
|
157
158
|
|
|
158
159
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
159
160
|
where: { id: fromInventory.id },
|
|
160
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
161
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
161
162
|
})
|
|
162
163
|
|
|
163
164
|
// - add inventory history
|
|
@@ -165,6 +166,7 @@ export const transfer = {
|
|
|
165
166
|
...fromInventory,
|
|
166
167
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
167
168
|
product: fromInventory.product,
|
|
169
|
+
productDetail: fromInventory.productDetail,
|
|
168
170
|
warehouse: fromInventory.warehouse,
|
|
169
171
|
location: fromInventory.location,
|
|
170
172
|
seq: fromInventory.lastSeq,
|
|
@@ -44,7 +44,7 @@ export const unloadedInventories = {
|
|
|
44
44
|
orderProductId: In(foundWorksheetDetails.map(wsd => wsd.targetProduct.id)),
|
|
45
45
|
status: In([INVENTORY_STATUS.UNLOADED, INVENTORY_STATUS.CHECKED])
|
|
46
46
|
},
|
|
47
|
-
relations: ['reusablePallet', 'product', 'bizplace']
|
|
47
|
+
relations: ['reusablePallet', 'product', 'bizplace', 'inventoryItems']
|
|
48
48
|
})
|
|
49
49
|
const items = foundInv.map((inv: Inventory) => {
|
|
50
50
|
const expirationDate: Date = inv.expirationDate ? new Date(inv.expirationDate) : null
|
|
@@ -19,12 +19,13 @@ import {
|
|
|
19
19
|
InventoryNoGenerator,
|
|
20
20
|
Location,
|
|
21
21
|
Pallet,
|
|
22
|
-
Warehouse
|
|
22
|
+
Warehouse,
|
|
23
|
+
generateInventoryHistory
|
|
23
24
|
} from '@things-factory/warehouse-base'
|
|
24
25
|
|
|
25
26
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../../constants'
|
|
26
27
|
import { Worksheet, WorksheetDetail } from '../../../../entities'
|
|
27
|
-
import {
|
|
28
|
+
import { WorksheetNoGenerator } from '../../../../utils'
|
|
28
29
|
import {
|
|
29
30
|
OperationGuideInterface,
|
|
30
31
|
PackingUnits,
|
|
@@ -242,7 +242,7 @@ export const worksheetsResolver = {
|
|
|
242
242
|
params.filters.findIndex(item => item.name == 'executionDate'),
|
|
243
243
|
1
|
|
244
244
|
)
|
|
245
|
-
arrFilters.push({ ...
|
|
245
|
+
arrFilters.push({ ...executionDateParam, name: 'executionDate' })
|
|
246
246
|
}
|
|
247
247
|
const foundInventoryCheck: InventoryCheck[] = await getRepository(InventoryCheck).find({
|
|
248
248
|
...convertListParams({ filters: arrFilters })
|
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, packingType, packingSize, orderProductId, worksheetDetails },
|
|
22
|
+
{ worksheetNo, batchId, productId, productDetailId, 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,6 +30,7 @@ export const regenerateReleaseGoodWorksheetDetailsResolver = {
|
|
|
30
30
|
worksheetNo,
|
|
31
31
|
batchId,
|
|
32
32
|
productId,
|
|
33
|
+
productDetailId,
|
|
33
34
|
packingType,
|
|
34
35
|
packingSize,
|
|
35
36
|
orderProductId,
|
|
@@ -45,6 +46,7 @@ export async function regenerateReleaseGoodWorksheetDetails(
|
|
|
45
46
|
worksheetNo: string,
|
|
46
47
|
batchId: string,
|
|
47
48
|
productId: string,
|
|
49
|
+
productDetailId: string,
|
|
48
50
|
packingType: string,
|
|
49
51
|
packingSize: number,
|
|
50
52
|
orderProductId: string,
|
|
@@ -115,6 +117,7 @@ export async function regenerateReleaseGoodWorksheetDetails(
|
|
|
115
117
|
batchIdRef: inventory.batchIdRef,
|
|
116
118
|
status: ORDER_INVENTORY_STATUS.READY_TO_PICK,
|
|
117
119
|
product: await tx.getRepository(Product).findOne(productId),
|
|
120
|
+
productDetail: productDetailId,
|
|
118
121
|
packingType,
|
|
119
122
|
packingSize,
|
|
120
123
|
orderProduct: targetProduct,
|
|
@@ -363,7 +363,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
363
363
|
worksheetDetailName: String!
|
|
364
364
|
productBarcode: String!
|
|
365
365
|
serialNumber: String
|
|
366
|
-
):
|
|
366
|
+
): ExecutingWorksheet @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
367
367
|
|
|
368
368
|
batchPicking (
|
|
369
369
|
taskNo: String!
|