@unchainedshop/core 4.5.0 → 4.6.1
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/lib/bulk-exporter/createBulkExporter.d.ts +33 -0
- package/lib/bulk-exporter/createBulkExporter.js +46 -0
- package/lib/bulk-exporter/handlers/exportAssortmentsHandler.d.ts +38 -0
- package/lib/bulk-exporter/handlers/exportAssortmentsHandler.js +137 -0
- package/lib/bulk-exporter/handlers/exportFiltersHandler.d.ts +26 -0
- package/lib/bulk-exporter/handlers/exportFiltersHandler.js +88 -0
- package/lib/bulk-exporter/handlers/exportProductsHandler.d.ts +40 -0
- package/lib/bulk-exporter/handlers/exportProductsHandler.js +238 -0
- package/lib/bulk-exporter/handlers/exportUsersHandler.d.ts +40 -0
- package/lib/bulk-exporter/handlers/exportUsersHandler.js +340 -0
- package/lib/bulk-exporter/handlers/generateCSVFileAndUrl.d.ts +13 -0
- package/lib/bulk-exporter/handlers/generateCSVFileAndUrl.js +21 -0
- package/lib/bulk-exporter/handlers/toCSV.d.ts +2 -0
- package/lib/bulk-exporter/handlers/toCSV.js +5 -0
- package/lib/bulk-exporter/index.d.ts +3 -0
- package/lib/bulk-exporter/index.js +3 -0
- package/lib/bulk-importer/handlers/assortment/create.d.ts +0 -2
- package/lib/bulk-importer/handlers/assortment/create.js +0 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +0 -2
- package/lib/bulk-importer/handlers/assortment/update.js +0 -1
- package/lib/bulk-importer/handlers/product/create.js +2 -2
- package/lib/bulk-importer/handlers/product/update.js +2 -2
- package/lib/core-index.d.ts +7 -1
- package/lib/core-index.js +5 -1
- package/lib/directors/EnrollmentDirector.d.ts +4 -1
- package/lib/directors/PaymentDirector.js +2 -0
- package/lib/directors/WorkerAdapter.d.ts +2 -0
- package/lib/services/fulfillQuotation.d.ts +3 -0
- package/lib/services/{fullfillQuotation.js → fulfillQuotation.js} +3 -3
- package/lib/services/index.d.ts +2 -2
- package/lib/services/index.js +2 -2
- package/lib/services/processOrder.js +17 -9
- package/lib/services/rejectQuotation.js +1 -1
- package/package.json +21 -20
- package/lib/services/fullfillQuotation.d.ts +0 -3
package/lib/services/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import { initializeEnrollmentService } from "./initializeEnrollment.js";
|
|
|
31
31
|
import { activateEnrollmentService } from "./activateEnrollment.js";
|
|
32
32
|
import { terminateEnrollmentService } from "./terminateEnrollment.js";
|
|
33
33
|
import { invalidateFilterCacheService } from "./invalidateFilterCache.js";
|
|
34
|
-
import {
|
|
34
|
+
import { fulfillQuotationService } from "./fulfillQuotation.js";
|
|
35
35
|
import { processQuotationService } from "./processQuotation.js";
|
|
36
36
|
import { proposeQuotationService } from "./proposeQuotation.js";
|
|
37
37
|
import { rejectQuotationService } from "./rejectQuotation.js";
|
|
@@ -127,7 +127,7 @@ export default function initServices(modules, customServices = {}) {
|
|
|
127
127
|
terminateEnrollment: terminateEnrollmentService,
|
|
128
128
|
},
|
|
129
129
|
quotations: {
|
|
130
|
-
|
|
130
|
+
fulfillQuotation: fulfillQuotationService,
|
|
131
131
|
processQuotation: processQuotationService,
|
|
132
132
|
proposeQuotation: proposeQuotationService,
|
|
133
133
|
rejectQuotation: rejectQuotationService,
|
|
@@ -3,14 +3,16 @@ import { createEnrollmentFromCheckoutService } from "./createEnrollmentFromCheck
|
|
|
3
3
|
import { ProductType } from '@unchainedshop/core-products';
|
|
4
4
|
import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
|
|
5
5
|
import { WarehousingDirector, DeliveryDirector, PaymentDirector } from "../directors/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { fulfillQuotationService } from "./fulfillQuotation.js";
|
|
7
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
8
|
+
const logger = createLogger('unchained:core:processOrder');
|
|
7
9
|
const isAutoConfirmationEnabled = async ({ orderPayment, orderDelivery, }, modules) => {
|
|
8
10
|
if (orderPayment.status !== OrderPaymentStatus.PAID) {
|
|
9
11
|
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
10
12
|
paymentProviderId: orderPayment.paymentProviderId,
|
|
11
13
|
});
|
|
12
14
|
if (!paymentProvider)
|
|
13
|
-
throw new Error(
|
|
15
|
+
throw new Error(`Payment provider not found: ${orderPayment.paymentProviderId}`);
|
|
14
16
|
const actions = await PaymentDirector.actions(paymentProvider, {}, { modules });
|
|
15
17
|
if (!actions.isPayLaterAllowed())
|
|
16
18
|
return false;
|
|
@@ -20,7 +22,7 @@ const isAutoConfirmationEnabled = async ({ orderPayment, orderDelivery, }, modul
|
|
|
20
22
|
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
21
23
|
});
|
|
22
24
|
if (!deliveryProvider)
|
|
23
|
-
throw new Error(
|
|
25
|
+
throw new Error(`Delivery provider not found: ${orderDelivery.deliveryProviderId}`);
|
|
24
26
|
const director = await DeliveryDirector.actions(deliveryProvider, {}, { modules });
|
|
25
27
|
if (!director.isAutoReleaseAllowed())
|
|
26
28
|
return false;
|
|
@@ -31,7 +33,7 @@ const findNextStatus = async (status, order, modules) => {
|
|
|
31
33
|
if (status === null) {
|
|
32
34
|
return OrderStatus.PENDING;
|
|
33
35
|
}
|
|
34
|
-
if (status === OrderStatus.
|
|
36
|
+
if (status === OrderStatus.FULFILLED || status === OrderStatus.REJECTED) {
|
|
35
37
|
return status;
|
|
36
38
|
}
|
|
37
39
|
const orderPayment = order.paymentId &&
|
|
@@ -52,10 +54,10 @@ const findNextStatus = async (status, order, modules) => {
|
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
if (status === OrderStatus.CONFIRMED) {
|
|
55
|
-
const
|
|
57
|
+
const readyForFulfillment = orderDelivery.status === OrderDeliveryStatus.DELIVERED &&
|
|
56
58
|
orderPayment.status === OrderPaymentStatus.PAID;
|
|
57
|
-
if (
|
|
58
|
-
return OrderStatus.
|
|
59
|
+
if (readyForFulfillment) {
|
|
60
|
+
return OrderStatus.FULFILLED;
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
return status;
|
|
@@ -125,9 +127,15 @@ export async function processOrderService(initialOrder, orderTransactionContext)
|
|
|
125
127
|
const quotation = await this.quotations.findQuotation({
|
|
126
128
|
quotationId: orderPosition.quotationId,
|
|
127
129
|
});
|
|
128
|
-
if (!quotation)
|
|
130
|
+
if (!quotation) {
|
|
131
|
+
logger.warn('Quotation not found during order fulfillment', {
|
|
132
|
+
orderId,
|
|
133
|
+
orderPositionId: orderPosition._id,
|
|
134
|
+
quotationId: orderPosition.quotationId,
|
|
135
|
+
});
|
|
129
136
|
return;
|
|
130
|
-
|
|
137
|
+
}
|
|
138
|
+
await fulfillQuotationService.bind(this)(quotation, {
|
|
131
139
|
orderId,
|
|
132
140
|
orderPositionId: orderPosition._id,
|
|
133
141
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuotationStatus } from '@unchainedshop/core-quotations';
|
|
2
2
|
import { processQuotationService } from "./processQuotation.js";
|
|
3
3
|
export async function rejectQuotationService(quotation, { quotationContext }) {
|
|
4
|
-
if (quotation.status === QuotationStatus.
|
|
4
|
+
if (quotation.status === QuotationStatus.FULFILLED)
|
|
5
5
|
return quotation;
|
|
6
6
|
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
7
7
|
status: QuotationStatus.REJECTED,
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core",
|
|
3
|
-
"
|
|
3
|
+
"description": "Core orchestration package for the Unchained Engine with business services and directors",
|
|
4
|
+
"version": "4.6.1",
|
|
4
5
|
"main": "lib/core-index.js",
|
|
5
6
|
"types": "lib/core-index.d.ts",
|
|
6
7
|
"type": "module",
|
|
@@ -34,25 +35,25 @@
|
|
|
34
35
|
},
|
|
35
36
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@unchainedshop/core-assortments": "^4.
|
|
38
|
-
"@unchainedshop/core-bookmarks": "^4.
|
|
39
|
-
"@unchainedshop/core-countries": "^4.
|
|
40
|
-
"@unchainedshop/core-currencies": "^4.
|
|
41
|
-
"@unchainedshop/core-delivery": "^4.
|
|
42
|
-
"@unchainedshop/core-enrollments": "^4.
|
|
43
|
-
"@unchainedshop/core-events": "^4.
|
|
44
|
-
"@unchainedshop/core-files": "^4.
|
|
45
|
-
"@unchainedshop/core-filters": "^4.
|
|
46
|
-
"@unchainedshop/core-languages": "^4.
|
|
47
|
-
"@unchainedshop/core-orders": "^4.
|
|
48
|
-
"@unchainedshop/core-payment": "^4.
|
|
49
|
-
"@unchainedshop/core-products": "^4.
|
|
50
|
-
"@unchainedshop/core-quotations": "^4.
|
|
51
|
-
"@unchainedshop/core-users": "^4.
|
|
52
|
-
"@unchainedshop/core-warehousing": "^4.
|
|
53
|
-
"@unchainedshop/core-worker": "^4.
|
|
54
|
-
"@unchainedshop/logger": "^4.
|
|
55
|
-
"@unchainedshop/utils": "^4.
|
|
38
|
+
"@unchainedshop/core-assortments": "^4.6.0",
|
|
39
|
+
"@unchainedshop/core-bookmarks": "^4.6.0",
|
|
40
|
+
"@unchainedshop/core-countries": "^4.6.0",
|
|
41
|
+
"@unchainedshop/core-currencies": "^4.6.0",
|
|
42
|
+
"@unchainedshop/core-delivery": "^4.6.0",
|
|
43
|
+
"@unchainedshop/core-enrollments": "^4.6.0",
|
|
44
|
+
"@unchainedshop/core-events": "^4.6.0",
|
|
45
|
+
"@unchainedshop/core-files": "^4.6.0",
|
|
46
|
+
"@unchainedshop/core-filters": "^4.6.0",
|
|
47
|
+
"@unchainedshop/core-languages": "^4.6.0",
|
|
48
|
+
"@unchainedshop/core-orders": "^4.6.0",
|
|
49
|
+
"@unchainedshop/core-payment": "^4.6.0",
|
|
50
|
+
"@unchainedshop/core-products": "^4.6.0",
|
|
51
|
+
"@unchainedshop/core-quotations": "^4.6.0",
|
|
52
|
+
"@unchainedshop/core-users": "^4.6.0",
|
|
53
|
+
"@unchainedshop/core-warehousing": "^4.6.0",
|
|
54
|
+
"@unchainedshop/core-worker": "^4.6.0",
|
|
55
|
+
"@unchainedshop/logger": "^4.6.0",
|
|
56
|
+
"@unchainedshop/utils": "^4.6.0",
|
|
56
57
|
"minipass-json-stream": "^1.0.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|