@things-factory/operato-hub 4.3.352 → 4.3.355
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/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.js +17 -4
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.js.map +1 -1
- package/package.json +5 -5
- package/server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.ts +18 -4
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typeorm_1 = require("typeorm");
|
|
4
4
|
const api_1 = require("@things-factory/api");
|
|
5
|
+
const warehouse_base_1 = require("@things-factory/warehouse-base");
|
|
5
6
|
const middlewares_1 = require("../middlewares");
|
|
6
7
|
const error_util_1 = require("../utils/error-util");
|
|
7
8
|
api_1.restfulApiRouter.get('/v1/warehouse/get-warehouse-bizplace-onhand-inventories', middlewares_1.businessMiddleware, middlewares_1.validationMiddleware, middlewares_1.loggingMiddleware, async (context, next) => {
|
|
@@ -23,21 +24,33 @@ api_1.restfulApiRouter.get('/v1/warehouse/get-warehouse-bizplace-onhand-inventor
|
|
|
23
24
|
let data = [];
|
|
24
25
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
25
26
|
let itemList = await tx.query(`
|
|
26
|
-
select
|
|
27
|
+
select *, coalesce(wboi.qty, 0) as available_qty, coalesce(wboi.qty - wboi.remain_qty, 0) as reserved_qty, coalesce(wboi.remain_qty,0) as remain_qty,
|
|
28
|
+
coalesce(invReserve.qty, 0) as buffer_qty
|
|
29
|
+
from warehouse_bizplace_onhand_inventories wboi
|
|
30
|
+
left join (
|
|
31
|
+
select product_id, sum(i.qty) as qty from inventories i
|
|
32
|
+
inner join locations l2 on l2.id = i.location_id
|
|
33
|
+
where i.bizplace_id = $2 and i.domain_id = $2 and l2."type" = $3
|
|
34
|
+
group by i.product_id
|
|
35
|
+
) invReserve on invReserve.product_id = wboi.product_id
|
|
27
36
|
where wboi."domain_id"= $1 and
|
|
28
37
|
wboi."bizplace_id" = $2 and
|
|
29
38
|
wboi."group_type" = 'SINGLE' and
|
|
30
39
|
wboi."ref_code" IN (${refCodes
|
|
31
40
|
.map((i, idx) => {
|
|
32
|
-
return '$' + (idx +
|
|
41
|
+
return '$' + (idx + 4);
|
|
33
42
|
})
|
|
34
43
|
.join(', ')})
|
|
35
|
-
`, [domain.id, bizplaceId, ...refCodes]);
|
|
44
|
+
`, [domain.id, bizplaceId, warehouse_base_1.LOCATION_TYPE.RESERVE, ...refCodes]);
|
|
36
45
|
data = refCodes.map(refCode => {
|
|
37
46
|
const foundRefCode = itemList.find(item => item.ref_code == refCode);
|
|
38
47
|
return {
|
|
39
48
|
refCode,
|
|
40
|
-
|
|
49
|
+
stock: {
|
|
50
|
+
quantityTotal: !(foundRefCode === null || foundRefCode === void 0 ? void 0 : foundRefCode.qty) || foundRefCode.qty < 0 ? 0 : foundRefCode.qty,
|
|
51
|
+
quantityReserved: !(foundRefCode === null || foundRefCode === void 0 ? void 0 : foundRefCode.reserved_qty) || foundRefCode.reserved_qty < 0 ? 0 : foundRefCode.reserved_qty,
|
|
52
|
+
quantityBuffer: 0
|
|
53
|
+
}
|
|
41
54
|
};
|
|
42
55
|
});
|
|
43
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-warehouse-bizplace-onhand-inventories.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.ts"],"names":[],"mappings":";;AACA,qCAAsD;AAEtD,6CAAgE;
|
|
1
|
+
{"version":3,"file":"get-warehouse-bizplace-onhand-inventories.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.ts"],"names":[],"mappings":";;AACA,qCAAsD;AAEtD,6CAAgE;AAChE,mEAA8D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355",
|
|
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/pdf": "^4.3.281",
|
|
93
93
|
"@things-factory/product-ui": "^4.3.344",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.281",
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
+
"@things-factory/sales-base": "^4.3.355",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.281",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.281",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.281",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"@things-factory/setting-ui": "^4.3.281",
|
|
108
108
|
"@things-factory/shell": "^4.3.281",
|
|
109
109
|
"@things-factory/system-ui": "^4.3.281",
|
|
110
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
111
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
110
|
+
"@things-factory/warehouse-base": "^4.3.355",
|
|
111
|
+
"@things-factory/worksheet-base": "^4.3.355",
|
|
112
112
|
"cron-parser": "^4.7.0",
|
|
113
113
|
"koa2-swagger-ui": "^5.0.2",
|
|
114
114
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"resolutions": {
|
|
121
121
|
"core-js": "^3.16.0"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "9fdaecb5b50f781e33a2733f2227c35335636be3"
|
|
124
124
|
}
|
package/server/routers/api/restful-apis/v1/warehouse/get-warehouse-bizplace-onhand-inventories.ts
CHANGED
|
@@ -2,6 +2,7 @@ import _ from 'lodash'
|
|
|
2
2
|
import { EntityManager, getConnection } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
import { restfulApiRouter as router } from '@things-factory/api'
|
|
5
|
+
import { LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
5
6
|
|
|
6
7
|
import { businessMiddleware, loggingMiddleware, validationMiddleware } from '../middlewares'
|
|
7
8
|
import { ApiError, ApiErrorHandler, throwInternalServerError } from '../utils/error-util'
|
|
@@ -35,17 +36,25 @@ router.get(
|
|
|
35
36
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
36
37
|
let itemList: any = await tx.query(
|
|
37
38
|
`
|
|
38
|
-
select
|
|
39
|
+
select *, coalesce(wboi.qty, 0) as available_qty, coalesce(wboi.qty - wboi.remain_qty, 0) as reserved_qty, coalesce(wboi.remain_qty,0) as remain_qty,
|
|
40
|
+
coalesce(invReserve.qty, 0) as buffer_qty
|
|
41
|
+
from warehouse_bizplace_onhand_inventories wboi
|
|
42
|
+
left join (
|
|
43
|
+
select product_id, sum(i.qty) as qty from inventories i
|
|
44
|
+
inner join locations l2 on l2.id = i.location_id
|
|
45
|
+
where i.bizplace_id = $2 and i.domain_id = $2 and l2."type" = $3
|
|
46
|
+
group by i.product_id
|
|
47
|
+
) invReserve on invReserve.product_id = wboi.product_id
|
|
39
48
|
where wboi."domain_id"= $1 and
|
|
40
49
|
wboi."bizplace_id" = $2 and
|
|
41
50
|
wboi."group_type" = 'SINGLE' and
|
|
42
51
|
wboi."ref_code" IN (${refCodes
|
|
43
52
|
.map((i, idx) => {
|
|
44
|
-
return '$' + (idx +
|
|
53
|
+
return '$' + (idx + 4)
|
|
45
54
|
})
|
|
46
55
|
.join(', ')})
|
|
47
56
|
`,
|
|
48
|
-
[domain.id, bizplaceId, ...refCodes]
|
|
57
|
+
[domain.id, bizplaceId, LOCATION_TYPE.RESERVE, ...refCodes]
|
|
49
58
|
)
|
|
50
59
|
|
|
51
60
|
data = refCodes.map(refCode => {
|
|
@@ -53,7 +62,12 @@ router.get(
|
|
|
53
62
|
|
|
54
63
|
return {
|
|
55
64
|
refCode,
|
|
56
|
-
|
|
65
|
+
stock: {
|
|
66
|
+
quantityTotal: !foundRefCode?.qty || foundRefCode.qty < 0 ? 0 : foundRefCode.qty,
|
|
67
|
+
quantityReserved:
|
|
68
|
+
!foundRefCode?.reserved_qty || foundRefCode.reserved_qty < 0 ? 0 : foundRefCode.reserved_qty,
|
|
69
|
+
quantityBuffer: 0
|
|
70
|
+
}
|
|
57
71
|
}
|
|
58
72
|
})
|
|
59
73
|
})
|