tripstorekrabi-shared 1.24.0 → 1.24.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/package.json +1 -1
- package/price.js +5 -5
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -27,7 +27,7 @@ const SELLING_MODE = 0;
|
|
|
27
27
|
const PARTNER_MODE = 1;
|
|
28
28
|
const OPERATOR_MODE = 2;
|
|
29
29
|
|
|
30
|
-
export function getActiveRevision(
|
|
30
|
+
export function getActiveRevision(date, pricing) {
|
|
31
31
|
if (!pricing?.revisions || pricing.revisions.length === 0) return null;
|
|
32
32
|
|
|
33
33
|
const getSafeDate = (dateField) => {
|
|
@@ -40,7 +40,7 @@ export function getActiveRevision(booking, pricing) {
|
|
|
40
40
|
.filter(r => r.isActive !== false)
|
|
41
41
|
.sort((a, b) => getSafeDate(a.startDate)?.valueOf() - getSafeDate(b.startDate)?.valueOf());
|
|
42
42
|
|
|
43
|
-
const bookingDate = getSafeDate(
|
|
43
|
+
const bookingDate = getSafeDate(date)?.startOf('day');
|
|
44
44
|
|
|
45
45
|
if (!bookingDate || !bookingDate.isValid()) {
|
|
46
46
|
return getSortedActive()[0] || pricing.revisions[0];
|
|
@@ -65,8 +65,8 @@ export function getActiveRevision(booking, pricing) {
|
|
|
65
65
|
})[0];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export function getActivePricing(
|
|
69
|
-
const activeRevision = getActiveRevision(
|
|
68
|
+
export function getActivePricing(date, pricing) {
|
|
69
|
+
const activeRevision = getActiveRevision(date, pricing);
|
|
70
70
|
|
|
71
71
|
if (!activeRevision) {
|
|
72
72
|
return pricing;
|
|
@@ -121,7 +121,7 @@ export function calculateInflatedSellingPrice(price, config, forceInflation = fa
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE }) {
|
|
124
|
-
const activeRevision = getActiveRevision(booking, pricing);
|
|
124
|
+
const activeRevision = getActiveRevision(booking.date, pricing);
|
|
125
125
|
|
|
126
126
|
if (!activeRevision) {
|
|
127
127
|
console.warn("Pricing fail-safe triggered: No active pricing revision found.");
|