@unchainedshop/core-quotations 4.8.18 → 4.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,8 +31,8 @@ export declare const configureQuotationsModule: ({ db, migrationRepository, opti
|
|
|
31
31
|
sort?: SortOption[];
|
|
32
32
|
}, options?: mongodb.FindOptions) => Promise<Quotation[]>;
|
|
33
33
|
normalizedStatus: (quotation: Quotation) => QuotationStatus;
|
|
34
|
-
isExpired(quotation: Quotation, { referenceDate }
|
|
35
|
-
referenceDate
|
|
34
|
+
isExpired(quotation: Quotation, { referenceDate }?: {
|
|
35
|
+
referenceDate?: Date;
|
|
36
36
|
}): boolean;
|
|
37
37
|
isProposalValid(quotation: Quotation): boolean;
|
|
38
38
|
create: ({ countryCode, currencyCode, ...quotationData }: QuotationData & {
|
|
@@ -83,7 +83,7 @@ export const configureQuotationsModule = async ({ db, migrationRepository, optio
|
|
|
83
83
|
updated: new Date(),
|
|
84
84
|
...fieldKeys.reduce((set, key) => ({ ...set, [key]: values[key] }), {}),
|
|
85
85
|
},
|
|
86
|
-
});
|
|
86
|
+
}, { returnDocument: 'after' });
|
|
87
87
|
if (!quotation)
|
|
88
88
|
return null;
|
|
89
89
|
await emit('QUOTATION_UPDATE', { quotation, fields: fieldKeys });
|
|
@@ -118,7 +118,7 @@ export const configureQuotationsModule = async ({ db, migrationRepository, optio
|
|
|
118
118
|
? QuotationStatus.REQUESTED
|
|
119
119
|
: quotation.status;
|
|
120
120
|
},
|
|
121
|
-
isExpired(quotation, { referenceDate }) {
|
|
121
|
+
isExpired(quotation, { referenceDate } = {}) {
|
|
122
122
|
const relevantDate = referenceDate ? new Date(referenceDate) : new Date();
|
|
123
123
|
if (!quotation.expires)
|
|
124
124
|
return false;
|
|
@@ -145,10 +145,13 @@ export const configureQuotationsModule = async ({ db, migrationRepository, optio
|
|
|
145
145
|
return quotation;
|
|
146
146
|
},
|
|
147
147
|
deleteRequestedUserQuotations: async (userId) => {
|
|
148
|
-
const
|
|
148
|
+
const selector = {
|
|
149
149
|
userId,
|
|
150
150
|
status: { $in: [QuotationStatus.REQUESTED, null] },
|
|
151
|
-
}
|
|
151
|
+
};
|
|
152
|
+
const quotations = await Quotations.find(selector, { projection: { _id: 1 } }).toArray();
|
|
153
|
+
const { deletedCount } = await Quotations.deleteMany(selector);
|
|
154
|
+
await Promise.all(quotations.map((quotation) => emit('QUOTATION_REMOVE', { quotationId: quotation._id })));
|
|
152
155
|
return deletedCount;
|
|
153
156
|
},
|
|
154
157
|
updateContext: updateQuotationFields(['context']),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-quotations",
|
|
3
3
|
"description": "Quotation and RFQ management module for the Unchained Engine",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.20",
|
|
5
5
|
"main": "lib/quotations-index.js",
|
|
6
6
|
"types": "lib/quotations-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@unchainedshop/utils": "^4.8.12"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^26.2.0",
|
|
44
44
|
"typescript": "^5.8.3"
|
|
45
45
|
}
|
|
46
46
|
}
|