@things-factory/worksheet-base 4.3.17 → 4.3.20
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/index.js +2 -1
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +174 -0
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -0
- package/package.json +17 -17
- package/server/entities/index.ts +2 -1
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +147 -0
|
@@ -7,5 +7,6 @@ const worksheet_detail_1 = require("./worksheet-detail");
|
|
|
7
7
|
Object.defineProperty(exports, "WorksheetDetail", { enumerable: true, get: function () { return worksheet_detail_1.WorksheetDetail; } });
|
|
8
8
|
const worksheet_movement_1 = require("./worksheet-movement");
|
|
9
9
|
Object.defineProperty(exports, "WorksheetMovement", { enumerable: true, get: function () { return worksheet_movement_1.WorksheetMovement; } });
|
|
10
|
-
|
|
10
|
+
const warehouse_bizplace_onhand_inventory_1 = require("./warehouse-bizplace-onhand-inventory");
|
|
11
|
+
exports.entities = [worksheet_1.Worksheet, worksheet_detail_1.WorksheetDetail, worksheet_movement_1.WorksheetMovement, warehouse_bizplace_onhand_inventory_1.WarehouseBizplaceOnhandInventory];
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/entities/index.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/entities/index.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAO9B,0FAPA,qBAAS,OAOA;AANlB,yDAAoD;AAMhC,gGANX,kCAAe,OAMW;AALnC,6DAAwD;AAKnB,kGAL5B,sCAAiB,OAK4B;AAJtD,+FAAwF;AAE3E,QAAA,QAAQ,GAAG,CAAC,qBAAS,EAAE,kCAAe,EAAE,sCAAiB,EAAE,sEAAgC,CAAC,CAAA"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WarehouseBizplaceOnhandInventory = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let WarehouseBizplaceOnhandInventory = class WarehouseBizplaceOnhandInventory {
|
|
15
|
+
};
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, typeorm_1.ViewColumn)(),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], WarehouseBizplaceOnhandInventory.prototype, "domainName", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, typeorm_1.ViewColumn)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], WarehouseBizplaceOnhandInventory.prototype, "bizplaceName", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.ViewColumn)(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], WarehouseBizplaceOnhandInventory.prototype, "domainId", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.ViewColumn)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], WarehouseBizplaceOnhandInventory.prototype, "bizplaceId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.ViewColumn)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], WarehouseBizplaceOnhandInventory.prototype, "packingType", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.ViewColumn)(),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], WarehouseBizplaceOnhandInventory.prototype, "packingSize", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.ViewColumn)(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], WarehouseBizplaceOnhandInventory.prototype, "uom", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.ViewColumn)(),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], WarehouseBizplaceOnhandInventory.prototype, "productId", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.ViewColumn)(),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], WarehouseBizplaceOnhandInventory.prototype, "productBundleId", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.ViewColumn)(),
|
|
54
|
+
__metadata("design:type", Number)
|
|
55
|
+
], WarehouseBizplaceOnhandInventory.prototype, "remainQty", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.ViewColumn)(),
|
|
58
|
+
__metadata("design:type", Number)
|
|
59
|
+
], WarehouseBizplaceOnhandInventory.prototype, "remainUomValue", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.ViewColumn)(),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], WarehouseBizplaceOnhandInventory.prototype, "groupType", void 0);
|
|
64
|
+
WarehouseBizplaceOnhandInventory = __decorate([
|
|
65
|
+
(0, typeorm_1.ViewEntity)({
|
|
66
|
+
expression: `
|
|
67
|
+
select d.name as "domainName", b.name as "bizplaceName", src.* from (
|
|
68
|
+
WITH oi as (
|
|
69
|
+
select
|
|
70
|
+
oi.domain_id,
|
|
71
|
+
oi.bizplace_id,
|
|
72
|
+
SUM(oi.release_qty) AS release_qty,
|
|
73
|
+
SUM(oi.release_uom_value) AS release_uom_value,
|
|
74
|
+
oi.batch_id,
|
|
75
|
+
oi.batch_id_ref,
|
|
76
|
+
oi.product_id,
|
|
77
|
+
oi.packing_type,
|
|
78
|
+
oi.packing_size,
|
|
79
|
+
oi.uom
|
|
80
|
+
FROM
|
|
81
|
+
order_inventories oi
|
|
82
|
+
WHERE
|
|
83
|
+
(oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
|
|
84
|
+
AND oi.batch_id NOTNULL
|
|
85
|
+
AND oi.product_id NOTNULL
|
|
86
|
+
AND oi.packing_type NOTNULL
|
|
87
|
+
AND oi.packing_size NOTNULL
|
|
88
|
+
AND oi.inventory_id IS NULL
|
|
89
|
+
GROUP BY
|
|
90
|
+
oi.domain_id,
|
|
91
|
+
oi.bizplace_id,
|
|
92
|
+
oi.batch_id,
|
|
93
|
+
oi.batch_id_ref,
|
|
94
|
+
oi.product_id,
|
|
95
|
+
oi.packing_type,
|
|
96
|
+
oi.packing_size,
|
|
97
|
+
oi.uom
|
|
98
|
+
)
|
|
99
|
+
-- SINGLE ITEM INVENTORY QUERY
|
|
100
|
+
select
|
|
101
|
+
i.domain_id as "domainId",
|
|
102
|
+
i.bizplace_id as "bizplaceId",
|
|
103
|
+
i.packing_type as "packingType",
|
|
104
|
+
i.packing_size as "packingSize",
|
|
105
|
+
i.uom,
|
|
106
|
+
i.product_id as "productId",
|
|
107
|
+
null as "productBundleId",
|
|
108
|
+
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) AS "remainQty",
|
|
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",
|
|
112
|
+
'SINGLE' AS "groupType"
|
|
113
|
+
FROM inventories i
|
|
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')
|
|
115
|
+
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
|
|
116
|
+
WHERE i.status = 'STORED'
|
|
117
|
+
GROUP by
|
|
118
|
+
i.domain_id,
|
|
119
|
+
i.bizplace_id,
|
|
120
|
+
i.product_id,
|
|
121
|
+
i.packing_type,
|
|
122
|
+
i.packing_size,
|
|
123
|
+
i.uom
|
|
124
|
+
union all
|
|
125
|
+
-- BUNDLE ITEM INVENTORY QUERY
|
|
126
|
+
SELECT
|
|
127
|
+
pbs.domain_id as "domainId",
|
|
128
|
+
pbs.bizplace_id as "bizplaceId",
|
|
129
|
+
pb.packing_type as "packingType",
|
|
130
|
+
pb.packing_size as "packingSize",
|
|
131
|
+
'UNIT' AS "uom",
|
|
132
|
+
null as "productId",
|
|
133
|
+
pb.id AS "productBundleId",
|
|
134
|
+
COALESCE(MIN(FLOOR(pbs."availableQty")),0) AS "remainQty",
|
|
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",
|
|
138
|
+
'BUNDLE' AS "groupType"
|
|
139
|
+
FROM product_bundles pb
|
|
140
|
+
INNER JOIN (
|
|
141
|
+
SELECT i.domain_id, i.bizplace_id, pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
142
|
+
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
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"
|
|
146
|
+
FROM product_bundle_settings pbs
|
|
147
|
+
LEFT JOIN inventories i ON i.product_id = pbs.product_id AND i.status = 'STORED'
|
|
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')
|
|
149
|
+
LEFT JOIN oi ON oi.product_id = i.product_id
|
|
150
|
+
GROUP by
|
|
151
|
+
i.domain_id,
|
|
152
|
+
i.bizplace_id,
|
|
153
|
+
pbs.product_id,
|
|
154
|
+
pbs.product_bundle_id
|
|
155
|
+
) pbs ON pbs.product_bundle_id = pb.id
|
|
156
|
+
GROUP BY
|
|
157
|
+
pbs.domain_id,
|
|
158
|
+
pbs.bizplace_id,
|
|
159
|
+
pb.packing_type,
|
|
160
|
+
pb.packing_size,
|
|
161
|
+
pb.name,
|
|
162
|
+
pb.sku,
|
|
163
|
+
pb.id
|
|
164
|
+
)
|
|
165
|
+
AS src
|
|
166
|
+
inner join domains d on d.id = src."domainId"
|
|
167
|
+
inner join bizplaces b on b.id = src."bizplaceId"
|
|
168
|
+
where src."remainQty" > 0
|
|
169
|
+
order by src."domainId"
|
|
170
|
+
`
|
|
171
|
+
})
|
|
172
|
+
], WarehouseBizplaceOnhandInventory);
|
|
173
|
+
exports.WarehouseBizplaceOnhandInventory = WarehouseBizplaceOnhandInventory;
|
|
174
|
+
//# sourceMappingURL=warehouse-bizplace-onhand-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.20",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/auth-base": "^4.3.
|
|
28
|
-
"@things-factory/biz-base": "^4.3.
|
|
29
|
-
"@things-factory/document-template-base": "^4.3.
|
|
30
|
-
"@things-factory/id-rule-base": "^4.3.
|
|
31
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
32
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
33
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
34
|
-
"@things-factory/integration-sftp": "^4.3.
|
|
35
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
36
|
-
"@things-factory/notification": "^4.3.
|
|
37
|
-
"@things-factory/sales-base": "^4.3.
|
|
38
|
-
"@things-factory/setting-base": "^4.3.
|
|
39
|
-
"@things-factory/shell": "^4.3.
|
|
40
|
-
"@things-factory/transport-base": "^4.3.
|
|
41
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
27
|
+
"@things-factory/auth-base": "^4.3.20",
|
|
28
|
+
"@things-factory/biz-base": "^4.3.20",
|
|
29
|
+
"@things-factory/document-template-base": "^4.3.20",
|
|
30
|
+
"@things-factory/id-rule-base": "^4.3.20",
|
|
31
|
+
"@things-factory/integration-lmd": "^4.3.20",
|
|
32
|
+
"@things-factory/integration-marketplace": "^4.3.20",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^4.3.20",
|
|
34
|
+
"@things-factory/integration-sftp": "^4.3.20",
|
|
35
|
+
"@things-factory/marketplace-base": "^4.3.20",
|
|
36
|
+
"@things-factory/notification": "^4.3.20",
|
|
37
|
+
"@things-factory/sales-base": "^4.3.20",
|
|
38
|
+
"@things-factory/setting-base": "^4.3.20",
|
|
39
|
+
"@things-factory/shell": "^4.3.20",
|
|
40
|
+
"@things-factory/transport-base": "^4.3.20",
|
|
41
|
+
"@things-factory/warehouse-base": "^4.3.20"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "2f86da10f36746b46428bc7408b586d0ec8aa793"
|
|
44
44
|
}
|
package/server/entities/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Worksheet } from './worksheet'
|
|
2
2
|
import { WorksheetDetail } from './worksheet-detail'
|
|
3
3
|
import { WorksheetMovement } from './worksheet-movement'
|
|
4
|
+
import { WarehouseBizplaceOnhandInventory } from './warehouse-bizplace-onhand-inventory'
|
|
4
5
|
|
|
5
|
-
export const entities = [Worksheet, WorksheetDetail, WorksheetMovement]
|
|
6
|
+
export const entities = [Worksheet, WorksheetDetail, WorksheetMovement, WarehouseBizplaceOnhandInventory]
|
|
6
7
|
|
|
7
8
|
export { Worksheet, WorksheetDetail, WorksheetMovement }
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { ViewColumn, ViewEntity } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
@ViewEntity({
|
|
4
|
+
expression: `
|
|
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
|
+
)
|
|
37
|
+
-- SINGLE ITEM INVENTORY QUERY
|
|
38
|
+
select
|
|
39
|
+
i.domain_id as "domainId",
|
|
40
|
+
i.bizplace_id as "bizplaceId",
|
|
41
|
+
i.packing_type as "packingType",
|
|
42
|
+
i.packing_size as "packingSize",
|
|
43
|
+
i.uom,
|
|
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",
|
|
48
|
+
COALESCE(sum(COALESCE(i.qty, 0::double precision))) AS "qty",
|
|
49
|
+
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "uomValue",
|
|
50
|
+
'SINGLE' AS "groupType"
|
|
51
|
+
FROM inventories i
|
|
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
|
|
54
|
+
WHERE i.status = 'STORED'
|
|
55
|
+
GROUP by
|
|
56
|
+
i.domain_id,
|
|
57
|
+
i.bizplace_id,
|
|
58
|
+
i.product_id,
|
|
59
|
+
i.packing_type,
|
|
60
|
+
i.packing_size,
|
|
61
|
+
i.uom
|
|
62
|
+
union all
|
|
63
|
+
-- BUNDLE ITEM INVENTORY QUERY
|
|
64
|
+
SELECT
|
|
65
|
+
pbs.domain_id as "domainId",
|
|
66
|
+
pbs.bizplace_id as "bizplaceId",
|
|
67
|
+
pb.packing_type as "packingType",
|
|
68
|
+
pb.packing_size as "packingSize",
|
|
69
|
+
'UNIT' AS "uom",
|
|
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",
|
|
74
|
+
COALESCE(MIN(FLOOR(pbs."qty")), 0::double precision) AS "qty",
|
|
75
|
+
COALESCE(MIN(FLOOR(pbs."uomValue")), 0::double precision) AS "uomValue",
|
|
76
|
+
'BUNDLE' AS "groupType"
|
|
77
|
+
FROM product_bundles pb
|
|
78
|
+
INNER JOIN (
|
|
79
|
+
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)) - 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",
|
|
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"
|
|
84
|
+
FROM product_bundle_settings pbs
|
|
85
|
+
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
|
|
88
|
+
GROUP by
|
|
89
|
+
i.domain_id,
|
|
90
|
+
i.bizplace_id,
|
|
91
|
+
pbs.product_id,
|
|
92
|
+
pbs.product_bundle_id
|
|
93
|
+
) pbs ON pbs.product_bundle_id = pb.id
|
|
94
|
+
GROUP BY
|
|
95
|
+
pbs.domain_id,
|
|
96
|
+
pbs.bizplace_id,
|
|
97
|
+
pb.packing_type,
|
|
98
|
+
pb.packing_size,
|
|
99
|
+
pb.name,
|
|
100
|
+
pb.sku,
|
|
101
|
+
pb.id
|
|
102
|
+
)
|
|
103
|
+
AS 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
|
|
107
|
+
order by src."domainId"
|
|
108
|
+
`
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
export class WarehouseBizplaceOnhandInventory {
|
|
112
|
+
@ViewColumn()
|
|
113
|
+
domainName: string
|
|
114
|
+
|
|
115
|
+
@ViewColumn()
|
|
116
|
+
bizplaceName: string
|
|
117
|
+
|
|
118
|
+
@ViewColumn()
|
|
119
|
+
domainId: string
|
|
120
|
+
|
|
121
|
+
@ViewColumn()
|
|
122
|
+
bizplaceId: string
|
|
123
|
+
|
|
124
|
+
@ViewColumn()
|
|
125
|
+
packingType: string
|
|
126
|
+
|
|
127
|
+
@ViewColumn()
|
|
128
|
+
packingSize: number
|
|
129
|
+
|
|
130
|
+
@ViewColumn()
|
|
131
|
+
uom: string
|
|
132
|
+
|
|
133
|
+
@ViewColumn()
|
|
134
|
+
productId: string
|
|
135
|
+
|
|
136
|
+
@ViewColumn()
|
|
137
|
+
productBundleId: string
|
|
138
|
+
|
|
139
|
+
@ViewColumn()
|
|
140
|
+
remainQty: number
|
|
141
|
+
|
|
142
|
+
@ViewColumn()
|
|
143
|
+
remainUomValue: number
|
|
144
|
+
|
|
145
|
+
@ViewColumn()
|
|
146
|
+
groupType: string
|
|
147
|
+
}
|