@things-factory/operato-wms 4.3.3 → 4.3.6
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/entities/warehouse-bizplace-onhand-inventory.js +7 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js +5 -6
- package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js +29 -16
- package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js.map +1 -1
- package/package.json +5 -5
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +7 -1
- package/server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts +5 -6
- package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +29 -16
|
@@ -107,6 +107,8 @@ WarehouseBizplaceOnhandInventory = __decorate([
|
|
|
107
107
|
null as "productBundleId",
|
|
108
108
|
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) AS "remainQty",
|
|
109
109
|
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)), 0) AS "remainUomValue",
|
|
110
|
+
COALESCE(sum(COALESCE(i.qty, 0::double precision))) AS "qty",
|
|
111
|
+
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "uomValue",
|
|
110
112
|
'SINGLE' AS "groupType"
|
|
111
113
|
FROM inventories i
|
|
112
114
|
INNER JOIN locations l2 ON i.location_id = l2.id AND i.domain_id = l2.domain_id AND l2.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
@@ -131,12 +133,16 @@ WarehouseBizplaceOnhandInventory = __decorate([
|
|
|
131
133
|
pb.id AS "productBundleId",
|
|
132
134
|
COALESCE(MIN(FLOOR(pbs."availableQty")),0) AS "remainQty",
|
|
133
135
|
COALESCE(MIN(FLOOR(pbs."availableUomValue")),0) AS "remainUomValue",
|
|
136
|
+
COALESCE(MIN(FLOOR(pbs."qty")), 0::double precision) AS "qty",
|
|
137
|
+
COALESCE(MIN(FLOOR(pbs."uomValue")), 0::double precision) AS "uomValue",
|
|
134
138
|
'BUNDLE' AS "groupType"
|
|
135
139
|
FROM product_bundles pb
|
|
136
140
|
INNER JOIN (
|
|
137
141
|
SELECT i.domain_id, i.bizplace_id, pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
138
142
|
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
139
|
-
(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"
|
|
143
|
+
(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",
|
|
144
|
+
(sum(COALESCE(i.qty, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "qty",
|
|
145
|
+
(sum(COALESCE(i.uom_value, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "uomValue"
|
|
140
146
|
FROM product_bundle_settings pbs
|
|
141
147
|
LEFT JOIN inventories i ON i.product_id = pbs.product_id AND i.status = 'STORED'
|
|
142
148
|
INNER JOIN locations l ON i.location_id = l.id AND i.domain_id = l.domain_id AND l.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warehouse-bizplace-onhand-inventory.js","sourceRoot":"","sources":["../../server/entities/warehouse-bizplace-onhand-inventory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgD;
|
|
1
|
+
{"version":3,"file":"warehouse-bizplace-onhand-inventory.js","sourceRoot":"","sources":["../../server/entities/warehouse-bizplace-onhand-inventory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgD;AA8GhD,IAAa,gCAAgC,GAA7C,MAAa,gCAAgC;CAoC5C,CAAA;AAlCC;IADC,IAAA,oBAAU,GAAE;;oEACK;AAGlB;IADC,IAAA,oBAAU,GAAE;;sEACO;AAGpB;IADC,IAAA,oBAAU,GAAE;;kEACG;AAGhB;IADC,IAAA,oBAAU,GAAE;;oEACK;AAGlB;IADC,IAAA,oBAAU,GAAE;;qEACM;AAGnB;IADC,IAAA,oBAAU,GAAE;;qEACM;AAGnB;IADC,IAAA,oBAAU,GAAE;;6DACF;AAGX;IADC,IAAA,oBAAU,GAAE;;mEACI;AAGjB;IADC,IAAA,oBAAU,GAAE;;yEACU;AAGvB;IADC,IAAA,oBAAU,GAAE;;mEACI;AAGjB;IADC,IAAA,oBAAU,GAAE;;wEACS;AAGtB;IADC,IAAA,oBAAU,GAAE;;mEACI;AAnCN,gCAAgC;IA5G5C,IAAA,oBAAU,EAAC;QACV,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGX;KACF,CAAC;GAEW,gCAAgC,CAoC5C;AApCY,4EAAgC"}
|
|
@@ -16,16 +16,15 @@ exports.inventoryExpiryMonitorResolver = {
|
|
|
16
16
|
async inventoryExpiryMonitor(_, params, context) {
|
|
17
17
|
const { domain, tx } = context.state;
|
|
18
18
|
const expInventories = await tx.query(`
|
|
19
|
-
SELECT "location", sum("expired") AS "expired", sum("
|
|
19
|
+
SELECT "location", sum("expired") AS "expired", sum("sixMonths") AS "sixMonths", sum("nineMonths") AS "nineMonths" FROM (
|
|
20
20
|
SELECT
|
|
21
21
|
CASE WHEN l.TYPE IN ('QUARANTINE','RESERVE') THEN 'QUARANTINED' ELSE 'IN SHELF' END AS "location",
|
|
22
22
|
CASE WHEN i.expiration_date - now()::date <= 0 THEN 1 ELSE 0 END AS "expired",
|
|
23
|
-
CASE WHEN i.expiration_date - now()::date > 0 AND i.expiration_date - now()::date <=
|
|
24
|
-
CASE WHEN i.expiration_date - now()::date >
|
|
25
|
-
CASE WHEN i.expiration_date - now()::date > 45 AND i.expiration_date - now()::date <= 60 THEN 1 ELSE 0 END AS "sixtyDays"
|
|
23
|
+
CASE WHEN i.expiration_date - now()::date > 0 AND i.expiration_date - now()::date <= 180 THEN 1 ELSE 0 END AS "sixMonths",
|
|
24
|
+
CASE WHEN i.expiration_date - now()::date > 180 AND i.expiration_date - now()::date <= 270 THEN 1 ELSE 0 END AS "nineMonths"
|
|
26
25
|
FROM inventories i
|
|
27
26
|
INNER JOIN locations l ON i.location_id = l.id
|
|
28
|
-
WHERE i.expiration_date - now()::date <=
|
|
27
|
+
WHERE i.expiration_date - now()::date <= 270
|
|
29
28
|
AND i.expiration_date NOTNULL
|
|
30
29
|
AND i.status = 'STORED'
|
|
31
30
|
AND i.domain_id = $1
|
|
@@ -46,6 +45,6 @@ function getExpiryCountByStatus(expInventories, location) {
|
|
|
46
45
|
return inv;
|
|
47
46
|
})(matchedInv);
|
|
48
47
|
else
|
|
49
|
-
return { expired: 0,
|
|
48
|
+
return { expired: 0, sixMonths: 0, nineMonths: 0 };
|
|
50
49
|
}
|
|
51
50
|
//# sourceMappingURL=inventory-expiry-monitor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory-expiry-monitor.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKa,QAAA,8BAA8B,GAAG;IAC5C,KAAK,CAAC,sBAAsB,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QAClE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAEvF,MAAM,cAAc,GAMd,MAAM,EAAE,CAAC,KAAK,CAClB
|
|
1
|
+
{"version":3,"file":"inventory-expiry-monitor.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKa,QAAA,8BAA8B,GAAG;IAC5C,KAAK,CAAC,sBAAsB,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QAClE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAEvF,MAAM,cAAc,GAMd,MAAM,EAAE,CAAC,KAAK,CAClB;;;;;;;;;;;;;;;KAeD,EACC,CAAC,MAAM,CAAC,EAAE,CAAC,CACZ,CAAA;QAED,OAAO;YACL,WAAW,EAAE,sBAAsB,CAAC,cAAc,EAAE,aAAa,CAAC;YAClE,OAAO,EAAE,sBAAsB,CAAC,cAAc,EAAE,UAAU,CAAC;SAC5D,CAAA;IACH,CAAC;CACF,CAAA;AAED,SAAS,sBAAsB,CAAC,cAAc,EAAE,QAAQ;IACtD,IAAI,UAAU,GAAQ,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAA;IAE1E,IAAI,UAAU;QAAE,OAAO,CAAC,CAAC,EAAoB,EAAE,EAAE;gBAAxB,EAAE,QAAQ,OAAU,EAAL,GAAG,cAAlB,YAAoB,CAAF;YAAO,OAAA,GAAG,CAAA;SAAA,CAAC,CAAC,UAAU,CAAC,CAAA;;QAC7D,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAA;AACzD,CAAC"}
|
|
@@ -3,32 +3,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.outboundOrderByStatusResolver = void 0;
|
|
4
4
|
exports.outboundOrderByStatusResolver = {
|
|
5
5
|
async outboundOrderByStatus(_, params, context) {
|
|
6
|
-
const { domain,
|
|
6
|
+
const { domain, tx } = context.state;
|
|
7
7
|
const orderStatus = await tx.query(`
|
|
8
8
|
(
|
|
9
9
|
SELECT "status", COUNT(*) AS "count" FROM (
|
|
10
10
|
SELECT
|
|
11
|
-
CASE WHEN "status" = '
|
|
12
|
-
WHEN "status" = '
|
|
13
|
-
WHEN "status"
|
|
14
|
-
|
|
11
|
+
CASE WHEN "status" = 'DONE' and rg.updated_at::date = CURRENT_DATE THEN 'DONE'
|
|
12
|
+
WHEN "status" = 'CANCELLED' THEN 'CANCELLED'
|
|
13
|
+
WHEN "status" IN('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK') THEN 'PICKING UNASSIGNED'
|
|
14
|
+
WHEN "status" IN('READY_TO_PACK', 'PACKING') THEN 'PACKING'
|
|
15
|
+
WHEN "dispatchment_status" = 'READY_TO_DISPATCH' and "tracking_no" NOTNULL and "status" NOT IN ('CANCELLED', 'PENDING_CANCEL') THEN 'AWAITING DISPATCH'
|
|
16
|
+
WHEN "dispatchment_status" = 'DISPATCHED' and "tracking_no" NOTNULL and "status" NOT IN ('CANCELLED', 'PENDING_CANCEL') THEN 'OUT FROM WAREHOUSE'
|
|
17
|
+
END AS "status"
|
|
18
|
+
FROM release_goods rg
|
|
15
19
|
WHERE "domain_id" = $1
|
|
20
|
+
AND rg."status" IN ('CANCELLED','PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING', 'READY_TO_PACK', 'PACKING', 'DONE')
|
|
16
21
|
) AS foo
|
|
17
|
-
WHERE status IN ('PICKING ASSIGNED', 'PICKING UNASSIGNED', 'PACKING')
|
|
18
22
|
GROUP BY "status"
|
|
19
23
|
) UNION ALL (
|
|
20
|
-
SELECT "status", COUNT(
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
SELECT "status", COUNT(*) AS "count" FROM (
|
|
25
|
+
SELECT
|
|
26
|
+
CASE WHEN "dispatchment_status" = 'READY_TO_DISPATCH' and tracking_no NOTNULL THEN 'AWAITING DISPATCH'
|
|
27
|
+
WHEN "dispatchment_status" = 'DISPATCHED' THEN 'OUT FROM WAREHOUSE'
|
|
28
|
+
END AS "status"
|
|
29
|
+
FROM release_goods rg
|
|
30
|
+
WHERE "domain_id" = $1
|
|
31
|
+
AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
|
|
32
|
+
AND rg."status" NOT IN ('CANCELLED', 'PENDING_CANCEL')
|
|
33
|
+
AND rg."tracking_no" NOTNULL
|
|
34
|
+
) AS foo
|
|
23
35
|
GROUP BY "status"
|
|
24
36
|
) UNION ALL (
|
|
25
|
-
SELECT
|
|
26
|
-
|
|
27
|
-
WHEN "status"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
SELECT "status", COUNT(*) AS "count" FROM (
|
|
38
|
+
SELECT
|
|
39
|
+
CASE WHEN "status" IN('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING') THEN 'PICKING ASSIGNED'
|
|
40
|
+
END AS "status"
|
|
41
|
+
FROM release_goods rg
|
|
42
|
+
WHERE "domain_id" = $1
|
|
43
|
+
AND rg."status" IN ('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING')
|
|
44
|
+
) AS foo
|
|
32
45
|
GROUP BY "status"
|
|
33
46
|
)
|
|
34
47
|
`, [domain.id]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbound-order-by-status.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/outbound-order-by-status.ts"],"names":[],"mappings":";;;AAKa,QAAA,6BAA6B,GAAG;IAC3C,KAAK,CAAC,qBAAqB,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACjE,MAAM,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"outbound-order-by-status.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/outbound-order-by-status.ts"],"names":[],"mappings":";;;AAKa,QAAA,6BAA6B,GAAG;IAC3C,KAAK,CAAC,qBAAqB,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACjE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAEvF,MAAM,WAAW,GAAwC,MAAM,EAAE,CAAC,KAAK,CACrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCD,EACC,CAAC,MAAM,CAAC,EAAE,CAAC,CACZ,CAAA;QAED,MAAM,UAAU,GAAa;YAC3B,oBAAoB;YACpB,kBAAkB;YAClB,SAAS;YACT,mBAAmB;YACnB,oBAAoB;YACpB,WAAW;YACX,MAAM;YACN,cAAc;SACf,CAAA;QAED,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,YAAiD,EAAE,MAAc,EAAE,EAAE;YAC7F,IAAI,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,CAAA;YAEjE,IAAI,SAAS;gBAAE,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;;gBAC/D,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;YAE5C,OAAO,YAAY,CAAA;QACrB,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,CAAC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-wms",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.6",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@things-factory/print-ui": "^4.3.2",
|
|
93
93
|
"@things-factory/product-base": "^4.3.2",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.2",
|
|
95
|
-
"@things-factory/sales-ui": "^4.3.
|
|
95
|
+
"@things-factory/sales-ui": "^4.3.6",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.2",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.2",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.2",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"@things-factory/system-ui": "^4.3.2",
|
|
109
109
|
"@things-factory/transport-base": "^4.3.2",
|
|
110
110
|
"@things-factory/tutorial-ui": "^4.3.2",
|
|
111
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
112
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
111
|
+
"@things-factory/warehouse-base": "^4.3.6",
|
|
112
|
+
"@things-factory/worksheet-base": "^4.3.6"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@things-factory/builder": "^4.3.1",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"cypress-localstorage-commands": "^1.6.1",
|
|
119
119
|
"eslint-plugin-cypress": "^2.12.1"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "4bac4b99239169cd2daa6e92a69bde75af7494df"
|
|
122
122
|
}
|
|
@@ -45,6 +45,8 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
45
45
|
null as "productBundleId",
|
|
46
46
|
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) AS "remainQty",
|
|
47
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",
|
|
48
|
+
COALESCE(sum(COALESCE(i.qty, 0::double precision))) AS "qty",
|
|
49
|
+
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "uomValue",
|
|
48
50
|
'SINGLE' AS "groupType"
|
|
49
51
|
FROM inventories i
|
|
50
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')
|
|
@@ -69,12 +71,16 @@ import { ViewColumn, ViewEntity } from 'typeorm'
|
|
|
69
71
|
pb.id AS "productBundleId",
|
|
70
72
|
COALESCE(MIN(FLOOR(pbs."availableQty")),0) AS "remainQty",
|
|
71
73
|
COALESCE(MIN(FLOOR(pbs."availableUomValue")),0) AS "remainUomValue",
|
|
74
|
+
COALESCE(MIN(FLOOR(pbs."qty")), 0::double precision) AS "qty",
|
|
75
|
+
COALESCE(MIN(FLOOR(pbs."uomValue")), 0::double precision) AS "uomValue",
|
|
72
76
|
'BUNDLE' AS "groupType"
|
|
73
77
|
FROM product_bundles pb
|
|
74
78
|
INNER JOIN (
|
|
75
79
|
SELECT i.domain_id, i.bizplace_id, pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
76
80
|
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
77
|
-
(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"
|
|
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",
|
|
82
|
+
(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 "uomValue"
|
|
78
84
|
FROM product_bundle_settings pbs
|
|
79
85
|
LEFT JOIN inventories i ON i.product_id = pbs.product_id AND i.status = 'STORED'
|
|
80
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')
|
|
@@ -15,16 +15,15 @@ export const inventoryExpiryMonitorResolver = {
|
|
|
15
15
|
sixtyDays: number
|
|
16
16
|
}[] = await tx.query(
|
|
17
17
|
`
|
|
18
|
-
SELECT "location", sum("expired") AS "expired", sum("
|
|
18
|
+
SELECT "location", sum("expired") AS "expired", sum("sixMonths") AS "sixMonths", sum("nineMonths") AS "nineMonths" FROM (
|
|
19
19
|
SELECT
|
|
20
20
|
CASE WHEN l.TYPE IN ('QUARANTINE','RESERVE') THEN 'QUARANTINED' ELSE 'IN SHELF' END AS "location",
|
|
21
21
|
CASE WHEN i.expiration_date - now()::date <= 0 THEN 1 ELSE 0 END AS "expired",
|
|
22
|
-
CASE WHEN i.expiration_date - now()::date > 0 AND i.expiration_date - now()::date <=
|
|
23
|
-
CASE WHEN i.expiration_date - now()::date >
|
|
24
|
-
CASE WHEN i.expiration_date - now()::date > 45 AND i.expiration_date - now()::date <= 60 THEN 1 ELSE 0 END AS "sixtyDays"
|
|
22
|
+
CASE WHEN i.expiration_date - now()::date > 0 AND i.expiration_date - now()::date <= 180 THEN 1 ELSE 0 END AS "sixMonths",
|
|
23
|
+
CASE WHEN i.expiration_date - now()::date > 180 AND i.expiration_date - now()::date <= 270 THEN 1 ELSE 0 END AS "nineMonths"
|
|
25
24
|
FROM inventories i
|
|
26
25
|
INNER JOIN locations l ON i.location_id = l.id
|
|
27
|
-
WHERE i.expiration_date - now()::date <=
|
|
26
|
+
WHERE i.expiration_date - now()::date <= 270
|
|
28
27
|
AND i.expiration_date NOTNULL
|
|
29
28
|
AND i.status = 'STORED'
|
|
30
29
|
AND i.domain_id = $1
|
|
@@ -45,5 +44,5 @@ function getExpiryCountByStatus(expInventories, location) {
|
|
|
45
44
|
let matchedInv: any = expInventories.find(inv => inv.location == location)
|
|
46
45
|
|
|
47
46
|
if (matchedInv) return (({ location, ...inv }) => inv)(matchedInv)
|
|
48
|
-
else return { expired: 0,
|
|
47
|
+
else return { expired: 0, sixMonths: 0, nineMonths: 0 }
|
|
49
48
|
}
|
|
@@ -5,34 +5,47 @@ import { Domain, ListParam } from '@things-factory/shell'
|
|
|
5
5
|
|
|
6
6
|
export const outboundOrderByStatusResolver = {
|
|
7
7
|
async outboundOrderByStatus(_: any, params: ListParam, context: any) {
|
|
8
|
-
const { domain,
|
|
8
|
+
const { domain, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
9
9
|
|
|
10
10
|
const orderStatus: { status: string; count: number }[] = await tx.query(
|
|
11
11
|
`
|
|
12
12
|
(
|
|
13
13
|
SELECT "status", COUNT(*) AS "count" FROM (
|
|
14
14
|
SELECT
|
|
15
|
-
CASE WHEN "status" = '
|
|
16
|
-
WHEN "status" = '
|
|
17
|
-
WHEN "status"
|
|
18
|
-
|
|
15
|
+
CASE WHEN "status" = 'DONE' and rg.updated_at::date = CURRENT_DATE THEN 'DONE'
|
|
16
|
+
WHEN "status" = 'CANCELLED' THEN 'CANCELLED'
|
|
17
|
+
WHEN "status" IN('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK') THEN 'PICKING UNASSIGNED'
|
|
18
|
+
WHEN "status" IN('READY_TO_PACK', 'PACKING') THEN 'PACKING'
|
|
19
|
+
WHEN "dispatchment_status" = 'READY_TO_DISPATCH' and "tracking_no" NOTNULL and "status" NOT IN ('CANCELLED', 'PENDING_CANCEL') THEN 'AWAITING DISPATCH'
|
|
20
|
+
WHEN "dispatchment_status" = 'DISPATCHED' and "tracking_no" NOTNULL and "status" NOT IN ('CANCELLED', 'PENDING_CANCEL') THEN 'OUT FROM WAREHOUSE'
|
|
21
|
+
END AS "status"
|
|
22
|
+
FROM release_goods rg
|
|
19
23
|
WHERE "domain_id" = $1
|
|
24
|
+
AND rg."status" IN ('CANCELLED','PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING', 'READY_TO_PACK', 'PACKING', 'DONE')
|
|
20
25
|
) AS foo
|
|
21
|
-
WHERE status IN ('PICKING ASSIGNED', 'PICKING UNASSIGNED', 'PACKING')
|
|
22
26
|
GROUP BY "status"
|
|
23
27
|
) UNION ALL (
|
|
24
|
-
SELECT "status", COUNT(
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
SELECT "status", COUNT(*) AS "count" FROM (
|
|
29
|
+
SELECT
|
|
30
|
+
CASE WHEN "dispatchment_status" = 'READY_TO_DISPATCH' and tracking_no NOTNULL THEN 'AWAITING DISPATCH'
|
|
31
|
+
WHEN "dispatchment_status" = 'DISPATCHED' THEN 'OUT FROM WAREHOUSE'
|
|
32
|
+
END AS "status"
|
|
33
|
+
FROM release_goods rg
|
|
34
|
+
WHERE "domain_id" = $1
|
|
35
|
+
AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
|
|
36
|
+
AND rg."status" NOT IN ('CANCELLED', 'PENDING_CANCEL')
|
|
37
|
+
AND rg."tracking_no" NOTNULL
|
|
38
|
+
) AS foo
|
|
27
39
|
GROUP BY "status"
|
|
28
40
|
) UNION ALL (
|
|
29
|
-
SELECT
|
|
30
|
-
|
|
31
|
-
WHEN "status"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
SELECT "status", COUNT(*) AS "count" FROM (
|
|
42
|
+
SELECT
|
|
43
|
+
CASE WHEN "status" IN('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING') THEN 'PICKING ASSIGNED'
|
|
44
|
+
END AS "status"
|
|
45
|
+
FROM release_goods rg
|
|
46
|
+
WHERE "domain_id" = $1
|
|
47
|
+
AND rg."status" IN ('PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING')
|
|
48
|
+
) AS foo
|
|
36
49
|
GROUP BY "status"
|
|
37
50
|
)
|
|
38
51
|
`,
|