@things-factory/sales-base 4.2.12 → 4.3.0
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/constants/attachment-type.js +2 -1
- package/dist-server/constants/attachment-type.js.map +1 -1
- package/dist-server/constants/index.js +1 -0
- package/dist-server/constants/index.js.map +1 -1
- package/dist-server/constants/order.js +12 -3
- package/dist-server/constants/order.js.map +1 -1
- package/dist-server/constants/release-good.js +9 -0
- package/dist-server/constants/release-good.js.map +1 -0
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +501 -0
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -0
- package/dist-server/service/draft-release-good/draft-release-good-query.js +289 -0
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -0
- package/dist-server/service/draft-release-good/draft-release-good-type.js +364 -0
- package/dist-server/service/draft-release-good/draft-release-good-type.js.map +1 -0
- package/dist-server/service/draft-release-good/draft-release-good.js +321 -0
- package/dist-server/service/draft-release-good/draft-release-good.js.map +1 -0
- package/dist-server/service/draft-release-good/index.js +21 -0
- package/dist-server/service/draft-release-good/index.js.map +1 -0
- package/dist-server/service/index.js +47 -19
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +38 -1
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +9 -1
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +5 -1
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +13 -13
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-product/order-product.js +39 -4
- package/dist-server/service/order-product/order-product.js.map +1 -1
- package/dist-server/service/order-tote/index.js +21 -0
- package/dist-server/service/order-tote/index.js.map +1 -0
- package/dist-server/service/order-tote/order-tote-mutation.js +56 -0
- package/dist-server/service/order-tote/order-tote-mutation.js.map +1 -0
- package/dist-server/service/order-tote/order-tote-query.js +123 -0
- package/dist-server/service/order-tote/order-tote-query.js.map +1 -0
- package/dist-server/service/order-tote/order-tote-types.js +79 -0
- package/dist-server/service/order-tote/order-tote-types.js.map +1 -0
- package/dist-server/service/order-tote/order-tote.js +91 -0
- package/dist-server/service/order-tote/order-tote.js.map +1 -0
- package/dist-server/service/order-tote-item/index.js +21 -0
- package/dist-server/service/order-tote-item/index.js.map +1 -0
- package/dist-server/service/order-tote-item/order-tote-item-mutation.js +56 -0
- package/dist-server/service/order-tote-item/order-tote-item-mutation.js.map +1 -0
- package/dist-server/service/order-tote-item/order-tote-item-query.js +100 -0
- package/dist-server/service/order-tote-item/order-tote-item-query.js.map +1 -0
- package/dist-server/service/order-tote-item/order-tote-item-types.js +91 -0
- package/dist-server/service/order-tote-item/order-tote-item-types.js.map +1 -0
- package/dist-server/service/order-tote-item/order-tote-item.js +104 -0
- package/dist-server/service/order-tote-item/order-tote-item.js.map +1 -0
- package/dist-server/service/order-tote-seal/index.js +21 -0
- package/dist-server/service/order-tote-seal/index.js.map +1 -0
- package/dist-server/service/order-tote-seal/order-tote-seal-mutation.js +56 -0
- package/dist-server/service/order-tote-seal/order-tote-seal-mutation.js.map +1 -0
- package/dist-server/service/order-tote-seal/order-tote-seal-query.js +97 -0
- package/dist-server/service/order-tote-seal/order-tote-seal-query.js.map +1 -0
- package/dist-server/service/order-tote-seal/order-tote-seal-types.js +71 -0
- package/dist-server/service/order-tote-seal/order-tote-seal-types.js.map +1 -0
- package/dist-server/service/order-tote-seal/order-tote-seal.js +71 -0
- package/dist-server/service/order-tote-seal/order-tote-seal.js.map +1 -0
- package/dist-server/service/others/other-query.js +37 -2
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +23 -1
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +28 -2
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +32 -12
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/utils/inventory-util.js +258 -99
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/dist-server/utils/order-no-generator.js +7 -0
- package/dist-server/utils/order-no-generator.js.map +1 -1
- package/package.json +13 -13
- package/server/constants/attachment-type.ts +2 -1
- package/server/constants/index.ts +1 -0
- package/server/constants/order.ts +12 -2
- package/server/constants/release-good.ts +6 -0
- package/server/service/draft-release-good/draft-release-good-mutation.ts +671 -0
- package/server/service/draft-release-good/draft-release-good-query.ts +314 -0
- package/server/service/draft-release-good/draft-release-good-type.ts +261 -0
- package/server/service/draft-release-good/draft-release-good.ts +270 -0
- package/server/service/draft-release-good/index.ts +9 -0
- package/server/service/index.ts +51 -21
- package/server/service/order-inventory/order-inventory-query.ts +40 -2
- package/server/service/order-inventory/order-inventory-types.ts +6 -0
- package/server/service/order-inventory/order-inventory.ts +5 -5
- package/server/service/order-product/order-product-types.ts +5 -3
- package/server/service/order-product/order-product.ts +30 -3
- package/server/service/order-tote/index.ts +9 -0
- package/server/service/order-tote/order-tote-mutation.ts +30 -0
- package/server/service/order-tote/order-tote-query.ts +114 -0
- package/server/service/order-tote/order-tote-types.ts +47 -0
- package/server/service/order-tote/order-tote.ts +62 -0
- package/server/service/order-tote-item/index.ts +9 -0
- package/server/service/order-tote-item/order-tote-item-mutation.ts +30 -0
- package/server/service/order-tote-item/order-tote-item-query.ts +88 -0
- package/server/service/order-tote-item/order-tote-item-types.ts +56 -0
- package/server/service/order-tote-item/order-tote-item.ts +72 -0
- package/server/service/order-tote-seal/index.ts +9 -0
- package/server/service/order-tote-seal/order-tote-seal-mutation.ts +30 -0
- package/server/service/order-tote-seal/order-tote-seal-query.ts +60 -0
- package/server/service/order-tote-seal/order-tote-seal-types.ts +41 -0
- package/server/service/order-tote-seal/order-tote-seal.ts +46 -0
- package/server/service/others/other-query.ts +43 -8
- package/server/service/release-good/release-good-mutation.ts +24 -2
- package/server/service/release-good/release-good-query.ts +57 -30
- package/server/service/release-good/release-good.ts +28 -9
- package/server/utils/inventory-util.ts +287 -106
- package/server/utils/order-no-generator.ts +42 -48
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-type.js","sourceRoot":"","sources":["../../server/constants/attachment-type.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,SAAS,EAAE,WAAW;IACtB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;IACR,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"attachment-type.js","sourceRoot":"","sources":["../../server/constants/attachment-type.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,SAAS,EAAE,WAAW;IACtB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;IACR,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,IAAI,EAAE,WAAW;CAClB,CAAA"}
|
|
@@ -16,4 +16,5 @@ __exportStar(require("./product-group-type"), exports);
|
|
|
16
16
|
__exportStar(require("./order"), exports);
|
|
17
17
|
__exportStar(require("./vas-target-type"), exports);
|
|
18
18
|
__exportStar(require("./transfer-order-type"), exports);
|
|
19
|
+
__exportStar(require("./release-good"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,8CAA2B;AAC3B,uDAAoC;AACpC,0CAAuB;AACvB,oDAAiC;AACjC,wDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,8CAA2B;AAC3B,uDAAoC;AACpC,0CAAuB;AACvB,oDAAiC;AACjC,wDAAqC;AACrC,iDAA8B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PURCHASE_ORDER_STATUS = exports.ORDER_NUMBER_RULE_TYPE = exports.ORDER_NUMBER_SETTING_KEY = exports.GRN_STATUS = exports.ORDER_TYPES = exports.ORDER_VAS_STATUS = exports.ORDER_INVENTORY_STATUS = exports.ORDER_PRODUCT_STATUS = exports.ORDER_INVENTORY_TYPE = exports.MANIFEST_STATUS = exports.DISPATCHMENT_STATUS = exports.ORDER_STATUS = void 0;
|
|
3
|
+
exports.DRAFT_RELEASE_ORDER_STATUS = exports.PURCHASE_ORDER_STATUS = exports.ORDER_NUMBER_RULE_TYPE = exports.ORDER_NUMBER_SETTING_KEY = exports.GRN_STATUS = exports.ORDER_TYPES = exports.ORDER_VAS_STATUS = exports.ORDER_INVENTORY_STATUS = exports.ORDER_PRODUCT_STATUS = exports.ORDER_INVENTORY_TYPE = exports.MANIFEST_STATUS = exports.DISPATCHMENT_STATUS = exports.ORDER_STATUS = void 0;
|
|
4
4
|
exports.ORDER_STATUS = {
|
|
5
5
|
DRAFT: 'DRAFT',
|
|
6
6
|
PENDING: 'PENDING',
|
|
@@ -144,6 +144,7 @@ exports.ORDER_TYPES = {
|
|
|
144
144
|
DELIVERY: 'DELIVERY',
|
|
145
145
|
COLLECTION: 'COLLECTION',
|
|
146
146
|
RELEASE_OF_GOODS: 'RELEASE_OF_GOODS',
|
|
147
|
+
DRAFT_RELEASE_GOODS: 'DRAFT_RELEASE_GOODS',
|
|
147
148
|
VAS_ORDER: 'VAS_ORDER',
|
|
148
149
|
CYCLE_COUNT: 'CYCLE_COUNT',
|
|
149
150
|
STOCK_TAKE: 'STOCK_TAKE',
|
|
@@ -162,7 +163,8 @@ exports.ORDER_NUMBER_SETTING_KEY = {
|
|
|
162
163
|
RO_NUMBER_RULE: 'ro-number-rule',
|
|
163
164
|
DO_NUMBER_RULE: 'do-number-rule',
|
|
164
165
|
RR_NUMBER_RULE: 'rr-number-rule',
|
|
165
|
-
TO_NUMBER_RULE: 'to-number-rule'
|
|
166
|
+
TO_NUMBER_RULE: 'to-number-rule',
|
|
167
|
+
DRO_NUMBER_RULE: 'dro-number-rule'
|
|
166
168
|
};
|
|
167
169
|
exports.ORDER_NUMBER_RULE_TYPE = {
|
|
168
170
|
GAN_NUMBER: 'gan_number',
|
|
@@ -171,7 +173,8 @@ exports.ORDER_NUMBER_RULE_TYPE = {
|
|
|
171
173
|
RO_NUMBER: 'ro_number',
|
|
172
174
|
DO_NUMBER: 'do_number',
|
|
173
175
|
RR_NUMBER: 'rr_number',
|
|
174
|
-
TO_NUMBER: 'to_number'
|
|
176
|
+
TO_NUMBER: 'to_number',
|
|
177
|
+
DRO_NUMBER: 'dro_number'
|
|
175
178
|
};
|
|
176
179
|
exports.PURCHASE_ORDER_STATUS = {
|
|
177
180
|
DRAFT: 'DRAFT',
|
|
@@ -180,4 +183,10 @@ exports.PURCHASE_ORDER_STATUS = {
|
|
|
180
183
|
REJECTED: 'REJECTED',
|
|
181
184
|
COMPLETED: 'COMPLETED'
|
|
182
185
|
};
|
|
186
|
+
exports.DRAFT_RELEASE_ORDER_STATUS = {
|
|
187
|
+
DRAFT: 'DRAFT',
|
|
188
|
+
INSUFFICIENT: 'INSUFFICIENT',
|
|
189
|
+
SUBMITTED: 'SUBMITTED',
|
|
190
|
+
CANCELLED: 'CANCELLED'
|
|
191
|
+
};
|
|
183
192
|
//# sourceMappingURL=order.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../server/constants/order.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAA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exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReleaseOrderType = void 0;
|
|
4
|
+
var ReleaseOrderType;
|
|
5
|
+
(function (ReleaseOrderType) {
|
|
6
|
+
ReleaseOrderType["B2B"] = "b2b";
|
|
7
|
+
ReleaseOrderType["B2C"] = "b2c";
|
|
8
|
+
})(ReleaseOrderType = exports.ReleaseOrderType || (exports.ReleaseOrderType = {}));
|
|
9
|
+
//# sourceMappingURL=release-good.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-good.js","sourceRoot":"","sources":["../../server/constants/release-good.ts"],"names":[],"mappings":";;;AAEA,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+BAAW,CAAA;IACX,+BAAW,CAAA;AACf,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B"}
|
|
@@ -0,0 +1,501 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.upsertDraftReleaseGoodProducts = exports.updateDraftReleaseGoodFunction = exports.createDraftReleaseGoodFunction = exports.upsertDraftReleaseGoodFunction = exports.DraftReleaseGoodMutation = void 0;
|
|
16
|
+
const graphql_upload_1 = require("graphql-upload");
|
|
17
|
+
const type_graphql_1 = require("type-graphql");
|
|
18
|
+
const typeorm_1 = require("typeorm");
|
|
19
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
20
|
+
const utils_1 = require("../../utils");
|
|
21
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
22
|
+
const id_rule_base_1 = require("@things-factory/id-rule-base");
|
|
23
|
+
const product_base_1 = require("@things-factory/product-base");
|
|
24
|
+
const setting_base_1 = require("@things-factory/setting-base");
|
|
25
|
+
// import { Location } from '@things-factory/warehouse-base'
|
|
26
|
+
const __1 = require("../");
|
|
27
|
+
const constants_1 = require("../../constants");
|
|
28
|
+
const utils_2 = require("../../utils");
|
|
29
|
+
const order_product_types_1 = require("../order-product/order-product-types");
|
|
30
|
+
const shipping_order_1 = require("../shipping-order/shipping-order");
|
|
31
|
+
const shipping_order_types_1 = require("../shipping-order/shipping-order-types");
|
|
32
|
+
// import {
|
|
33
|
+
// checkArrivedNoticeFunction,
|
|
34
|
+
// confirmArrivalNoticeFunction,
|
|
35
|
+
// generateArrivalNoticeFunction,
|
|
36
|
+
// receiveArrivalNoticeFunction
|
|
37
|
+
// } from '../arrival-notice/arrival-notice-mutation'
|
|
38
|
+
const draft_release_good_query_1 = require("./draft-release-good-query");
|
|
39
|
+
const release_good_query_1 = require("../release-good/release-good-query");
|
|
40
|
+
const release_good_mutation_1 = require("../release-good/release-good-mutation");
|
|
41
|
+
const errors_1 = require("../../errors");
|
|
42
|
+
let DraftReleaseGoodMutation = class DraftReleaseGoodMutation {
|
|
43
|
+
async upsertDraftReleaseGood(context, draftReleaseGood, orderProducts, files, shippingOrder) {
|
|
44
|
+
try {
|
|
45
|
+
const { tx } = context.state;
|
|
46
|
+
const createdDraftReleaseGood = await upsertDraftReleaseGoodFunction(null, draftReleaseGood, orderProducts, shippingOrder, files, context, tx);
|
|
47
|
+
return createdDraftReleaseGood;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async createDraftReleaseGood(draftReleaseGood, context) {
|
|
54
|
+
const { domain, user, tx } = context.state;
|
|
55
|
+
let drg = await tx.getRepository(__1.DraftReleaseGood).save(Object.assign(Object.assign({}, draftReleaseGood), { domain, status: 'INSUFFICIENT', creator: user, updater: user }));
|
|
56
|
+
// add order products
|
|
57
|
+
return drg;
|
|
58
|
+
}
|
|
59
|
+
async updateDraftReleaseGood(id, patch, context) {
|
|
60
|
+
const { domain, user, tx } = context.state;
|
|
61
|
+
const repository = tx.getRepository(__1.DraftReleaseGood);
|
|
62
|
+
const draftReleaseGood = await repository.findOne({
|
|
63
|
+
where: { domain, id }
|
|
64
|
+
});
|
|
65
|
+
return await repository.save(Object.assign(Object.assign(Object.assign({}, draftReleaseGood), patch), { updater: user }));
|
|
66
|
+
}
|
|
67
|
+
async updateMultipleDraftReleaseGood(patches, context) {
|
|
68
|
+
const { domain, user, tx } = context.state;
|
|
69
|
+
let results = [];
|
|
70
|
+
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
71
|
+
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
72
|
+
const draftReleaseGoodRepo = tx.getRepository(__1.DraftReleaseGood);
|
|
73
|
+
if (_createRecords.length > 0) {
|
|
74
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
75
|
+
const newRecord = _createRecords[i];
|
|
76
|
+
const result = await draftReleaseGoodRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
77
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (_updateRecords.length > 0) {
|
|
81
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
82
|
+
const newRecord = _updateRecords[i];
|
|
83
|
+
const draftReleaseGood = await draftReleaseGoodRepo.findOne(newRecord.id);
|
|
84
|
+
const result = await draftReleaseGoodRepo.save(Object.assign(Object.assign(Object.assign({}, draftReleaseGood), newRecord), { updater: user }));
|
|
85
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return results;
|
|
89
|
+
}
|
|
90
|
+
async deleteDraftReleaseGood(id, context) {
|
|
91
|
+
const { domain, tx } = context.state;
|
|
92
|
+
await tx.getRepository(__1.DraftReleaseGood).delete({ domain, id });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
async deleteDraftReleaseGoods(ids, context) {
|
|
96
|
+
const { domain, tx } = context.state;
|
|
97
|
+
await tx.getRepository(__1.DraftReleaseGood).delete({
|
|
98
|
+
domain,
|
|
99
|
+
id: (0, typeorm_1.In)(ids)
|
|
100
|
+
});
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
async generateReleaseGoodsFromDraft(context, ids) {
|
|
104
|
+
var _a;
|
|
105
|
+
const { domain, user, tx } = context.state;
|
|
106
|
+
const updatableDraftOrders = await tx.getRepository(__1.DraftReleaseGood).find({
|
|
107
|
+
where: {
|
|
108
|
+
domain,
|
|
109
|
+
id: (0, typeorm_1.In)(ids),
|
|
110
|
+
status: constants_1.DRAFT_RELEASE_ORDER_STATUS.DRAFT
|
|
111
|
+
},
|
|
112
|
+
relations: [
|
|
113
|
+
'orderProducts',
|
|
114
|
+
'orderProducts.product',
|
|
115
|
+
'orderProducts.productBundle',
|
|
116
|
+
'shippingOrder',
|
|
117
|
+
'bizplace',
|
|
118
|
+
'domain',
|
|
119
|
+
'creator',
|
|
120
|
+
'updater'
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
if (updatableDraftOrders.length > 0) {
|
|
124
|
+
let createdReleaseGoods = [];
|
|
125
|
+
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
126
|
+
const roNoSetting = await settingRepo.findOne({
|
|
127
|
+
where: {
|
|
128
|
+
domain,
|
|
129
|
+
name: constants_1.ORDER_NUMBER_SETTING_KEY.RO_NUMBER_RULE
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
for (let index = 0; index < updatableDraftOrders.length; index++) {
|
|
133
|
+
const draftOrder = updatableDraftOrders[index];
|
|
134
|
+
let foundPermittedBizplace;
|
|
135
|
+
let companyBizplace;
|
|
136
|
+
if ((_a = draftOrder === null || draftOrder === void 0 ? void 0 : draftOrder.bizplace) === null || _a === void 0 ? void 0 : _a.id) {
|
|
137
|
+
foundPermittedBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne(draftOrder.bizplace.id, {
|
|
138
|
+
relations: ['company', 'company.domain']
|
|
139
|
+
});
|
|
140
|
+
const companyDomain = foundPermittedBizplace.company.domain;
|
|
141
|
+
companyBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({ where: { domain: companyDomain } });
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const bizplaces = [foundPermittedBizplace, companyBizplace];
|
|
147
|
+
let productInventory = await utils_1.InventoryUtil.bizplaceProductInventory(bizplaces, {
|
|
148
|
+
filters: [{
|
|
149
|
+
name: 'productId',
|
|
150
|
+
operator: 'in',
|
|
151
|
+
value: [
|
|
152
|
+
...draftOrder.orderProducts.filter(itm => itm === null || itm === void 0 ? void 0 : itm.product).map(itm => { return itm.product.id; }),
|
|
153
|
+
...draftOrder.orderProducts.filter(itm => itm === null || itm === void 0 ? void 0 : itm.productBundle).map(itm => { return itm.productBundle.id; })
|
|
154
|
+
]
|
|
155
|
+
}]
|
|
156
|
+
}, context, tx);
|
|
157
|
+
draftOrder.orderProducts = draftOrder.orderProducts.map(itm => {
|
|
158
|
+
let foundProductInv = productInventory.items.find(i => { var _a, _b; return (i.productId == ((_a = itm === null || itm === void 0 ? void 0 : itm.product) === null || _a === void 0 ? void 0 : _a.id) || i.productId == ((_b = itm === null || itm === void 0 ? void 0 : itm.productBundle) === null || _b === void 0 ? void 0 : _b.id)) && i.packingType == itm.packingType && i.packingSize == itm.packingSize && i.uom == itm.uom && itm.releaseQty <= i.remainQty; });
|
|
159
|
+
return Object.assign(Object.assign({}, itm), { status: foundProductInv ? 'suffice' : 'insufficient' });
|
|
160
|
+
});
|
|
161
|
+
let insufficient = draftOrder.orderProducts.find(op => op.status == 'insufficient');
|
|
162
|
+
if (!insufficient) {
|
|
163
|
+
//create RO
|
|
164
|
+
let releaseGood = Object.assign({}, draftOrder);
|
|
165
|
+
delete releaseGood.id;
|
|
166
|
+
delete releaseGood.name;
|
|
167
|
+
delete releaseGood.createdAt;
|
|
168
|
+
delete releaseGood.createdBy;
|
|
169
|
+
delete releaseGood.updatedAt;
|
|
170
|
+
delete releaseGood.updatedBy;
|
|
171
|
+
let orderInventories = [];
|
|
172
|
+
for (let index = 0; index < draftOrder.orderProducts.length; index++) {
|
|
173
|
+
const itm = draftOrder.orderProducts[index];
|
|
174
|
+
let data = [];
|
|
175
|
+
if (itm.productBundle) {
|
|
176
|
+
let bundle = await tx.getRepository(product_base_1.ProductBundle).findOne({ where: { id: itm.productBundle.id }, relations: ['productBundleSettings', 'productBundleSettings.productDetail', 'productBundleSettings.product',] });
|
|
177
|
+
for (let index2 = 0; index2 < bundle.productBundleSettings.length; index2++) {
|
|
178
|
+
const objProductBundleSetting = bundle.productBundleSettings[index2];
|
|
179
|
+
data.push({
|
|
180
|
+
sku: objProductBundleSetting.product.sku,
|
|
181
|
+
packing_type: objProductBundleSetting.productDetail.packingType,
|
|
182
|
+
packing_size: objProductBundleSetting.productDetail.packingSize,
|
|
183
|
+
uom: objProductBundleSetting.productDetail.uom,
|
|
184
|
+
release_qty: objProductBundleSetting.bundleQty * itm.releaseQty,
|
|
185
|
+
assignedQty: undefined,
|
|
186
|
+
assignedUomValue: undefined,
|
|
187
|
+
releaseUomValue: undefined
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
data = [{
|
|
193
|
+
sku: itm.product.sku,
|
|
194
|
+
packing_type: itm.packingType,
|
|
195
|
+
packing_size: itm.packingSize,
|
|
196
|
+
uom: itm.uom,
|
|
197
|
+
release_qty: itm.releaseQty,
|
|
198
|
+
assignedQty: undefined,
|
|
199
|
+
assignedUomValue: undefined,
|
|
200
|
+
releaseUomValue: undefined
|
|
201
|
+
}];
|
|
202
|
+
}
|
|
203
|
+
data.forEach(data => {
|
|
204
|
+
let existingOI = orderInventories.find(itm => itm.sku == data.sku &&
|
|
205
|
+
itm.packing_type == data.packing_type &&
|
|
206
|
+
itm.packing_size == data.packing_size &&
|
|
207
|
+
itm.uom == data.uom);
|
|
208
|
+
if (existingOI) {
|
|
209
|
+
existingOI.release_qty = existingOI.release_qty + data.release_qty;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
orderInventories.push(data);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
await (0, typeorm_1.getConnection)().transaction(async (childTx) => {
|
|
218
|
+
let availableItems = await (0, release_good_query_1.bulkReleaseGoodsAvailableItemsFunction)(orderInventories, draftOrder.bizplace.id, context, childTx);
|
|
219
|
+
if (availableItems.some(item => !item.release_qty || item.release_qty > item.assignedQty))
|
|
220
|
+
throw new errors_1.ValidationError(Object.assign(Object.assign({}, errors_1.ValidationError.ERROR_CODES.INSUFFICIENT_STOCK), { detail: { data: JSON.stringify(availableItems) } }));
|
|
221
|
+
// update orderInventories if availableItems are valid
|
|
222
|
+
releaseGood.orderInventories = availableItems.map(itm => {
|
|
223
|
+
return Object.assign(Object.assign({}, itm), { releaseQty: itm.release_qty });
|
|
224
|
+
});
|
|
225
|
+
let createdReleaseGood = await (0, release_good_mutation_1.bulkGenerateReleaseGood)(releaseGood, releaseGood.bizplace.id, roNoSetting, domain, user, childTx);
|
|
226
|
+
await childTx
|
|
227
|
+
.getRepository(__1.DraftReleaseGood)
|
|
228
|
+
.update({ id: draftOrder.id }, { releaseGood: createdReleaseGood, status: constants_1.DRAFT_RELEASE_ORDER_STATUS.SUBMITTED });
|
|
229
|
+
createdReleaseGood = await (0, release_good_mutation_1.confirmReleaseGood)(createdReleaseGood.name, context, childTx);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
console.error(error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
__decorate([
|
|
242
|
+
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
243
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
244
|
+
(0, type_graphql_1.Mutation)(returns => __1.DraftReleaseGood),
|
|
245
|
+
__param(0, (0, type_graphql_1.Ctx)()),
|
|
246
|
+
__param(1, (0, type_graphql_1.Arg)('draftReleaseGood', type => __1.DraftReleaseGoodPatch)),
|
|
247
|
+
__param(2, (0, type_graphql_1.Arg)('orderProducts', type => [order_product_types_1.OrderProductPatch])),
|
|
248
|
+
__param(3, (0, type_graphql_1.Arg)('files', type => [graphql_upload_1.GraphQLUpload], { nullable: true })),
|
|
249
|
+
__param(4, (0, type_graphql_1.Arg)('shippingOrder', type => shipping_order_types_1.ShippingOrderPatch, { nullable: true })),
|
|
250
|
+
__metadata("design:type", Function),
|
|
251
|
+
__metadata("design:paramtypes", [Object, __1.DraftReleaseGoodPatch, Array, Array, shipping_order_types_1.ShippingOrderPatch]),
|
|
252
|
+
__metadata("design:returntype", Promise)
|
|
253
|
+
], DraftReleaseGoodMutation.prototype, "upsertDraftReleaseGood", null);
|
|
254
|
+
__decorate([
|
|
255
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
256
|
+
(0, type_graphql_1.Mutation)(returns => __1.DraftReleaseGood, { description: 'To create new DraftReleaseGood' }),
|
|
257
|
+
__param(0, (0, type_graphql_1.Arg)('draftReleaseGood', type => __1.NewDraftReleaseGood, { nullable: true })),
|
|
258
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
259
|
+
__metadata("design:type", Function),
|
|
260
|
+
__metadata("design:paramtypes", [__1.NewDraftReleaseGood, Object]),
|
|
261
|
+
__metadata("design:returntype", Promise)
|
|
262
|
+
], DraftReleaseGoodMutation.prototype, "createDraftReleaseGood", null);
|
|
263
|
+
__decorate([
|
|
264
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
265
|
+
(0, type_graphql_1.Mutation)(returns => __1.DraftReleaseGood, { description: 'To modify DraftReleaseGood information' }),
|
|
266
|
+
__param(0, (0, type_graphql_1.Arg)('id')),
|
|
267
|
+
__param(1, (0, type_graphql_1.Arg)('patch', type => __1.DraftReleaseGoodPatch)),
|
|
268
|
+
__param(2, (0, type_graphql_1.Ctx)()),
|
|
269
|
+
__metadata("design:type", Function),
|
|
270
|
+
__metadata("design:paramtypes", [String, __1.DraftReleaseGoodPatch, Object]),
|
|
271
|
+
__metadata("design:returntype", Promise)
|
|
272
|
+
], DraftReleaseGoodMutation.prototype, "updateDraftReleaseGood", null);
|
|
273
|
+
__decorate([
|
|
274
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
275
|
+
(0, type_graphql_1.Mutation)(returns => [__1.DraftReleaseGood], { description: "To modify multiple DraftReleaseGoods' information" }),
|
|
276
|
+
__param(0, (0, type_graphql_1.Arg)('patches', type => [__1.DraftReleaseGoodPatch])),
|
|
277
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
278
|
+
__metadata("design:type", Function),
|
|
279
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
280
|
+
__metadata("design:returntype", Promise)
|
|
281
|
+
], DraftReleaseGoodMutation.prototype, "updateMultipleDraftReleaseGood", null);
|
|
282
|
+
__decorate([
|
|
283
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
284
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete DraftReleaseGood' }),
|
|
285
|
+
__param(0, (0, type_graphql_1.Arg)('id')),
|
|
286
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
287
|
+
__metadata("design:type", Function),
|
|
288
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
289
|
+
__metadata("design:returntype", Promise)
|
|
290
|
+
], DraftReleaseGoodMutation.prototype, "deleteDraftReleaseGood", null);
|
|
291
|
+
__decorate([
|
|
292
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
293
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple draftReleaseGoods' }),
|
|
294
|
+
__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
295
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
296
|
+
__metadata("design:type", Function),
|
|
297
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
298
|
+
__metadata("design:returntype", Promise)
|
|
299
|
+
], DraftReleaseGoodMutation.prototype, "deleteDraftReleaseGoods", null);
|
|
300
|
+
__decorate([
|
|
301
|
+
(0, type_graphql_1.Directive)('@privilege(category: "order_customer", privilege: "mutation")'),
|
|
302
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
303
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To generate Release Goods from Draft' }),
|
|
304
|
+
__param(0, (0, type_graphql_1.Ctx)()),
|
|
305
|
+
__param(1, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
306
|
+
__metadata("design:type", Function),
|
|
307
|
+
__metadata("design:paramtypes", [Object, Array]),
|
|
308
|
+
__metadata("design:returntype", Promise)
|
|
309
|
+
], DraftReleaseGoodMutation.prototype, "generateReleaseGoodsFromDraft", null);
|
|
310
|
+
DraftReleaseGoodMutation = __decorate([
|
|
311
|
+
(0, type_graphql_1.Resolver)(__1.DraftReleaseGood)
|
|
312
|
+
], DraftReleaseGoodMutation);
|
|
313
|
+
exports.DraftReleaseGoodMutation = DraftReleaseGoodMutation;
|
|
314
|
+
async function upsertDraftReleaseGoodFunction(_, draftReleaseGood, orderProducts, shippingOrder, files, context, tx) {
|
|
315
|
+
if (!draftReleaseGood.id) {
|
|
316
|
+
draftReleaseGood = await createDraftReleaseGoodFunction(_, draftReleaseGood, orderProducts, shippingOrder, files, context, tx);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
draftReleaseGood = await updateDraftReleaseGoodFunction(_, draftReleaseGood, orderProducts, shippingOrder, files, context, tx);
|
|
320
|
+
}
|
|
321
|
+
return draftReleaseGood;
|
|
322
|
+
}
|
|
323
|
+
exports.upsertDraftReleaseGoodFunction = upsertDraftReleaseGoodFunction;
|
|
324
|
+
async function createDraftReleaseGoodFunction(_, draftReleaseGood, orderProducts, shippingOrder, files, context, tx) {
|
|
325
|
+
var _a;
|
|
326
|
+
const { domain, user } = context.state;
|
|
327
|
+
let myBizplace;
|
|
328
|
+
let orderNo = '';
|
|
329
|
+
let arrError = [];
|
|
330
|
+
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
331
|
+
if ((_a = draftReleaseGood === null || draftReleaseGood === void 0 ? void 0 : draftReleaseGood.bizplace) === null || _a === void 0 ? void 0 : _a.id) {
|
|
332
|
+
const permittedBizplaces = await (0, biz_base_1.getPermittedBizplaces)(domain, user);
|
|
333
|
+
let foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == draftReleaseGood.bizplace.id);
|
|
334
|
+
if (!foundPermittedBizplace)
|
|
335
|
+
throw new Error(`This user does not permitted for this company`);
|
|
336
|
+
draftReleaseGood.bizplace = foundPermittedBizplace;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
arrError.push(`No bizplace was selected`);
|
|
340
|
+
}
|
|
341
|
+
if (arrError.length > 0) {
|
|
342
|
+
throw new Error(arrError.join(', '));
|
|
343
|
+
}
|
|
344
|
+
// // find DRO number rule setting
|
|
345
|
+
const droNoSetting = await settingRepo.findOne({
|
|
346
|
+
where: {
|
|
347
|
+
domain,
|
|
348
|
+
name: constants_1.ORDER_NUMBER_SETTING_KEY.PO_NUMBER_RULE
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
if (droNoSetting) {
|
|
352
|
+
orderNo = await (0, id_rule_base_1.generateId)({ domain, type: constants_1.ORDER_NUMBER_RULE_TYPE.DRO_NUMBER, seed: {} });
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
orderNo = utils_2.OrderNoGenerator.draftReleaseGood();
|
|
356
|
+
}
|
|
357
|
+
// // 1. Create draft release good
|
|
358
|
+
const createdDraftReleaseGood = await tx.getRepository(__1.DraftReleaseGood).save(Object.assign(Object.assign({}, draftReleaseGood), { name: orderNo, status: constants_1.DRAFT_RELEASE_ORDER_STATUS.DRAFT, domain, creator: user, updater: user }));
|
|
359
|
+
// // 2. Create draft release good product
|
|
360
|
+
await upsertDraftReleaseGoodProducts(domain, draftReleaseGood.bizplace, createdDraftReleaseGood, orderProducts, user, tx);
|
|
361
|
+
// // 3. Create Attachments
|
|
362
|
+
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
363
|
+
const attachments = files.map(attachment => {
|
|
364
|
+
return {
|
|
365
|
+
file: attachment,
|
|
366
|
+
refBy: createdDraftReleaseGood.id,
|
|
367
|
+
category: constants_1.ATTACHMENT_TYPE.DGRN
|
|
368
|
+
};
|
|
369
|
+
});
|
|
370
|
+
await (0, attachment_base_1.createAttachments)(_, { attachments }, context);
|
|
371
|
+
}
|
|
372
|
+
return createdDraftReleaseGood;
|
|
373
|
+
}
|
|
374
|
+
exports.createDraftReleaseGoodFunction = createDraftReleaseGoodFunction;
|
|
375
|
+
async function updateDraftReleaseGoodFunction(_, draftReleaseGood, orderProducts, shippingOrder, files, context, tx) {
|
|
376
|
+
var _a;
|
|
377
|
+
const { domain, user } = context.state;
|
|
378
|
+
let existingDraftReleaseGood = await (0, draft_release_good_query_1.getDraftReleaseGoodFunction)(_, draftReleaseGood.name, context, tx);
|
|
379
|
+
if ((_a = draftReleaseGood === null || draftReleaseGood === void 0 ? void 0 : draftReleaseGood.bizplace) === null || _a === void 0 ? void 0 : _a.id) {
|
|
380
|
+
const permittedBizplaces = await (0, biz_base_1.getPermittedBizplaces)(domain, user);
|
|
381
|
+
let foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == draftReleaseGood.bizplace.id);
|
|
382
|
+
if (!foundPermittedBizplace)
|
|
383
|
+
throw new Error(`This user does not permitted for this company`);
|
|
384
|
+
draftReleaseGood.bizplace = foundPermittedBizplace;
|
|
385
|
+
}
|
|
386
|
+
if (shippingOrder) {
|
|
387
|
+
// case to update existing shippingOrder
|
|
388
|
+
if (existingDraftReleaseGood.shippingOrder) {
|
|
389
|
+
await tx.getRepository(shipping_order_1.ShippingOrder).update(existingDraftReleaseGood.shippingOrder.id, shippingOrder);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
let newShippingOrder = await tx.getRepository(shipping_order_1.ShippingOrder).save(Object.assign(Object.assign({}, shippingOrder), { name: utils_2.OrderNoGenerator.shippingOrder(), domain, bizplace: draftReleaseGood.bizplace, status: constants_1.ORDER_STATUS.PENDING, creator: user, updater: user }));
|
|
393
|
+
draftReleaseGood.shippingOrder = newShippingOrder;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
// case to delete existing shippingOrder
|
|
398
|
+
if (existingDraftReleaseGood.shippingOrder) {
|
|
399
|
+
await tx.getRepository(shipping_order_1.ShippingOrder).delete(existingDraftReleaseGood.shippingOrder);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// // 1. Update draft release good
|
|
403
|
+
const updateDraftReleaseGood = await tx.getRepository(__1.DraftReleaseGood).save(Object.assign(Object.assign(Object.assign({}, existingDraftReleaseGood), draftReleaseGood), { domain, creator: user, updater: user }));
|
|
404
|
+
// // 2. Update draft release good product
|
|
405
|
+
await upsertDraftReleaseGoodProducts(domain, draftReleaseGood.bizplace, draftReleaseGood, orderProducts, user, tx);
|
|
406
|
+
// // 3. Remove Purchase Order Attachment
|
|
407
|
+
const foundAttachments = await (0, typeorm_1.getRepository)(attachment_base_1.Attachment).find({
|
|
408
|
+
where: {
|
|
409
|
+
domain,
|
|
410
|
+
refBy: draftReleaseGood.id,
|
|
411
|
+
category: constants_1.ATTACHMENT_TYPE.DGRN
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
// // 4. Remove All Attachment
|
|
415
|
+
if (foundAttachments === null || foundAttachments === void 0 ? void 0 : foundAttachments.length) {
|
|
416
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(_, { refBys: foundAttachments.map(file => file.refBy) }, context);
|
|
417
|
+
}
|
|
418
|
+
// // 5. Add New Attachment
|
|
419
|
+
if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
|
|
420
|
+
const attachments = files.map(attachment => {
|
|
421
|
+
return {
|
|
422
|
+
file: attachment,
|
|
423
|
+
refBy: updateDraftReleaseGood.id,
|
|
424
|
+
category: constants_1.ATTACHMENT_TYPE.DGRN
|
|
425
|
+
};
|
|
426
|
+
});
|
|
427
|
+
await (0, attachment_base_1.createAttachments)(_, { attachments }, context);
|
|
428
|
+
}
|
|
429
|
+
return existingDraftReleaseGood;
|
|
430
|
+
}
|
|
431
|
+
exports.updateDraftReleaseGoodFunction = updateDraftReleaseGoodFunction;
|
|
432
|
+
async function upsertDraftReleaseGoodProducts(domain, bizplace, draftReleaseGood, orderProductsPatch, user, tx) {
|
|
433
|
+
try {
|
|
434
|
+
let orderProducts = [];
|
|
435
|
+
const draftReleaseGoodRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(__1.DraftReleaseGood)) || (0, typeorm_1.getRepository)(__1.DraftReleaseGood);
|
|
436
|
+
const bizplaceRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(biz_base_1.Bizplace)) || (0, typeorm_1.getRepository)(biz_base_1.Bizplace);
|
|
437
|
+
const orderProductRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(__1.OrderProduct)) || (0, typeorm_1.getRepository)(__1.OrderProduct);
|
|
438
|
+
const productRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(product_base_1.Product)) || (0, typeorm_1.getRepository)(product_base_1.Product);
|
|
439
|
+
const productBundleRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(product_base_1.ProductBundle)) || (0, typeorm_1.getRepository)(product_base_1.ProductBundle);
|
|
440
|
+
draftReleaseGood = await draftReleaseGoodRepo.findOne({
|
|
441
|
+
where: { id: draftReleaseGood.id },
|
|
442
|
+
relations: ['orderProducts', 'orderProducts.product', 'orderProducts.productBundle', 'orderProducts.creator', 'orderProducts.updater']
|
|
443
|
+
});
|
|
444
|
+
// Remove all existing order products that do not exist in current input
|
|
445
|
+
let removeOP = draftReleaseGood.orderProducts.filter(existingOP => orderProductsPatch.filter(inOP => inOP.id == existingOP.id).length == 0);
|
|
446
|
+
// removeOP.forEach(async op => {
|
|
447
|
+
// await orderProductRepo.delete(op)
|
|
448
|
+
// })
|
|
449
|
+
if (removeOP.length > 0)
|
|
450
|
+
await orderProductRepo.delete(removeOP.map(itm => itm.id));
|
|
451
|
+
bizplace = await bizplaceRepo.findOne(bizplace.id, {
|
|
452
|
+
relations: ['domain', 'company', 'company.domain']
|
|
453
|
+
});
|
|
454
|
+
orderProducts = await Promise.all(orderProductsPatch.map(async (op) => {
|
|
455
|
+
var _a;
|
|
456
|
+
if (!(op === null || op === void 0 ? void 0 : op.id))
|
|
457
|
+
delete op.id;
|
|
458
|
+
const customerCompanyDomain = bizplace.company.domain;
|
|
459
|
+
let product = null;
|
|
460
|
+
let productBundle = null;
|
|
461
|
+
let existingOP = draftReleaseGood.orderProducts.find(existOP => existOP.id == op.id);
|
|
462
|
+
let updatePatch = Object.assign(Object.assign(Object.assign({}, existingOP), op), { domain, batchId: '', packQty: 0, actualPackQty: 0, palletQty: 0, actualPalletQty: 0, bizplace: bizplace, name: (op === null || op === void 0 ? void 0 : op.id) ? op.name : utils_2.OrderNoGenerator.orderProduct(), draftReleaseGood: draftReleaseGood, status: draftReleaseGood.status, creator: (op === null || op === void 0 ? void 0 : op.id) ? op.creator : user, updater: user });
|
|
463
|
+
if ((_a = op === null || op === void 0 ? void 0 : op.product) === null || _a === void 0 ? void 0 : _a.id) {
|
|
464
|
+
product = await productRepo.findOne({
|
|
465
|
+
where: { domain: customerCompanyDomain, id: op.product.id }
|
|
466
|
+
});
|
|
467
|
+
updatePatch['product'] = product || undefined;
|
|
468
|
+
if (!product) {
|
|
469
|
+
productBundle = await productBundleRepo.findOne({
|
|
470
|
+
where: { domain: customerCompanyDomain, id: op.product.id }
|
|
471
|
+
});
|
|
472
|
+
updatePatch['productBundle'] = productBundle || undefined;
|
|
473
|
+
}
|
|
474
|
+
if (!product && !productBundle)
|
|
475
|
+
throw new Error(`product not found`);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
if (existingOP) {
|
|
479
|
+
product = existingOP.product;
|
|
480
|
+
productBundle = existingOP.productBundle;
|
|
481
|
+
updatePatch['product'] = existingOP.product || undefined;
|
|
482
|
+
updatePatch['productBundle'] = existingOP.productBundle || undefined;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
updatePatch['packingType'] = (op === null || op === void 0 ? void 0 : op.packingType)
|
|
486
|
+
? op.packingType
|
|
487
|
+
: (product === null || product === void 0 ? void 0 : product.packingType)
|
|
488
|
+
? product.packingType
|
|
489
|
+
: productBundle.packingType;
|
|
490
|
+
updatePatch['uom'] = (op === null || op === void 0 ? void 0 : op.uom) ? op.uom : (product === null || product === void 0 ? void 0 : product.primaryUnit) ? product.primaryUnit : 'UNIT';
|
|
491
|
+
updatePatch['uomValue'] = (op === null || op === void 0 ? void 0 : op.uomValue) ? op.uomValue : (product === null || product === void 0 ? void 0 : product.primaryValue) ? product.primaryValue : 0;
|
|
492
|
+
return updatePatch;
|
|
493
|
+
}));
|
|
494
|
+
await orderProductRepo.save(orderProducts);
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
throw error;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
exports.upsertDraftReleaseGoodProducts = upsertDraftReleaseGoodProducts;
|
|
501
|
+
//# sourceMappingURL=draft-release-good-mutation.js.map
|