@things-factory/worksheet-base 4.3.113-alpha.0 → 4.3.114
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 +73 -58
- 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 +24 -33
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +48 -78
- 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/render-orientage-do.js +1 -1
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/render-orientage-grn.js +1 -1
- package/dist-server/controllers/render-orientage-grn.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 +9 -7
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +2 -3
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +62 -29
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.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 +39 -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/cycle-count-worksheet.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/find-sorting-release-orders-by-task-no.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/packing-worksheet.js +1 -4
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +3 -3
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +51 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-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/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-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/index.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 +18 -17
- package/server/controllers/inbound/unloading-worksheet-controller.ts +86 -72
- 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 +36 -41
- package/server/controllers/outbound/picking-worksheet-controller.ts +66 -98
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/render-orientage-do.ts +1 -1
- package/server/controllers/render-orientage-grn.ts +12 -12
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +12 -15
- package/server/entities/index.ts +2 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +63 -29
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +0 -6
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +43 -1
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/cycle-count-worksheet.ts +1 -0
- package/server/graphql/resolvers/worksheet/find-sorting-release-orders-by-task-no.ts +62 -62
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +1 -3
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +2 -4
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +3 -3
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +57 -1
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +2 -3
- package/server/graphql/resolvers/worksheet/transfer.ts +16 -18
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +1 -1
- 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/index.ts +2 -2
- package/server/graphql/types/worksheet-detail/index.ts +0 -1
- package/server/utils/inventory-util.ts +126 -1
|
@@ -22,8 +22,7 @@ import {
|
|
|
22
22
|
InventoryNoGenerator,
|
|
23
23
|
Location,
|
|
24
24
|
LOCATION_TYPE,
|
|
25
|
-
Warehouse
|
|
26
|
-
generateInventoryHistory
|
|
25
|
+
Warehouse
|
|
27
26
|
} from '@things-factory/warehouse-base'
|
|
28
27
|
|
|
29
28
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
@@ -37,6 +36,7 @@ import {
|
|
|
37
36
|
RefOrderType
|
|
38
37
|
} from '../../graphql/resolvers/worksheet/vas-transactions'
|
|
39
38
|
import { PackingUnits } from '../../graphql/resolvers/worksheet/vas-transactions/interfaces/repackaging'
|
|
39
|
+
import { generateInventoryHistory } from '../../utils'
|
|
40
40
|
import { ReferenceOrderType, WorksheetController } from '../worksheet-controller'
|
|
41
41
|
|
|
42
42
|
type CompleteTransactionType = (trxMgr: EntityManager, orderVas: OrderVas, user: User) => Promise<void>
|
|
@@ -19,17 +19,11 @@ import {
|
|
|
19
19
|
VasOrder
|
|
20
20
|
} from '@things-factory/sales-base'
|
|
21
21
|
import { Domain } from '@things-factory/shell'
|
|
22
|
-
import {
|
|
23
|
-
Inventory,
|
|
24
|
-
INVENTORY_STATUS,
|
|
25
|
-
InventoryItem,
|
|
26
|
-
Pallet,
|
|
27
|
-
generateInventoryHistory
|
|
28
|
-
} from '@things-factory/warehouse-base'
|
|
22
|
+
import { Inventory, INVENTORY_STATUS, InventoryItem, Pallet } from '@things-factory/warehouse-base'
|
|
29
23
|
|
|
30
24
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
|
|
31
25
|
import { Worksheet, WorksheetDetail } from '../entities'
|
|
32
|
-
import { WorksheetNoGenerator } from '../utils'
|
|
26
|
+
import { generateInventoryHistory, WorksheetNoGenerator } from '../utils'
|
|
33
27
|
|
|
34
28
|
export type ReferenceOrderType = ArrivalNotice | ReleaseGood | VasOrder | InventoryCheck | DeliveryOrder | ReturnOrder
|
|
35
29
|
export type OrderTargetTypes = OrderProduct | OrderInventory | OrderVas
|
|
@@ -1012,9 +1006,11 @@ export class WorksheetController {
|
|
|
1012
1006
|
async getChildQty(
|
|
1013
1007
|
productDetails: ProductDetail[],
|
|
1014
1008
|
productBarcode: string,
|
|
1015
|
-
orderProductDetail: ProductDetail
|
|
1016
|
-
scannedProductDetail: ProductDetail
|
|
1009
|
+
orderProductDetail: ProductDetail
|
|
1017
1010
|
): Promise<number> {
|
|
1011
|
+
const scannedProductDetail: ProductDetail = productDetails.find(
|
|
1012
|
+
(productDetail: ProductDetail) => productDetail.gtin === productBarcode
|
|
1013
|
+
)
|
|
1018
1014
|
let hasChildRelation: boolean = Boolean(scannedProductDetail?.childProductDetail)
|
|
1019
1015
|
let hasMatchingChild: boolean
|
|
1020
1016
|
let childQty: number
|
|
@@ -1063,11 +1059,12 @@ export class WorksheetController {
|
|
|
1063
1059
|
let results = await this.trxMgr.query(
|
|
1064
1060
|
`
|
|
1065
1061
|
WITH RECURSIVE cte as (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1062
|
+
select * from (
|
|
1063
|
+
select pd2.product_id as "productId", pd2.id, pd2.packing_size as "packingSize",
|
|
1064
|
+
pd2.packing_type as "packingType", pd2.uom as "uom", (pd2.uom_value * $2::float) as "uomValue", $2::float as "qty", pd2.gtin
|
|
1065
|
+
from product_details pd
|
|
1066
|
+
inner join product_details pd2 on pd.product_id = pd2.product_id and pd.packing_type = pd2.packing_type and pd.packing_size = pd2.packing_size and pd.uom = pd2.uom
|
|
1067
|
+
where pd.id = $1
|
|
1071
1068
|
) as dt
|
|
1072
1069
|
union all
|
|
1073
1070
|
select pd.product_id as "productId", pd.id, pd.packing_size as "packingSize",
|
package/server/entities/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { WarehouseBizplaceOnhandInventory } from './warehouse-bizplace-onhand-inventory'
|
|
2
1
|
import { Worksheet } from './worksheet'
|
|
3
2
|
import { WorksheetDetail } from './worksheet-detail'
|
|
4
3
|
import { WorksheetMovement } from './worksheet-movement'
|
|
4
|
+
import { WarehouseBizplaceOnhandInventory } from './warehouse-bizplace-onhand-inventory'
|
|
5
5
|
|
|
6
6
|
export const entities = [Worksheet, WorksheetDetail, WorksheetMovement, WarehouseBizplaceOnhandInventory]
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { Worksheet, WorksheetDetail, WorksheetMovement }
|
|
@@ -2,23 +2,55 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
2
2
|
|
|
3
3
|
@ViewEntity({
|
|
4
4
|
expression: `
|
|
5
|
-
select d.name as "
|
|
5
|
+
select d.name as "domainName", b.name as "bizplaceName", src.* from (
|
|
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
|
+
)
|
|
6
37
|
-- SINGLE ITEM INVENTORY QUERY
|
|
7
38
|
select
|
|
8
|
-
i.domain_id as "
|
|
9
|
-
i.bizplace_id as "
|
|
10
|
-
i.packing_type as "
|
|
11
|
-
i.packing_size as "
|
|
39
|
+
i.domain_id as "domainId",
|
|
40
|
+
i.bizplace_id as "bizplaceId",
|
|
41
|
+
i.packing_type as "packingType",
|
|
42
|
+
i.packing_size as "packingSize",
|
|
12
43
|
i.uom,
|
|
13
|
-
i.product_id as "
|
|
14
|
-
null as "
|
|
15
|
-
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0))) AS "
|
|
16
|
-
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0))) AS "
|
|
44
|
+
i.product_id as "productId",
|
|
45
|
+
null as "productBundleId",
|
|
46
|
+
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) AS "remainQty",
|
|
47
|
+
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)), 0) AS "remainUomValue",
|
|
17
48
|
COALESCE(sum(COALESCE(i.qty, 0::double precision))) AS "qty",
|
|
18
|
-
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "
|
|
19
|
-
'SINGLE' AS "
|
|
49
|
+
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "uomValue",
|
|
50
|
+
'SINGLE' AS "groupType"
|
|
20
51
|
FROM inventories i
|
|
21
52
|
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
|
|
22
54
|
WHERE i.status = 'STORED'
|
|
23
55
|
GROUP by
|
|
24
56
|
i.domain_id,
|
|
@@ -30,28 +62,29 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
30
62
|
union all
|
|
31
63
|
-- BUNDLE ITEM INVENTORY QUERY
|
|
32
64
|
SELECT
|
|
33
|
-
pbs.domain_id as "
|
|
34
|
-
pbs.bizplace_id as "
|
|
35
|
-
pb.packing_type as "
|
|
36
|
-
pb.packing_size as "
|
|
65
|
+
pbs.domain_id as "domainId",
|
|
66
|
+
pbs.bizplace_id as "bizplaceId",
|
|
67
|
+
pb.packing_type as "packingType",
|
|
68
|
+
pb.packing_size as "packingSize",
|
|
37
69
|
'UNIT' AS "uom",
|
|
38
|
-
null as "
|
|
39
|
-
pb.id AS "
|
|
40
|
-
COALESCE(MIN(FLOOR(pbs."
|
|
41
|
-
COALESCE(MIN(FLOOR(pbs."
|
|
70
|
+
null as "productId",
|
|
71
|
+
pb.id AS "productBundleId",
|
|
72
|
+
COALESCE(MIN(FLOOR(pbs."availableQty")),0) AS "remainQty",
|
|
73
|
+
COALESCE(MIN(FLOOR(pbs."availableUomValue")),0) AS "remainUomValue",
|
|
42
74
|
COALESCE(MIN(FLOOR(pbs."qty")), 0::double precision) AS "qty",
|
|
43
|
-
COALESCE(MIN(FLOOR(pbs."
|
|
44
|
-
'BUNDLE' AS "
|
|
75
|
+
COALESCE(MIN(FLOOR(pbs."uomValue")), 0::double precision) AS "uomValue",
|
|
76
|
+
'BUNDLE' AS "groupType"
|
|
45
77
|
FROM product_bundles pb
|
|
46
78
|
INNER JOIN (
|
|
47
79
|
SELECT i.domain_id, i.bizplace_id, pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
48
|
-
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0))) / min(pbs.bundle_qty) AS "
|
|
49
|
-
(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0))) / min(pbs.bundle_qty) AS "
|
|
80
|
+
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
81
|
+
(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue",
|
|
50
82
|
(sum(COALESCE(i.qty, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "qty",
|
|
51
|
-
(sum(COALESCE(i.uom_value, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "
|
|
83
|
+
(sum(COALESCE(i.uom_value, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "uomValue"
|
|
52
84
|
FROM product_bundle_settings pbs
|
|
53
85
|
LEFT JOIN inventories i ON i.product_id = pbs.product_id AND i.status = 'STORED'
|
|
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')
|
|
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
|
|
55
88
|
GROUP by
|
|
56
89
|
i.domain_id,
|
|
57
90
|
i.bizplace_id,
|
|
@@ -68,13 +101,14 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
68
101
|
pb.id
|
|
69
102
|
)
|
|
70
103
|
AS src
|
|
71
|
-
inner join domains d on d.id = src."
|
|
72
|
-
inner join bizplaces b on b.id = src."
|
|
73
|
-
where src."
|
|
104
|
+
inner join domains d on d.id = src."domainId"
|
|
105
|
+
inner join bizplaces b on b.id = src."bizplaceId"
|
|
106
|
+
where src."remainQty" >= 0
|
|
74
107
|
and src."qty" > 0
|
|
75
|
-
order by src."
|
|
108
|
+
order by src."domainId"
|
|
76
109
|
`
|
|
77
110
|
})
|
|
111
|
+
|
|
78
112
|
export class WarehouseBizplaceOnhandInventory {
|
|
79
113
|
@ViewColumn()
|
|
80
114
|
domainName: string
|
|
@@ -32,7 +32,6 @@ 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')
|
|
36
35
|
.addSelect('"INV".qty', 'qty')
|
|
37
36
|
.addSelect('"INV".packing_type', 'packingType')
|
|
38
37
|
.addSelect('"INV".packing_size', 'packingSize')
|
|
@@ -48,7 +47,6 @@ export const batchPickingWorksheetResolver = {
|
|
|
48
47
|
.leftJoin('WSD.targetInventory', 'T_INV')
|
|
49
48
|
.leftJoin('T_INV.inventory', 'INV')
|
|
50
49
|
.leftJoin('T_INV.product', 'PROD')
|
|
51
|
-
.leftJoin('T_INV.productDetail', 'PROD_DET')
|
|
52
50
|
.leftJoin('T_INV.binLocation', 'BIN_LOC')
|
|
53
51
|
.leftJoin('INV.location', 'LOC')
|
|
54
52
|
.where('"WSD"."worksheet_id" = :worksheetId', { worksheetId: worksheet.id })
|
|
@@ -66,7 +64,6 @@ export const batchPickingWorksheetResolver = {
|
|
|
66
64
|
.addGroupBy('"PROD".name')
|
|
67
65
|
.addGroupBy('"PROD".sku')
|
|
68
66
|
.addGroupBy('"PROD".description')
|
|
69
|
-
.addGroupBy('"PROD_DET".id')
|
|
70
67
|
.addGroupBy('"T_INV".batch_id')
|
|
71
68
|
.addGroupBy('"T_INV".packing_type')
|
|
72
69
|
.addGroupBy('BIN_LOC.name')
|
|
@@ -129,9 +126,6 @@ export const batchPickingWorksheetResolver = {
|
|
|
129
126
|
name: item?.productName,
|
|
130
127
|
description: item?.productDescription,
|
|
131
128
|
sku: item?.productSku
|
|
132
|
-
},
|
|
133
|
-
productDetail: {
|
|
134
|
-
id: item?.productDetailId
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
131
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EntityManager, In } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
+
// import { logger } from '@things-factory/env'
|
|
5
|
+
// import { Account, AccountingAPI } from '@things-factory/integration-accounting'
|
|
4
6
|
import {
|
|
5
7
|
DeliveryOrder,
|
|
6
8
|
ORDER_INVENTORY_STATUS,
|
|
@@ -11,9 +13,10 @@ import {
|
|
|
11
13
|
ReleaseGood
|
|
12
14
|
} from '@things-factory/sales-base'
|
|
13
15
|
import { Domain } from '@things-factory/shell'
|
|
14
|
-
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location
|
|
16
|
+
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location } from '@things-factory/warehouse-base'
|
|
15
17
|
|
|
16
18
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
19
|
+
import { generateInventoryHistory } from '../../../utils'
|
|
17
20
|
|
|
18
21
|
export const confirmCancellationReleaseOrder = {
|
|
19
22
|
async confirmCancellationReleaseOrder(_: any, { name }, context: any) {
|
|
@@ -22,9 +25,13 @@ export const confirmCancellationReleaseOrder = {
|
|
|
22
25
|
where: { domain, name, status: ORDER_STATUS.PENDING_CANCEL },
|
|
23
26
|
relations: [
|
|
24
27
|
'bizplace',
|
|
28
|
+
'bizplace.domain',
|
|
29
|
+
'orderProducts',
|
|
25
30
|
'orderInventories',
|
|
26
31
|
'orderInventories.inventory',
|
|
27
32
|
'orderInventories.inventory.location',
|
|
33
|
+
'orderInventories.inventory.product',
|
|
34
|
+
'orderInventories.inventory.productDetail',
|
|
28
35
|
'orderVass'
|
|
29
36
|
]
|
|
30
37
|
})
|
|
@@ -189,6 +196,41 @@ export const confirmCancellationReleaseOrder = {
|
|
|
189
196
|
releaseGood.updater = user
|
|
190
197
|
await tx.getRepository(ReleaseGood).save(releaseGood)
|
|
191
198
|
|
|
199
|
+
// if (releaseGood?.refNo3 && releaseGood?.type == 'b2c') {
|
|
200
|
+
// const account: Account = await tx
|
|
201
|
+
// .getRepository(Account)
|
|
202
|
+
// .findOne({ domain: releaseGood.bizplace.domain, status: 'active' })
|
|
203
|
+
|
|
204
|
+
// // Xilnex create shipment and create sales return if sales invoice is completed
|
|
205
|
+
// const createSalesReturn = async account => {
|
|
206
|
+
// if (account) {
|
|
207
|
+
// await getManager().transaction(async txMgr => {
|
|
208
|
+
// if (account.platform == 'xilnex') {
|
|
209
|
+
// try {
|
|
210
|
+
// await AccountingAPI.createShipment(account, {
|
|
211
|
+
// releaseGood,
|
|
212
|
+
// orderProducts: releaseGood.orderProducts
|
|
213
|
+
// })
|
|
214
|
+
// } catch (error) {
|
|
215
|
+
// logger.error(`confirm-cancellation-release-order[createShipment]: ${error}`)
|
|
216
|
+
// }
|
|
217
|
+
|
|
218
|
+
// try {
|
|
219
|
+
// await AccountingAPI.createSalesReturn(account, {
|
|
220
|
+
// releaseGood,
|
|
221
|
+
// orderProducts: releaseGood.orderProducts
|
|
222
|
+
// })
|
|
223
|
+
// } catch (error) {
|
|
224
|
+
// logger.error(`confirm-cancellation-release-order[createSalesReturn]: ${error}`)
|
|
225
|
+
// }
|
|
226
|
+
// }
|
|
227
|
+
// })
|
|
228
|
+
// }
|
|
229
|
+
// }
|
|
230
|
+
|
|
231
|
+
// createSalesReturn(account)
|
|
232
|
+
// }
|
|
233
|
+
|
|
192
234
|
return
|
|
193
235
|
}
|
|
194
236
|
}
|
|
@@ -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
|
|
7
|
+
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location } 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 { switchLocationStatus } from '../../../utils'
|
|
12
|
+
import { generateInventoryHistory, switchLocationStatus } from '../../../utils'
|
|
13
13
|
|
|
14
14
|
export const cycleCountAdjustmentResolver = {
|
|
15
15
|
async cycleCountAdjustment(_: any, { cycleCountNo }, context: any) {
|
|
@@ -33,6 +33,7 @@ export const cycleCountWorksheetResolver = {
|
|
|
33
33
|
.leftJoinAndSelect('INV.location', 'LOC')
|
|
34
34
|
.leftJoinAndSelect('INV.product', 'PROD')
|
|
35
35
|
.leftJoinAndSelect('LOC.warehouse', 'WH')
|
|
36
|
+
.leftJoinAndSelect('INS_LOC.warehouse', 'INS_WH')
|
|
36
37
|
|
|
37
38
|
if (locationSortingRules?.length > 0) {
|
|
38
39
|
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EntityManager, SelectQueryBuilder } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
ORDER_INVENTORY_STATUS,
|
|
5
|
+
ORDER_STATUS,
|
|
6
|
+
OrderInventory as OrderInventoryEntity,
|
|
7
|
+
ReleaseGood as ReleaseGoodEntity
|
|
8
8
|
} from '@things-factory/sales-base'
|
|
9
9
|
import { Domain } from '@things-factory/shell'
|
|
10
10
|
import { Location } from '@things-factory/warehouse-base'
|
|
@@ -13,68 +13,68 @@ import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
|
13
13
|
import { Worksheet as WorksheetEntity, WorksheetDetail as WorksheetDetailEntity } from '../../../entities'
|
|
14
14
|
|
|
15
15
|
export const findSortingReleaseOrdersByTaskNoResolver = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
async findSortingReleaseOrdersByTaskNo(_: any, { taskNo }, context: any) {
|
|
17
|
+
const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
|
|
18
|
+
let task = await tx.getRepository(WorksheetEntity).findOne({
|
|
19
|
+
where: { taskNo, status: WORKSHEET_STATUS.EXECUTING, type: WORKSHEET_TYPE.SORTING }
|
|
20
|
+
})
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
// Find Task based on Bin
|
|
23
|
+
if (!task) {
|
|
24
|
+
const binLocation: Location = await tx.getRepository(Location).findOne({
|
|
25
|
+
where: { domain, name: taskNo }
|
|
26
|
+
})
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const qb: SelectQueryBuilder<OrderInventoryEntity> = tx
|
|
29
|
+
.getRepository(OrderInventoryEntity)
|
|
30
|
+
.createQueryBuilder('orderInventory')
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
qb.innerJoinAndSelect('orderInventory.releaseGood', 'releaseGood')
|
|
33
|
+
.innerJoinAndSelect('worksheets', 'ws', `orderInventory.ref_worksheet_id = ws.id AND ws.type = 'BATCH_PICKING'`)
|
|
34
|
+
.innerJoinAndSelect('worksheets', 'ws2', `ws2.task_no = ws.task_no AND ws2.type = 'SORTING'`)
|
|
35
|
+
.innerJoinAndSelect('releaseGood.bizplace', 'bizplace')
|
|
36
|
+
.innerJoinAndSelect('bizplace.domain', 'domain')
|
|
37
|
+
.where('orderInventory.domain_id = :domainId', { domainId: domain.id })
|
|
38
|
+
.andWhere('orderInventory.status IN (:...orderInventoryStatus)', {
|
|
39
|
+
orderInventoryStatus: [ORDER_INVENTORY_STATUS.SORTING]
|
|
40
|
+
})
|
|
41
|
+
.andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
|
|
42
|
+
.andWhere('releaseGood.status = :status', { status: ORDER_STATUS.SORTING })
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const orderInventoryByBin = await qb.getRawOne()
|
|
45
|
+
if (orderInventoryByBin?.releaseGood_id) {
|
|
46
|
+
taskNo = orderInventoryByBin.ws_task_no
|
|
47
|
+
task = await tx.getRepository(WorksheetEntity).findOne({
|
|
48
|
+
where: { taskNo, status: WORKSHEET_STATUS.EXECUTING, type: WORKSHEET_TYPE.SORTING }
|
|
49
|
+
})
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error(`Bin do not have any batch picking order.`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
if (!task) throw new Error('Unable to find task no.')
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
const qb: SelectQueryBuilder<WorksheetEntity> = tx
|
|
58
|
+
.getRepository(WorksheetEntity)
|
|
59
|
+
.createQueryBuilder('ws')
|
|
60
|
+
.select('rg.id as id')
|
|
61
|
+
.addSelect('rg.name as name')
|
|
62
|
+
.addSelect('rg.status as status')
|
|
63
|
+
.innerJoin(Domain, 'domain', 'ws.domain_id = domain.id')
|
|
64
|
+
.innerJoin(WorksheetDetailEntity, 'wsd', 'ws.id = wsd.worksheet_id')
|
|
65
|
+
.innerJoin(OrderInventoryEntity, 'oi', 'oi.id = wsd.target_inventory_id')
|
|
66
|
+
.innerJoin(ReleaseGoodEntity, 'rg', 'rg.id = oi.release_good_id')
|
|
67
|
+
.where('domain.id = :domainId', { domainId: domain.id })
|
|
68
|
+
.andWhere('ws.taskNo = :taskNo', { taskNo: taskNo })
|
|
69
|
+
.andWhere('ws.type = :worksheetType', { worksheetType: WORKSHEET_TYPE.SORTING })
|
|
70
|
+
.andWhere('ws.status = :worksheetStatus', { worksheetStatus: WORKSHEET_STATUS.EXECUTING })
|
|
71
|
+
.andWhere('rg.status = :roStatus', { roStatus: ORDER_STATUS.SORTING })
|
|
72
|
+
.groupBy('rg.id')
|
|
73
|
+
.addGroupBy('rg.name')
|
|
74
|
+
.addGroupBy('rg.status')
|
|
75
|
+
.orderBy('rg.createdAt', 'ASC')
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
77
|
+
const releaseGoods: ReleaseGoodEntity[] = await qb.getRawMany()
|
|
78
|
+
return { releaseGoods, taskNo }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -40,7 +40,6 @@ 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')
|
|
44
43
|
.leftJoinAndSelect('iv.warehouse', 'warehouse')
|
|
45
44
|
.leftJoinAndSelect('iv.location', 'location')
|
|
46
45
|
.leftJoinAndSelect('iv.creator', 'creator')
|
|
@@ -135,8 +134,7 @@ export const inventoriesByPalletResolver = {
|
|
|
135
134
|
productName: item.product.name,
|
|
136
135
|
productSKU: item.product.sku,
|
|
137
136
|
productBrand: item.product.brand,
|
|
138
|
-
productId: item.product.id
|
|
139
|
-
productDetailId: item.productDetail.id
|
|
137
|
+
productId: item.product.id
|
|
140
138
|
}
|
|
141
139
|
})
|
|
142
140
|
)
|
|
@@ -14,7 +14,7 @@ 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
|
|
17
|
+
import { WORKSHEET_TYPE } from '../../../constants'
|
|
18
18
|
import { PackingWorksheetController, SellercraftController } from '../../../controllers'
|
|
19
19
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
20
20
|
|
|
@@ -104,9 +104,7 @@ export const packingWorksheetResolver = {
|
|
|
104
104
|
|
|
105
105
|
if (!worksheet) throw new Error('Worksheet does not exist')
|
|
106
106
|
|
|
107
|
-
if (worksheet.status ===
|
|
108
|
-
throw new Error(`Worksheet is completed already`)
|
|
109
|
-
} else if (worksheet.status === WORKSHEET_STATUS.DEACTIVATED) {
|
|
107
|
+
if (worksheet.status === 'DEACTIVATED') {
|
|
110
108
|
const packingWSCtrl: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
111
109
|
|
|
112
110
|
const directActivatePackingWorksheet: Setting = await tx.getRepository(Setting).findOne({
|
|
@@ -93,9 +93,9 @@ export async function completeBatchPicking(
|
|
|
93
93
|
break
|
|
94
94
|
|
|
95
95
|
case ApplicationType.MMS:
|
|
96
|
-
const companyDomain: Domain =
|
|
96
|
+
const companyDomain: Domain = foundReleaseGood.bizplace.company.domain
|
|
97
97
|
const marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
98
|
-
where: { orderNo:
|
|
98
|
+
where: { orderNo: foundReleaseGood.refNo, domain: companyDomain },
|
|
99
99
|
relations: [
|
|
100
100
|
'marketplaceOrderItems',
|
|
101
101
|
'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
@@ -108,7 +108,7 @@ export async function completeBatchPicking(
|
|
|
108
108
|
|
|
109
109
|
if (marketplaceStore?.isAutoUpdateShipment) {
|
|
110
110
|
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
111
|
-
await ecommerceCtrl.createOrderShip(
|
|
111
|
+
await ecommerceCtrl.createOrderShip(foundReleaseGood, marketplaceStore, marketplaceOrder, companyDomain)
|
|
112
112
|
}
|
|
113
113
|
break
|
|
114
114
|
|
|
@@ -2,6 +2,8 @@ import { EntityManager, getManager } from 'typeorm'
|
|
|
2
2
|
|
|
3
3
|
import { ApplicationType, User } from '@things-factory/auth-base'
|
|
4
4
|
import { Bizplace, ContactPoint, getMyBizplace } from '@things-factory/biz-base'
|
|
5
|
+
// import { logger } from '@things-factory/env'
|
|
6
|
+
// import { Account, AccountingAPI } from '@things-factory/integration-accounting'
|
|
5
7
|
import { LastMileAPI, LastMileDelivery } from '@things-factory/integration-lmd'
|
|
6
8
|
import { MarketplaceStore, MarketplaceTransporter } from '@things-factory/integration-marketplace'
|
|
7
9
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
@@ -57,7 +59,15 @@ export async function completePicking(
|
|
|
57
59
|
const pickingWSCtrl: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
|
|
58
60
|
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
59
61
|
where: { domain, name: releaseGoodNo },
|
|
60
|
-
relations: [
|
|
62
|
+
relations: [
|
|
63
|
+
'bizplace',
|
|
64
|
+
'bizplace.domain',
|
|
65
|
+
'bizplace.company',
|
|
66
|
+
'bizplace.company.domain',
|
|
67
|
+
'orderProducts',
|
|
68
|
+
'orderProducts.product',
|
|
69
|
+
'orderProducts.productDetail'
|
|
70
|
+
]
|
|
61
71
|
})
|
|
62
72
|
|
|
63
73
|
const worksheet: Worksheet = await pickingWSCtrl.findWorksheetByRefOrder(releaseGood, WORKSHEET_TYPE.PICKING, [
|
|
@@ -238,6 +248,52 @@ export async function completePicking(
|
|
|
238
248
|
break
|
|
239
249
|
}
|
|
240
250
|
|
|
251
|
+
// const account: Account = await tx
|
|
252
|
+
// .getRepository(Account)
|
|
253
|
+
// .findOne({ domain: releaseGood.bizplace.domain, status: 'active' })
|
|
254
|
+
|
|
255
|
+
// // Xilnex Create Sales Order and Post Sales Order to Sales Invoice
|
|
256
|
+
// const createSalesOrder = async account => {
|
|
257
|
+
// if (account) {
|
|
258
|
+
// try {
|
|
259
|
+
// await getManager().transaction(async txMgr => {
|
|
260
|
+
// if (account.platform == 'xilnex') {
|
|
261
|
+
// const salesOrder: any = await AccountingAPI.createSalesOrder(account, {
|
|
262
|
+
// releaseGood,
|
|
263
|
+
// orderProducts: releaseGood.orderProducts
|
|
264
|
+
// })
|
|
265
|
+
|
|
266
|
+
// if (salesOrder) {
|
|
267
|
+
// const salesInvoice: any = await AccountingAPI.postSalesOrderToSalesInvoice(account, {
|
|
268
|
+
// orderId: salesOrder?.id || null
|
|
269
|
+
// })
|
|
270
|
+
|
|
271
|
+
// const salesOrderItems: any = salesInvoice.sale.items
|
|
272
|
+
// await Promise.all(
|
|
273
|
+
// releaseGood.orderProducts.map(async op => {
|
|
274
|
+
// const matchedProduct: any = salesOrderItems.find(soi => soi.itemId == op.productDetail.refCode)
|
|
275
|
+
// if (matchedProduct) {
|
|
276
|
+
// await tx.getRepository(OrderProduct).update({ id: op.id }, { refItemId: matchedProduct.id })
|
|
277
|
+
// }
|
|
278
|
+
// })
|
|
279
|
+
// )
|
|
280
|
+
|
|
281
|
+
// await txMgr
|
|
282
|
+
// .getRepository(ReleaseGood)
|
|
283
|
+
// .update({ id: releaseGood.id }, { refNo3: salesInvoice.salesId, updater: releaseGood.updater })
|
|
284
|
+
// }
|
|
285
|
+
// }
|
|
286
|
+
// })
|
|
287
|
+
// } catch (error) {
|
|
288
|
+
// logger.error(`complete-picking[createSalesOrder]: ${error}`)
|
|
289
|
+
// }
|
|
290
|
+
// }
|
|
291
|
+
// }
|
|
292
|
+
|
|
293
|
+
// if (releaseGood.type == 'b2c') {
|
|
294
|
+
// createSalesOrder(account)
|
|
295
|
+
// }
|
|
296
|
+
|
|
241
297
|
if (releaseGood.packingOption) {
|
|
242
298
|
const packingWSCtrl: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
243
299
|
await packingWSCtrl.generatePackingWorksheet(releaseGoodNo)
|