@things-factory/operato-hub 4.3.247 → 4.3.249
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/email-attachment.js +4 -0
- package/dist-server/entities/email-attachment.js.map +1 -1
- package/dist-server/graphql/resolvers/email/send-emails.js +7 -5
- package/dist-server/graphql/resolvers/email/send-emails.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +156 -133
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/get-products.js +2 -2
- package/dist-server/routers/api/restful-apis/v1/company/get-product-list.js +2 -2
- package/dist-server/routers/api/restful-apis/v1/company/get-product-list.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/utils/params.js +2 -2
- package/dist-server/routers/api/restful-apis/v1/utils/params.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-release-order.js +146 -123
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-release-order.js.map +1 -1
- package/openapi/unstable/product.yaml +1 -1
- package/openapi/v1/product.yaml +3 -3
- package/openapi/v2/product.yaml +1 -1
- package/package.json +31 -31
- package/server/entities/email-attachment.ts +4 -0
- package/server/graphql/resolvers/email/send-emails.ts +8 -6
- package/server/routers/api/restful-apis/unstable/add-release-order.ts +218 -172
- package/server/routers/api/restful-apis/unstable/get-products.ts +2 -2
- package/server/routers/api/restful-apis/v1/company/get-product-list.ts +2 -2
- package/server/routers/api/restful-apis/v1/utils/params.ts +2 -2
- package/server/routers/api/restful-apis/v1/warehouse/add-release-order.ts +207 -161
|
@@ -41,6 +41,10 @@ __decorate([
|
|
|
41
41
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
42
42
|
__metadata("design:type", String)
|
|
43
43
|
], EmailAttachment.prototype, "variables", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], EmailAttachment.prototype, "attachmentVariables", void 0);
|
|
44
48
|
__decorate([
|
|
45
49
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
46
50
|
__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-attachment.js","sourceRoot":"","sources":["../../server/entities/email-attachment.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAsH;AAEtH,yDAAgD;AAChD,iDAA8C;
|
|
1
|
+
{"version":3,"file":"email-attachment.js","sourceRoot":"","sources":["../../server/entities/email-attachment.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAsH;AAEtH,yDAAgD;AAChD,iDAA8C;AAE9C,mCAA+B;AAIxB,IAAM,eAAe,GAArB,MAAM,eAAe;CA2C3B,CAAA;AA1CC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;2CACrB;AAEV;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;kDAClB,cAAM,oBAAN,cAAM;+CAAA;AAEd;IAAC,IAAA,gBAAM,GAAE;;6CACG;AAEZ;IAAC,IAAA,gBAAM,GAAE;;kDACQ;AAEjB;IAAC,IAAA,gBAAM,GAAE;;gDACM;AAEf;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACV;AAEjB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4DACA;AAE3B;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wDACJ;AAEvB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,aAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC;8BACnD,aAAK;8CAAA;AAEZ;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;kDAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;kDAAA;AAEf;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;kDACO,gBAAI,oBAAJ,gBAAI;gDAAA;AAEb;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;kDACO,gBAAI,oBAAJ,gBAAI;gDAAA;AA1CF,eAAe;IAF3B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,uBAAuB,EAAE,CAAC,eAAgC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;GACxG,eAAe,CA2C3B;AA3CY,0CAAe"}
|
|
@@ -97,10 +97,8 @@ async function processEmailCronJob(email, fromDate, toDate) {
|
|
|
97
97
|
let attachments = [];
|
|
98
98
|
// black list filtration
|
|
99
99
|
// let partnerBlackList = JSON.parse(email.partnerBlackList) || []
|
|
100
|
-
//
|
|
101
100
|
// partner list
|
|
102
101
|
let partnerList = JSON.parse(email.partnerList) || [];
|
|
103
|
-
//
|
|
104
102
|
const partners = await (0, typeorm_1.getRepository)(auth_base_1.Partner).find({
|
|
105
103
|
where: { domain: email.domain, id: (0, typeorm_1.In)(partnerList) },
|
|
106
104
|
relations: ['partnerDomain']
|
|
@@ -108,6 +106,10 @@ async function processEmailCronJob(email, fromDate, toDate) {
|
|
|
108
106
|
// retrieve and process xlsx attachmennts
|
|
109
107
|
for (let attachment of email.emailAttachments) {
|
|
110
108
|
let client = shell_1.GraphqlLocalClient.client;
|
|
109
|
+
let attachmentVariables = JSON.parse(attachment.attachmentVariables);
|
|
110
|
+
let numberOfMonths = (attachmentVariables === null || attachmentVariables === void 0 ? void 0 : attachmentVariables.numberOfMonths) || 1;
|
|
111
|
+
let numberOfWeeks = (attachmentVariables === null || attachmentVariables === void 0 ? void 0 : attachmentVariables.numberOfWeeks) ? attachmentVariables.numberOfWeeks * 7 : 7;
|
|
112
|
+
let numberOfDays = (attachmentVariables === null || attachmentVariables === void 0 ? void 0 : attachmentVariables.numberOfDays) || 1;
|
|
111
113
|
for (let partner of partners) {
|
|
112
114
|
const bizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
|
|
113
115
|
where: { domain: partner.partnerDomain }
|
|
@@ -124,15 +126,15 @@ async function processEmailCronJob(email, fromDate, toDate) {
|
|
|
124
126
|
let curDateForMonth = new Date(curDate);
|
|
125
127
|
let curDateForWeek = new Date(curDate);
|
|
126
128
|
let curDateForDay = new Date(curDate);
|
|
127
|
-
let prevMonth = curDateForMonth.getMonth() -
|
|
129
|
+
let prevMonth = curDateForMonth.getMonth() - numberOfMonths;
|
|
128
130
|
let prevMonthBegin = new Date(curDateForMonth.setMonth(prevMonth));
|
|
129
131
|
prevMonthBegin.setHours(0, 0, 0, 0);
|
|
130
132
|
let prevMonthBeginDateTime = new Date(prevMonthBegin - timezoneOffset * 60000).toISOString();
|
|
131
|
-
let prevWeek = curDateForWeek.getDate() -
|
|
133
|
+
let prevWeek = curDateForWeek.getDate() - numberOfWeeks; // subtract 1 week
|
|
132
134
|
let prevWeekBegin = new Date(curDateForWeek.setDate(prevWeek));
|
|
133
135
|
prevWeekBegin.setHours(0, 0, 0, 0);
|
|
134
136
|
let prevWeekBeginDateTime = new Date(prevWeekBegin - timezoneOffset * 60000).toISOString();
|
|
135
|
-
let prevDay = curDateForDay.getDate() -
|
|
137
|
+
let prevDay = curDateForDay.getDate() - numberOfDays; // subtract 1 day
|
|
136
138
|
let prevDayBegin = new Date(curDateForDay.setDate(prevDay));
|
|
137
139
|
prevDayBegin.setHours(0, 0, 0, 0);
|
|
138
140
|
let prevDayBeginDateTime = new Date(prevDayBegin - timezoneOffset * 60000).toISOString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-emails.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/email/send-emails.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AACzC,8DAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"send-emails.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/email/send-emails.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AACzC,8DAA6B;AAC7B,qCAA2C;AAE3C,yDAAyD;AACzD,uDAAmD;AACnD,2DAAyE;AACzE,6CAA4C;AAC5C,iDAA0D;AAE1D,gDAAyC;AAEzC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEnB,QAAA,kBAAkB,GAAG;IAChC,KAAK,CAAC,UAAU,CAAC,CAAM,EAAE,EAAE,EAAE,OAAY;QACvC,MAAM,MAAM,GAAY,MAAM,IAAA,uBAAa,EAAC,gBAAK,CAAC,CAAC,IAAI,CAAC;YACtD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YACvB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,CAAC;SAC3F,CAAC,CAAA;QAEF,IAAI;YACF,IAAI,GAAG,GAAQ,IAAI,IAAI,EAAE,CAAA;YACzB,IAAI,aAAa,GAAQ,IAAI,IAAI,CAAC,GAAG,GAAG,qBAAqB,GAAG,KAAK,CAAC,CAAA;YACtE,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;gBACxB,yCAAyC;gBACzC,IAAI,QAAQ,GAAQ,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;gBAC9D,IAAI,GAAG,GAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA,CAAC,+BAA+B;gBACxE,IAAI,SAAS,GAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;gBAE9C,IAAI,GAAG,GAAG,GAA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AQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7F,CAAC"}
|
|
@@ -45,6 +45,9 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
|
|
|
45
45
|
where: { id: customerBizplaceId },
|
|
46
46
|
relations: ['domain']
|
|
47
47
|
});
|
|
48
|
+
const worksheetPickingAssignment = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
49
|
+
where: { domain, category: 'id-rule', name: 'enable-worksheet-picking-activation-assignment' }
|
|
50
|
+
});
|
|
48
51
|
releaseGood = {
|
|
49
52
|
domain,
|
|
50
53
|
bizplace: customerBizplace,
|
|
@@ -93,7 +96,8 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
|
|
|
93
96
|
discountAmount: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.discountAmount,
|
|
94
97
|
taxAmount: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.taxAmount,
|
|
95
98
|
shippingFee: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.shippingFee,
|
|
96
|
-
lmdOption: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.lmdOption
|
|
99
|
+
lmdOption: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.lmdOption,
|
|
100
|
+
assignedInventory: (worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) == 'true' ? false : true
|
|
97
101
|
};
|
|
98
102
|
// check existing order
|
|
99
103
|
await checkExistingOrder(releaseGood, customerBizplace, bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.checkDuplicationValidation, context, tx);
|
|
@@ -153,11 +157,11 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
|
|
|
153
157
|
}
|
|
154
158
|
// assignment
|
|
155
159
|
// console.time('assign')
|
|
156
|
-
let assignedOrderProducts = await assignToInventory(massagedData.orderProducts, customerBizplace, context, tx);
|
|
160
|
+
let assignedOrderProducts = await assignToInventory(massagedData.orderProducts, customerBizplace, context, tx, worksheetPickingAssignment);
|
|
157
161
|
// console.timeEnd('assign')
|
|
158
162
|
// create order
|
|
159
163
|
// console.time('save')
|
|
160
|
-
let result = await createReleaseGood(releaseGood, assignedOrderProducts, customerBizplace, context, tx);
|
|
164
|
+
let result = await createReleaseGood(releaseGood, assignedOrderProducts, customerBizplace, context, tx, worksheetPickingAssignment);
|
|
161
165
|
// console.timeEnd('save')
|
|
162
166
|
let addReleaseGood = {
|
|
163
167
|
id: result.id,
|
|
@@ -391,7 +395,7 @@ async function createDraftOrder(releaseGood, orderProducts, context) {
|
|
|
391
395
|
return await (0, sales_base_1.createDraftReleaseGoodFunction)(null, releaseGood, orderProducts, null, [], context, tx);
|
|
392
396
|
});
|
|
393
397
|
}
|
|
394
|
-
async function createReleaseGood(releaseGood, orderProducts, bizplace, context, tx) {
|
|
398
|
+
async function createReleaseGood(releaseGood, orderProducts, bizplace, context, tx, worksheetPickingAssignment) {
|
|
395
399
|
try {
|
|
396
400
|
const { domain, user } = context.state;
|
|
397
401
|
const settingRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(setting_base_1.Setting)) || (0, typeorm_1.getRepository)(setting_base_1.Setting);
|
|
@@ -485,7 +489,9 @@ async function createReleaseGood(releaseGood, orderProducts, bizplace, context,
|
|
|
485
489
|
creator: user,
|
|
486
490
|
updater: user,
|
|
487
491
|
acceptedBy: user,
|
|
488
|
-
acceptedAt: new Date()
|
|
492
|
+
acceptedAt: new Date(),
|
|
493
|
+
assignedInventory: (worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) == 'true' ? false : true,
|
|
494
|
+
orderMethod: sales_base_1.ORDER_METHOD.SELECT_BY_PRODUCT
|
|
489
495
|
};
|
|
490
496
|
let resultReleaseGood = await tx.getRepository(sales_base_1.ReleaseGood).save(newReleaseGood);
|
|
491
497
|
let combinedOrderInventories = [];
|
|
@@ -493,17 +499,19 @@ async function createReleaseGood(releaseGood, orderProducts, bizplace, context,
|
|
|
493
499
|
let orderInventories = orderProduct.orderInventories;
|
|
494
500
|
orderProduct = Object.assign(new sales_base_1.OrderProduct(), Object.assign(Object.assign({}, orderProduct), { name: (0, uuid_1.v4)(), domain: domain, bizplace: bizplace, releaseGood: resultReleaseGood, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_PRODUCT_STATUS.ASSIGNED }));
|
|
495
501
|
let result = await tx.getRepository(sales_base_1.OrderProduct).save(orderProduct);
|
|
496
|
-
|
|
497
|
-
let
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
502
|
+
if (worksheetPickingAssignment.value !== 'true') {
|
|
503
|
+
for (let oiIdx = 0; oiIdx < orderInventories.length; oiIdx++) {
|
|
504
|
+
let orderInventory = Object.assign(new sales_base_1.OrderInventory(), Object.assign(Object.assign({}, orderInventories[oiIdx]), { name: (0, uuid_1.v4)(), domain: domain, bizplace: bizplace, releaseGood: resultReleaseGood, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET, orderProduct: result }));
|
|
505
|
+
await tx.getRepository(sales_base_1.OrderInventory).save(orderInventory);
|
|
506
|
+
combinedOrderInventories.push({
|
|
507
|
+
product: { name: orderInventory.product.name, sku: orderInventory.product.sku },
|
|
508
|
+
batchId: orderInventory.batchId,
|
|
509
|
+
packingType: orderInventory.packingType,
|
|
510
|
+
packingSize: orderInventory.packingSize,
|
|
511
|
+
releaseQty: orderInventory.releaseQty,
|
|
512
|
+
releaseUomValue: orderInventory.releaseUomValue
|
|
513
|
+
});
|
|
514
|
+
}
|
|
507
515
|
}
|
|
508
516
|
return result;
|
|
509
517
|
}));
|
|
@@ -745,102 +753,103 @@ async function massageOrderItems(releaseGood, inputOrderProducts, context) {
|
|
|
745
753
|
throw error;
|
|
746
754
|
}
|
|
747
755
|
}
|
|
748
|
-
async function assignToInventory(orderProducts, customerBizplace, context, tx) {
|
|
756
|
+
async function assignToInventory(orderProducts, customerBizplace, context, tx, worksheetPickingAssignment) {
|
|
749
757
|
const { client, domain, user } = context.state;
|
|
758
|
+
const pickingProductSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
759
|
+
where: { domain, name: 'rule-for-picking-product' }
|
|
760
|
+
});
|
|
750
761
|
for (let opIdx = 0; opIdx < orderProducts.length; opIdx++) {
|
|
751
762
|
let orderProduct = orderProducts[opIdx];
|
|
752
763
|
let assignedOrderInventories = [];
|
|
753
|
-
const pickingProductSetting = await tx.getRepository(setting_base_1.Setting).findOne({
|
|
754
|
-
where: { domain, name: 'rule-for-picking-product' }
|
|
755
|
-
});
|
|
756
764
|
for (let oiIdx = 0; oiIdx < orderProducts[opIdx].orderInventories.length; oiIdx++) {
|
|
757
765
|
const orderInventory = orderProduct.orderInventories[oiIdx];
|
|
758
766
|
let sortings = [];
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
767
|
+
if ((worksheetPickingAssignment === null || worksheetPickingAssignment === void 0 ? void 0 : worksheetPickingAssignment.value) !== 'true') {
|
|
768
|
+
switch (orderInventory.product.pickingStrategy) {
|
|
769
|
+
case 'LIFO':
|
|
770
|
+
sortings.push({ name: 'iv.created_at', desc: true });
|
|
771
|
+
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
772
|
+
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
773
|
+
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
774
|
+
}
|
|
765
775
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
769
|
-
}
|
|
770
|
-
break;
|
|
771
|
-
case 'FEFO':
|
|
772
|
-
sortings.push({ name: 'iv.expiration_date', desc: false }, { name: 'iv.created_at', desc: false });
|
|
773
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
774
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
775
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
776
|
+
else {
|
|
777
|
+
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
776
778
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
sortings.push({ name: '
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
785
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
786
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
779
|
+
break;
|
|
780
|
+
case 'FEFO':
|
|
781
|
+
sortings.push({ name: 'iv.expiration_date', desc: false }, { name: 'iv.created_at', desc: false });
|
|
782
|
+
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
783
|
+
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
784
|
+
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
785
|
+
}
|
|
787
786
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
791
|
-
}
|
|
792
|
-
break;
|
|
793
|
-
case 'LOCATION':
|
|
794
|
-
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
795
|
-
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
796
|
-
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
787
|
+
else {
|
|
788
|
+
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
797
789
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
sortings.push({ name: '
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
790
|
+
break;
|
|
791
|
+
case 'FMFO':
|
|
792
|
+
sortings.push({ name: 'iv.manufacture_date', desc: false }, { name: 'iv.created_at', desc: false });
|
|
793
|
+
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
794
|
+
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
795
|
+
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
800
|
+
}
|
|
801
|
+
break;
|
|
802
|
+
case 'LOCATION':
|
|
803
|
+
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
804
|
+
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
805
|
+
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
sortings.push({ name: 'loc.name', desc: false }, { name: 'iv.created_at', desc: false });
|
|
809
810
|
}
|
|
810
|
-
}
|
|
811
|
-
else {
|
|
812
|
-
sortings.push({ name: 'loc.name', desc: false });
|
|
813
|
-
sortings.push({ name: 'iv.pallet_id', desc: false });
|
|
814
|
-
}
|
|
815
|
-
break;
|
|
816
|
-
}
|
|
817
|
-
let queryFilters = [];
|
|
818
|
-
let queryStrings = queryFilters.reduce((acc, itm, idx, arr) => {
|
|
819
|
-
acc.values.push(itm.filters);
|
|
820
|
-
switch (itm === null || itm === void 0 ? void 0 : itm.operator) {
|
|
821
|
-
case 'notin':
|
|
822
|
-
case 'in':
|
|
823
|
-
acc.query.push(`${itm.query} ${itm.operator == 'notin' ? 'NOT IN' : 'IN'} (${itm.filtes
|
|
824
|
-
.map((itm, idx) => {
|
|
825
|
-
return `$${acc.values.length + 1}`;
|
|
826
|
-
})
|
|
827
|
-
.join(',')})`);
|
|
828
811
|
break;
|
|
812
|
+
//Every other case includes 'FIFO' will be applicable for this case
|
|
829
813
|
default:
|
|
830
|
-
|
|
814
|
+
sortings.push({ name: 'iv.created_at', desc: false });
|
|
815
|
+
if (pickingProductSetting === null || pickingProductSetting === void 0 ? void 0 : pickingProductSetting.value) {
|
|
816
|
+
for (const [key, value] of Object.entries(JSON.parse(pickingProductSetting.value))) {
|
|
817
|
+
sortings.push({ name: `loc.${key}`, desc: value == 'DESC' ? true : false });
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
sortings.push({ name: 'loc.name', desc: false });
|
|
822
|
+
sortings.push({ name: 'iv.pallet_id', desc: false });
|
|
823
|
+
}
|
|
831
824
|
break;
|
|
832
825
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
826
|
+
let queryFilters = [];
|
|
827
|
+
let queryStrings = queryFilters.reduce((acc, itm, idx, arr) => {
|
|
828
|
+
acc.values.push(itm.filters);
|
|
829
|
+
switch (itm === null || itm === void 0 ? void 0 : itm.operator) {
|
|
830
|
+
case 'notin':
|
|
831
|
+
case 'in':
|
|
832
|
+
acc.query.push(`${itm.query} ${itm.operator == 'notin' ? 'NOT IN' : 'IN'} (${itm.filtes
|
|
833
|
+
.map((itm, idx) => {
|
|
834
|
+
return `$${acc.values.length + 1}`;
|
|
835
|
+
})
|
|
836
|
+
.join(',')})`);
|
|
837
|
+
break;
|
|
838
|
+
default:
|
|
839
|
+
acc.query.push(`${itm.query} ${(itm === null || itm === void 0 ? void 0 : itm.operator) ? itm.operator : '='} $${acc.values.length + 1}`);
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
acc.query.push(`${itm.query} ${(itm === null || itm === void 0 ? void 0 : itm.operator) ? itm.operator : '='} $${acc.values.length + 1}`);
|
|
843
|
+
}, {
|
|
844
|
+
query: [],
|
|
845
|
+
values: []
|
|
846
|
+
});
|
|
847
|
+
let sortQuery = sortings
|
|
848
|
+
.map(itm => {
|
|
849
|
+
return `${itm.name} ${itm.desc ? 'DESC' : 'ASC'}`;
|
|
850
|
+
})
|
|
851
|
+
.join(`,`);
|
|
852
|
+
let updatedInventories = await tx.getRepository(warehouse_base_1.Inventory).query(`
|
|
844
853
|
update inventories tgt set locked_qty = coalesce(locked_qty,0) + src.reserve_qty,
|
|
845
854
|
locked_uom_value = coalesce(locked_uom_value,0) + src.reserve_uom_value,
|
|
846
855
|
updated_at = NOW(),
|
|
@@ -853,12 +862,12 @@ async function assignToInventory(orderProducts, customerBizplace, context, tx) {
|
|
|
853
862
|
case when "lock_amount" < 0 then "available_qty" else "available_qty" - "lock_amount" end as "reserve_qty"
|
|
854
863
|
from (
|
|
855
864
|
select *,
|
|
856
|
-
qty - locked_qty as available_qty,
|
|
857
|
-
sum(qty - locked_qty - release_qty) over (order by sort_seq asc rows between unbounded preceding and current row) as lock_amount
|
|
865
|
+
qty - locked_qty - unassigned_qty as available_qty,
|
|
866
|
+
sum(qty - locked_qty - release_qty - unassigned_qty) over (order by sort_seq asc rows between unbounded preceding and current row) as lock_amount
|
|
858
867
|
from (
|
|
859
868
|
SELECT 0 as sort_seq, null as id, null as pallet_id, null as batch_id, null as batch_id_ref,
|
|
860
869
|
null as unit, '${orderInventory.uom}' as uom, '${orderInventory.packingType}' as packing_type, '${orderInventory.packingSize}' as packing_size,
|
|
861
|
-
null as manufacture_year, null as carton_id, 0 as uom_value, 0 as locked_uom_value, 0 as qty, 0 as locked_qty, null as created_at,
|
|
870
|
+
null as manufacture_year, null as carton_id, 0 as uom_value, 0 as locked_uom_value, 0 as qty, 0 as locked_qty, 0 as unassigned_uom_value, 0 as unassigned_qty, null as created_at,
|
|
862
871
|
'${orderInventory.releaseQty}' as release_qty, '${orderInventory.releaseUomValue}' as release_uom_value
|
|
863
872
|
UNION
|
|
864
873
|
(
|
|
@@ -866,9 +875,10 @@ async function assignToInventory(orderProducts, customerBizplace, context, tx) {
|
|
|
866
875
|
iv.id, iv.pallet_id, iv.batch_id, iv.batch_id_ref,
|
|
867
876
|
iv.unit, iv.uom, iv.packing_type, iv.packing_size,
|
|
868
877
|
iv.manufacture_year, iv.carton_id, iv.uom_value,
|
|
869
|
-
coalesce(iv.locked_uom_value,0) as locked_uom_value, iv.qty, coalesce(iv.locked_qty,0) as locked_qty, iv.created_at,
|
|
878
|
+
coalesce(iv.locked_uom_value,0) as locked_uom_value, iv.qty, coalesce(iv.locked_qty,0) as locked_qty, coalesce(pds.unassigned_uom_value,0) as unassigned_uom_value, coalesce(pds.unassigned_qty,0) as unassigned_qty, iv.created_at,
|
|
870
879
|
0 as release_qty, 0 as release_uom_value
|
|
871
880
|
FROM "inventories" "iv"
|
|
881
|
+
LEFT JOIN "product_detail_stocks" "pds" ON "pds"."product_detail_id" = "iv"."product_detail_id"
|
|
872
882
|
INNER JOIN "locations" "loc" ON "loc"."id"="iv"."location_id"
|
|
873
883
|
INNER JOIN "products" "p" ON "p"."id"="iv"."product_id"
|
|
874
884
|
INNER JOIN "warehouse_inventory_assignment_rankings" "wiar" ON "wiar"."location_type"="loc"."type"
|
|
@@ -886,42 +896,55 @@ async function assignToInventory(orderProducts, customerBizplace, context, tx) {
|
|
|
886
896
|
tgt."id", tgt."qty", tgt."pallet_id", tgt."carton_id", tgt."batch_id", tgt."batch_id_ref", tgt."unit",
|
|
887
897
|
tgt."uom", tgt."packing_type", tgt."packing_size", tgt."manufacture_year",
|
|
888
898
|
tgt."locked_qty", tgt."uom_value", tgt."locked_uom_value", src."reserve_qty", src."reserve_uom_value";`, [
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
899
|
+
user.id,
|
|
900
|
+
domain.id,
|
|
901
|
+
customerBizplace.id,
|
|
902
|
+
orderInventory.packingType,
|
|
903
|
+
orderInventory.packingSize,
|
|
904
|
+
orderInventory.product.id,
|
|
905
|
+
warehouse_base_1.INVENTORY_STATUS.STORED,
|
|
906
|
+
warehouse_base_1.LOCATION_TYPE.QUARANTINE,
|
|
907
|
+
warehouse_base_1.LOCATION_TYPE.RESERVE,
|
|
908
|
+
warehouse_base_1.LOCATION_TYPE.STORAGE,
|
|
909
|
+
...queryStrings.values
|
|
910
|
+
]);
|
|
911
|
+
let totalAssigned = updatedInventories[0].reduce((acc, inv) => {
|
|
912
|
+
return acc + inv.reserve_qty;
|
|
913
|
+
}, 0);
|
|
914
|
+
if (orderInventory.releaseQty != totalAssigned) {
|
|
915
|
+
throw new index_1.ValidationError({
|
|
916
|
+
errorCode: 'INSUFFICIENT_STOCK',
|
|
917
|
+
message: 'insufficient stock',
|
|
918
|
+
detail: JSON.stringify({
|
|
919
|
+
code: 'insufficient stock',
|
|
920
|
+
sku: orderInventory.product.sku,
|
|
921
|
+
packingType: orderInventory.packingType,
|
|
922
|
+
packingSize: orderInventory.packingSize,
|
|
923
|
+
uom: orderInventory.uom,
|
|
924
|
+
qty: orderInventory.releaseQty,
|
|
925
|
+
uom_value: orderInventory.releaseUomValue
|
|
926
|
+
})
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
updatedInventories[0].forEach(inv => {
|
|
930
|
+
let oi = Object.assign(Object.assign({}, orderInventory), { inventory: { id: inv.id }, uom: inv.uom, packingType: inv.packing_type, batchId: inv.batch_id, releaseQty: inv.reserve_qty, releaseUomValue: inv.reserve_uom_value, pickedQty: 0, packedQty: 0, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET, domain: { id: domain.id }, bizplace: { id: customerBizplace.id } });
|
|
931
|
+
assignedOrderInventories.push(oi);
|
|
917
932
|
});
|
|
933
|
+
orderProducts[opIdx].orderInventories = assignedOrderInventories;
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
await tx
|
|
937
|
+
.getRepository(warehouse_base_1.ProductDetailStock)
|
|
938
|
+
.createQueryBuilder()
|
|
939
|
+
.update(warehouse_base_1.ProductDetailStock)
|
|
940
|
+
.set({
|
|
941
|
+
unassignedQty: () => `"unassigned_qty" + ${orderInventory.releaseQty}`,
|
|
942
|
+
unassignedUomValue: () => `"unassigned_uom_value" + ${orderInventory.releaseUomValue}`
|
|
943
|
+
})
|
|
944
|
+
.where({ productDetail: orderInventory.productDetail.id })
|
|
945
|
+
.execute();
|
|
918
946
|
}
|
|
919
|
-
updatedInventories[0].forEach(inv => {
|
|
920
|
-
let oi = Object.assign(Object.assign({}, orderInventory), { inventory: { id: inv.id }, uom: inv.uom, packingType: inv.packing_type, batchId: inv.batch_id, releaseQty: inv.reserve_qty, releaseUomValue: inv.reserve_uom_value, pickedQty: 0, packedQty: 0, type: sales_base_1.ORDER_TYPES.RELEASE_OF_GOODS, status: sales_base_1.ORDER_INVENTORY_STATUS.PENDING_WORKSHEET, domain: { id: domain.id }, bizplace: { id: customerBizplace.id } });
|
|
921
|
-
assignedOrderInventories.push(oi);
|
|
922
|
-
});
|
|
923
947
|
}
|
|
924
|
-
orderProducts[opIdx].orderInventories = assignedOrderInventories;
|
|
925
948
|
}
|
|
926
949
|
return orderProducts;
|
|
927
950
|
}
|