@things-factory/operato-hub 4.3.478 → 4.3.479
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/unstable/add-sales-invoice.js +7 -0
- package/dist-server/routers/api/restful-apis/unstable/add-sales-invoice.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.js +22 -22
- package/dist-server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.js.map +1 -1
- package/package.json +14 -14
- package/server/routers/api/restful-apis/unstable/add-sales-invoice.ts +14 -0
- package/server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.ts +34 -49
|
@@ -8,11 +8,17 @@ const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
|
8
8
|
const api_1 = require("@things-factory/api");
|
|
9
9
|
const business_middleware_1 = require("../../../../middlewares/business-middleware");
|
|
10
10
|
const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
|
|
11
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
11
12
|
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-sales-invoice');
|
|
12
13
|
api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/add-sales-invoice', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
|
|
13
14
|
var _a;
|
|
14
15
|
const { client, domain } = context.state;
|
|
15
16
|
const { t } = context;
|
|
17
|
+
const name = context.state.domain.name;
|
|
18
|
+
const request = {
|
|
19
|
+
query: context.query,
|
|
20
|
+
requestBody: context.request.body
|
|
21
|
+
};
|
|
16
22
|
let bodyReq = context.request.body;
|
|
17
23
|
if (typeof bodyReq === undefined || !((_a = Object.keys(bodyReq)) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
18
24
|
context.throw(400, t('error.invalid body request format'));
|
|
@@ -102,6 +108,7 @@ api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/add-sales-invoice'
|
|
|
102
108
|
context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { domain, type: 'api' }) })
|
|
103
109
|
})).data
|
|
104
110
|
};
|
|
111
|
+
(0, integration_base_1.createPayloadLog)(name, `/unstable/warehouse/:warehouseId/add-sales-invoice`, request, context.body, context, integration_base_1.PayloadType.INGESTION);
|
|
105
112
|
});
|
|
106
113
|
function checkMandatoryKey(context, params) {
|
|
107
114
|
let noparams = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-sales-invoice.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/add-sales-invoice.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAE7B,6CAAgE;AAEhE,qFAAgF;AAChF,uFAAkF;
|
|
1
|
+
{"version":3,"file":"add-sales-invoice.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/add-sales-invoice.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAE7B,6CAAgE;AAEhE,qFAAgF;AAChF,uFAAkF;AAClF,uEAAgF;AAEhF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mEAAmE,CAAC,CAAA;AAEnG,sBAAM,CAAC,IAAI,CACT,oDAAoD,EACpD,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACxC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA;IACtC,MAAM,OAAO,GAAG;QACd,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;KAClC,CAAA;IACD,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAElC,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S;gBAAE,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YAEnD,IAAI,CAAC,KAAK,CAAC,GAAG;gBAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAEvC,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM;gBACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QACzG,CAAC,CAAC,CAAA;KACH;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;KACjC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;AACH,CAAC;AAvBD,8CAuBC"}
|
|
@@ -137,32 +137,32 @@ async function draftReleaseGoodStatus(bizplaceId, draftReleaseGood) {
|
|
|
137
137
|
computedStatus = await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
138
138
|
tx.query(`
|
|
139
139
|
create temp table temp_op_calculation on commit drop as (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
select op.draft_release_good_id as id from warehouse_bizplace_onhand_inventories wboi
|
|
141
|
+
left join (
|
|
142
|
+
select op.draft_release_good_id, case when op.product_id is not null then op.product_id else op.product_bundle_id end as id , op.product_bundle_id, op.domain_id, op.bizplace_id, op.release_qty from order_products op
|
|
143
|
+
where op.domain_id = $1 and op.bizplace_id = $2
|
|
144
|
+
and op.draft_release_good_id = $3
|
|
145
|
+
) op on op.domain_id=wboi.domain_id and op.bizplace_id=wboi.bizplace_id
|
|
146
|
+
where wboi."domain_id"= $1 and
|
|
147
|
+
wboi."bizplace_id" = $2 and
|
|
148
|
+
wboi."product_id" = op.id or
|
|
149
|
+
wboi."product_bundle_id" = op.id AND wboi."remain_qty" >= op.release_qty limit 1
|
|
150
150
|
)
|
|
151
|
-
`, [bizplaceId]);
|
|
151
|
+
`, [draftReleaseGood.domainId, bizplaceId, draftReleaseGood.id]);
|
|
152
152
|
tx.query(`
|
|
153
153
|
create temp table temp_transfer_inv_calculation on commit drop as (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
select op.draft_release_good_id as id from warehouse_bizplace_onhand_inventories wboi
|
|
155
|
+
left join (
|
|
156
|
+
select op.draft_release_good_id, case when op.product_id is not null then op.product_id else op.product_bundle_id end as id , op.product_bundle_id, op.domain_id, op.bizplace_id from order_products op
|
|
157
|
+
where op.domain_id = $1 and op.bizplace_id = $2
|
|
158
|
+
and op.draft_release_good_id = $3
|
|
159
|
+
) op on op.domain_id=wboi.domain_id and op.bizplace_id=wboi.bizplace_id
|
|
160
|
+
where wboi."domain_id"= $1 and
|
|
161
|
+
wboi."bizplace_id" = $2 and
|
|
162
|
+
wboi."product_id" = op.id or
|
|
163
|
+
wboi."product_bundle_id" = op.id AND wboi."transfer_qty" > 0 limit 1
|
|
164
164
|
)
|
|
165
|
-
`, [bizplaceId]);
|
|
165
|
+
`, [draftReleaseGood.domainId, bizplaceId, draftReleaseGood.id]);
|
|
166
166
|
const qb = tx.getRepository(sales_base_1.DraftReleaseGood).createQueryBuilder('drg');
|
|
167
167
|
qb.addSelect(`CASE WHEN "drg".status = 'DRAFT' and (tmp_calc.id IS NOT null and tmp_transfer.id IS null) then 'INSUFFICIENT'
|
|
168
168
|
WHEN "drg".status = 'DRAFT' and (tmp_calc.id IS null and tmp_transfer.id IS NOT null) then 'TRANSFER'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-draft-order-list.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,
|
|
1
|
+
{"version":3,"file":"get-draft-order-list.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/warehouse/get-draft-order-list.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,qCAAkG;AAElG,6CAAgE;AAEhE,2DAAwG;AAExG,gDAA4F;AAC5F,oDAAyF;AAGzF,sBAAM,CAAC,GAAG,CACR,oCAAoC,EACpC,gCAAkB,EAClB,kCAAoB,EACpB,+BAAiB,EACjB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,IAAI;QACF,uCAAuC;QACvC,kCAAkC;QAClC,IAAI,MAAM,qBAAQ,OAAO,CAAC,KAAK,CAAE,CAAA;QACjC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;QAClD,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QACzC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAA;QAE3B,IAAI,gBAAC,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA;YACvC,OAAO,MAAM,CAAC,cAAc,CAAC,CAAA;SAC9B;QAED,IAAI,gBAAC,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE;YAC5B,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;YACnC,OAAO,MAAM,CAAC,SAAS,CAAC,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AC,eAAe,KAAI,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAa,0CAAE,EAAE,CAAA,IAAI,CAAC,CAAC,SAAS,KAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,eAAe,CAAA,CAAA,EAAA,CAC1G,CAAA;QAED,OAAO,CAAC,MAAM,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,WAAW;YAC3C,CAAC,CAAC,uCAA0B,CAAC,QAAQ;YACrC,CAAC,CAAC,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,SAAS,KAAI,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU;gBAC7D,CAAC,CAAC,uCAA0B,CAAC,YAAY;gBACzC,CAAC,CAAC,uCAA0B,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC;AAvCD,gDAuCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.479",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -77,22 +77,22 @@
|
|
|
77
77
|
"@things-factory/i18n-base": "^4.3.434",
|
|
78
78
|
"@things-factory/import-ui": "^4.3.434",
|
|
79
79
|
"@things-factory/import-ui-excel": "^4.3.434",
|
|
80
|
-
"@things-factory/integration-accounting": "^4.3.
|
|
81
|
-
"@things-factory/integration-fulfillment": "^4.3.
|
|
82
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
83
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
84
|
-
"@things-factory/integration-pos": "^4.3.
|
|
85
|
-
"@things-factory/integration-powrup": "^4.3.
|
|
86
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
87
|
-
"@things-factory/integration-sftp": "^4.3.
|
|
80
|
+
"@things-factory/integration-accounting": "^4.3.479",
|
|
81
|
+
"@things-factory/integration-fulfillment": "^4.3.479",
|
|
82
|
+
"@things-factory/integration-lmd": "^4.3.479",
|
|
83
|
+
"@things-factory/integration-marketplace": "^4.3.479",
|
|
84
|
+
"@things-factory/integration-pos": "^4.3.479",
|
|
85
|
+
"@things-factory/integration-powrup": "^4.3.479",
|
|
86
|
+
"@things-factory/integration-sellercraft": "^4.3.479",
|
|
87
|
+
"@things-factory/integration-sftp": "^4.3.479",
|
|
88
88
|
"@things-factory/lite-menu": "^4.3.452",
|
|
89
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
89
|
+
"@things-factory/marketplace-base": "^4.3.479",
|
|
90
90
|
"@things-factory/more-ui": "^4.3.434",
|
|
91
91
|
"@things-factory/notification": "^4.3.452",
|
|
92
92
|
"@things-factory/pdf": "^4.3.381",
|
|
93
93
|
"@things-factory/product-ui": "^4.3.452",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.452",
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
+
"@things-factory/sales-base": "^4.3.479",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.381",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.381",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.381",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"@things-factory/shell": "^4.3.434",
|
|
109
109
|
"@things-factory/system-ui": "^4.3.434",
|
|
110
110
|
"@things-factory/transport-base": "^4.3.452",
|
|
111
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
112
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
111
|
+
"@things-factory/warehouse-base": "^4.3.479",
|
|
112
|
+
"@things-factory/worksheet-base": "^4.3.479",
|
|
113
113
|
"cron-parser": "^4.7.0",
|
|
114
114
|
"koa2-swagger-ui": "^5.0.2",
|
|
115
115
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"resolutions": {
|
|
122
122
|
"core-js": "^3.16.0"
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "83e6a29b1188681cd3a9404891ec07d497c28035"
|
|
125
125
|
}
|
|
@@ -4,6 +4,7 @@ import { restfulApiRouter as router } from '@things-factory/api'
|
|
|
4
4
|
|
|
5
5
|
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
6
6
|
import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
|
|
7
|
+
import { createPayloadLog, PayloadType } from '@things-factory/integration-base'
|
|
7
8
|
|
|
8
9
|
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-sales-invoice')
|
|
9
10
|
|
|
@@ -14,6 +15,11 @@ router.post(
|
|
|
14
15
|
async (context, next) => {
|
|
15
16
|
const { client, domain } = context.state
|
|
16
17
|
const { t } = context
|
|
18
|
+
const name = context.state.domain.name
|
|
19
|
+
const request = {
|
|
20
|
+
query: context.query,
|
|
21
|
+
requestBody: context.request.body
|
|
22
|
+
}
|
|
17
23
|
let bodyReq = context.request.body
|
|
18
24
|
|
|
19
25
|
if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
|
|
@@ -115,6 +121,14 @@ router.post(
|
|
|
115
121
|
} as any)
|
|
116
122
|
).data
|
|
117
123
|
}
|
|
124
|
+
createPayloadLog(
|
|
125
|
+
name,
|
|
126
|
+
`/unstable/warehouse/:warehouseId/add-sales-invoice`,
|
|
127
|
+
request,
|
|
128
|
+
context.body,
|
|
129
|
+
context,
|
|
130
|
+
PayloadType.INGESTION
|
|
131
|
+
)
|
|
118
132
|
}
|
|
119
133
|
)
|
|
120
134
|
|
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
-
import {
|
|
3
|
-
Between,
|
|
4
|
-
EntityManager,
|
|
5
|
-
getConnection,
|
|
6
|
-
getRepository,
|
|
7
|
-
SelectQueryBuilder
|
|
8
|
-
} from 'typeorm'
|
|
2
|
+
import { Between, EntityManager, getConnection, getRepository, SelectQueryBuilder } from 'typeorm'
|
|
9
3
|
|
|
10
4
|
import { restfulApiRouter as router } from '@things-factory/api'
|
|
11
5
|
import { Bizplace } from '@things-factory/biz-base'
|
|
12
|
-
import {
|
|
13
|
-
DRAFT_RELEASE_ORDER_STATUS,
|
|
14
|
-
DraftReleaseGood,
|
|
15
|
-
InventoryUtil
|
|
16
|
-
} from '@things-factory/sales-base'
|
|
6
|
+
import { DRAFT_RELEASE_ORDER_STATUS, DraftReleaseGood, InventoryUtil } from '@things-factory/sales-base'
|
|
17
7
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
validationMiddleware
|
|
22
|
-
} from '../middlewares'
|
|
23
|
-
import {
|
|
24
|
-
ApiError,
|
|
25
|
-
ApiErrorHandler,
|
|
26
|
-
throwInternalServerError
|
|
27
|
-
} from '../utils/error-util'
|
|
8
|
+
import { businessMiddleware, loggingMiddleware, validationMiddleware } from '../middlewares'
|
|
9
|
+
import { ApiError, ApiErrorHandler, throwInternalServerError } from '../utils/error-util'
|
|
10
|
+
import { companyRolesByScopeResolver } from 'server/graphql/resolvers/oauth2/company-roles-by-scope'
|
|
28
11
|
|
|
29
12
|
router.get(
|
|
30
13
|
'/v1/warehouse/get-draft-order-list',
|
|
@@ -118,9 +101,9 @@ router.get(
|
|
|
118
101
|
status: await draftReleaseGoodStatus(draftReleaseGood.bizplace.id, draftReleaseGood),
|
|
119
102
|
releaseGood: draftReleaseGood.releaseGood
|
|
120
103
|
? {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
104
|
+
id: draftReleaseGood.releaseGood[0]?.id,
|
|
105
|
+
name: draftReleaseGood.releaseGood[0]?.name
|
|
106
|
+
}
|
|
124
107
|
: null,
|
|
125
108
|
billTo: {
|
|
126
109
|
billingAddress: draftReleaseGood.billingAddress
|
|
@@ -160,42 +143,44 @@ router.get(
|
|
|
160
143
|
)
|
|
161
144
|
|
|
162
145
|
export async function draftReleaseGoodStatus(bizplaceId, draftReleaseGood) {
|
|
146
|
+
|
|
163
147
|
let computedStatus
|
|
148
|
+
|
|
164
149
|
computedStatus = await getConnection().transaction(async (tx: EntityManager) => {
|
|
165
150
|
tx.query(
|
|
166
151
|
`
|
|
167
152
|
create temp table temp_op_calculation on commit drop as (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
153
|
+
select op.draft_release_good_id as id from warehouse_bizplace_onhand_inventories wboi
|
|
154
|
+
left join (
|
|
155
|
+
select op.draft_release_good_id, case when op.product_id is not null then op.product_id else op.product_bundle_id end as id , op.product_bundle_id, op.domain_id, op.bizplace_id, op.release_qty from order_products op
|
|
156
|
+
where op.domain_id = $1 and op.bizplace_id = $2
|
|
157
|
+
and op.draft_release_good_id = $3
|
|
158
|
+
) op on op.domain_id=wboi.domain_id and op.bizplace_id=wboi.bizplace_id
|
|
159
|
+
where wboi."domain_id"= $1 and
|
|
160
|
+
wboi."bizplace_id" = $2 and
|
|
161
|
+
wboi."product_id" = op.id or
|
|
162
|
+
wboi."product_bundle_id" = op.id AND wboi."remain_qty" >= op.release_qty limit 1
|
|
178
163
|
)
|
|
179
164
|
`,
|
|
180
|
-
[bizplaceId]
|
|
165
|
+
[draftReleaseGood.domainId, bizplaceId, draftReleaseGood.id]
|
|
181
166
|
)
|
|
182
167
|
|
|
183
168
|
tx.query(
|
|
184
169
|
`
|
|
185
170
|
create temp table temp_transfer_inv_calculation on commit drop as (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
171
|
+
select op.draft_release_good_id as id from warehouse_bizplace_onhand_inventories wboi
|
|
172
|
+
left join (
|
|
173
|
+
select op.draft_release_good_id, case when op.product_id is not null then op.product_id else op.product_bundle_id end as id , op.product_bundle_id, op.domain_id, op.bizplace_id from order_products op
|
|
174
|
+
where op.domain_id = $1 and op.bizplace_id = $2
|
|
175
|
+
and op.draft_release_good_id = $3
|
|
176
|
+
) op on op.domain_id=wboi.domain_id and op.bizplace_id=wboi.bizplace_id
|
|
177
|
+
where wboi."domain_id"= $1 and
|
|
178
|
+
wboi."bizplace_id" = $2 and
|
|
179
|
+
wboi."product_id" = op.id or
|
|
180
|
+
wboi."product_bundle_id" = op.id AND wboi."transfer_qty" > 0 limit 1
|
|
196
181
|
)
|
|
197
182
|
`,
|
|
198
|
-
[bizplaceId]
|
|
183
|
+
[draftReleaseGood.domainId, bizplaceId, draftReleaseGood.id]
|
|
199
184
|
)
|
|
200
185
|
|
|
201
186
|
const qb: SelectQueryBuilder<DraftReleaseGood> = tx.getRepository(DraftReleaseGood).createQueryBuilder('drg')
|
|
@@ -251,8 +236,8 @@ export async function orderProductStatus(orderProduct, draftReleaseGood) {
|
|
|
251
236
|
return (status = foundProductInv?.transferQty
|
|
252
237
|
? DRAFT_RELEASE_ORDER_STATUS.TRANSFER
|
|
253
238
|
: (foundProductInv?.remainQty || 0) < orderProduct.releaseQty
|
|
254
|
-
|
|
255
|
-
|
|
239
|
+
? DRAFT_RELEASE_ORDER_STATUS.INSUFFICIENT
|
|
240
|
+
: DRAFT_RELEASE_ORDER_STATUS.DRAFT)
|
|
256
241
|
})
|
|
257
242
|
return status
|
|
258
243
|
}
|