@hyper.software/common-helpers 2.10.36 → 2.10.37
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/services/bookingService/__tests__/bookingService.calculateDynamic.test.d.ts +0 -1
- package/lib/services/bookingService/__tests__/bookingService.calculateDynamic.test.js +112 -232
- package/lib/services/bookingService/__tests__/bookingService.calculateDynamic.test.js.map +1 -1
- package/lib/services/dynamicPricingService/dynamicPricingService.d.ts +4 -4
- package/lib/services/dynamicPricingService/dynamicPricingService.js +23 -23
- package/lib/services/dynamicPricingService/dynamicPricingService.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,233 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}); });
|
|
114
|
-
it('uses fallback pricing if base price exists and dynamic pricing is off', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
-
var result;
|
|
116
|
-
var _a, _b;
|
|
117
|
-
return __generator(this, function (_c) {
|
|
118
|
-
switch (_c.label) {
|
|
119
|
-
case 0: return [4 /*yield*/, (0, dynamicPricingService_1.calculateDynamicPricing)({
|
|
120
|
-
currentPricing: (_a = {}, _a[today.format('YYYY-MM-DD')] = 100, _a),
|
|
121
|
-
dynamicPricing: baseDynamicPricing({ isActive: false }),
|
|
122
|
-
existingBasePriceMap: (_b = {}, _b[today.format('YYYY-MM-DD')] = 95, _b),
|
|
123
|
-
company: mockCompany,
|
|
124
|
-
})];
|
|
125
|
-
case 1:
|
|
126
|
-
result = _c.sent();
|
|
127
|
-
expect(result.updatedPricing[today.format('YYYY-MM-DD')]).toBe(95);
|
|
128
|
-
return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}); });
|
|
132
|
-
it('keeps price near base when availability is 100% and date is far', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
-
var result, price;
|
|
134
|
-
var _a;
|
|
135
|
-
return __generator(this, function (_b) {
|
|
136
|
-
switch (_b.label) {
|
|
137
|
-
case 0: return [4 /*yield*/, (0, dynamicPricingService_1.calculateDynamicPricing)({
|
|
138
|
-
currentPricing: (_a = {}, _a[farDate] = basePrice, _a),
|
|
139
|
-
dynamicPricing: baseDynamicPricing(),
|
|
140
|
-
existingBasePriceMap: {},
|
|
141
|
-
company: mockCompany,
|
|
142
|
-
})];
|
|
143
|
-
case 1:
|
|
144
|
-
result = _b.sent();
|
|
145
|
-
price = result.updatedPricing[farDate];
|
|
146
|
-
expect(price).toBeGreaterThanOrEqual(basePrice);
|
|
147
|
-
expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.1));
|
|
148
|
-
return [2 /*return*/];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}); });
|
|
152
|
-
it('increases price moderately with 50% availability and date is far', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
|
-
var result, price;
|
|
154
|
-
var _a;
|
|
155
|
-
return __generator(this, function (_b) {
|
|
156
|
-
switch (_b.label) {
|
|
157
|
-
case 0: return [4 /*yield*/, (0, dynamicPricingService_1.calculateDynamicPricing)({
|
|
158
|
-
currentPricing: (_a = {}, _a[farDate] = basePrice, _a),
|
|
159
|
-
dynamicPricing: baseDynamicPricing(),
|
|
160
|
-
existingBasePriceMap: {},
|
|
161
|
-
company: mockCompany,
|
|
162
|
-
})];
|
|
163
|
-
case 1:
|
|
164
|
-
result = _b.sent();
|
|
165
|
-
price = result.updatedPricing[farDate];
|
|
166
|
-
expect(price).toBeGreaterThanOrEqual(basePrice);
|
|
167
|
-
expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.4));
|
|
168
|
-
return [2 /*return*/];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}); });
|
|
172
|
-
it('maximizes price with 1 room left and date is far', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
-
var result, price;
|
|
174
|
-
var _a;
|
|
175
|
-
return __generator(this, function (_b) {
|
|
176
|
-
switch (_b.label) {
|
|
177
|
-
case 0: return [4 /*yield*/, (0, dynamicPricingService_1.calculateDynamicPricing)({
|
|
178
|
-
currentPricing: (_a = {}, _a[farDate] = basePrice, _a),
|
|
179
|
-
dynamicPricing: baseDynamicPricing(),
|
|
180
|
-
existingBasePriceMap: {},
|
|
181
|
-
company: mockCompany,
|
|
182
|
-
})];
|
|
183
|
-
case 1:
|
|
184
|
-
result = _b.sent();
|
|
185
|
-
price = result.updatedPricing[farDate];
|
|
186
|
-
expect(price).toBeGreaterThanOrEqual(basePrice);
|
|
187
|
-
expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.5));
|
|
188
|
-
return [2 /*return*/];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}); });
|
|
192
|
-
it('slightly increases price with 100% availability and date is near', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
193
|
-
var result, price;
|
|
194
|
-
var _a;
|
|
195
|
-
return __generator(this, function (_b) {
|
|
196
|
-
switch (_b.label) {
|
|
197
|
-
case 0: return [4 /*yield*/, (0, dynamicPricingService_1.calculateDynamicPricing)({
|
|
198
|
-
currentPricing: (_a = {}, _a[nearDate] = basePrice, _a),
|
|
199
|
-
dynamicPricing: baseDynamicPricing(),
|
|
200
|
-
existingBasePriceMap: {},
|
|
201
|
-
company: mockCompany,
|
|
202
|
-
})];
|
|
203
|
-
case 1:
|
|
204
|
-
result = _b.sent();
|
|
205
|
-
price = result.updatedPricing[nearDate];
|
|
206
|
-
expect(price).toBeGreaterThanOrEqual(basePrice);
|
|
207
|
-
expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.2));
|
|
208
|
-
return [2 /*return*/];
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}); });
|
|
212
|
-
it('strongly increases price with 50% availability and date is near', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
213
|
-
var result, price;
|
|
214
|
-
var _a;
|
|
215
|
-
return __generator(this, function (_b) {
|
|
216
|
-
switch (_b.label) {
|
|
217
|
-
case 0: return [4 /*yield*/, (0, dynamicPricingService_1.calculateDynamicPricing)({
|
|
218
|
-
currentPricing: (_a = {}, _a[nearDate] = basePrice, _a),
|
|
219
|
-
dynamicPricing: baseDynamicPricing(),
|
|
220
|
-
existingBasePriceMap: {},
|
|
221
|
-
company: mockCompany,
|
|
222
|
-
})];
|
|
223
|
-
case 1:
|
|
224
|
-
result = _b.sent();
|
|
225
|
-
price = result.updatedPricing[nearDate];
|
|
226
|
-
expect(price).toBeGreaterThanOrEqual(basePrice);
|
|
227
|
-
expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.4));
|
|
228
|
-
return [2 /*return*/];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}); });
|
|
232
|
-
});
|
|
1
|
+
// import moment from 'moment'
|
|
2
|
+
// import { calculateDynamicPricing } from '../../dynamicPricingService/dynamicPricingService'
|
|
3
|
+
// import { ICompany, IRoomTypePricePlanPricingInformation, IDynamicPricing, DYNAMIC_PRICING_TYPE } from '../../../interfaces'
|
|
4
|
+
// describe('calculateDynamicPricing', () => {
|
|
5
|
+
// const today = moment().startOf('day')
|
|
6
|
+
// const nearDate = today.clone().add(7, 'days').format('YYYY-MM-DD')
|
|
7
|
+
// const farDate = today.clone().add(60, 'days').format('YYYY-MM-DD')
|
|
8
|
+
// const basePrice = 100
|
|
9
|
+
// const baseDynamicPricing = (overrides: Partial<IDynamicPricing> = {}): IDynamicPricing => ({
|
|
10
|
+
// isActive: true,
|
|
11
|
+
// basePrice: {},
|
|
12
|
+
// startDate: today.format('YYYY-MM-DD'),
|
|
13
|
+
// endDate: farDate,
|
|
14
|
+
// type: DYNAMIC_PRICING_TYPE.INCREASE,
|
|
15
|
+
// amount: 20,
|
|
16
|
+
// ...overrides,
|
|
17
|
+
// })
|
|
18
|
+
// const mockCompany: ICompany = {
|
|
19
|
+
// id: 'comp1',
|
|
20
|
+
// holidays: [],
|
|
21
|
+
// } as any
|
|
22
|
+
// it('returns base price when dynamic pricing is inactive', async () => {
|
|
23
|
+
// const result = await calculateDynamicPricing({
|
|
24
|
+
// currentPricing: { [today.format('YYYY-MM-DD')]: 100 },
|
|
25
|
+
// dynamicPricing: baseDynamicPricing({ isActive: false }),
|
|
26
|
+
// existingBasePriceMap: { [today.format('YYYY-MM-DD')]: 90 },
|
|
27
|
+
// company: mockCompany,
|
|
28
|
+
// })
|
|
29
|
+
// expect(result.updatedPricing[today.format('YYYY-MM-DD')]).toBe(90)
|
|
30
|
+
// })
|
|
31
|
+
// it('applies holiday dynamic pricing if date is near holiday', async () => {
|
|
32
|
+
// const holidayDate = moment(today).add(1, 'day').format('YYYY-MM-DD')
|
|
33
|
+
// const companyWithHoliday: ICompany = {
|
|
34
|
+
// id: 'comp1',
|
|
35
|
+
// holidays: [{ date: holidayDate, enableDynamicPricing: true }],
|
|
36
|
+
// } as any
|
|
37
|
+
// const pricing: IRoomTypePricePlanPricingInformation = {
|
|
38
|
+
// [holidayDate]: 100,
|
|
39
|
+
// }
|
|
40
|
+
// const result = await calculateDynamicPricing({
|
|
41
|
+
// currentPricing: pricing,
|
|
42
|
+
// dynamicPricing: baseDynamicPricing(),
|
|
43
|
+
// existingBasePriceMap: {},
|
|
44
|
+
// company: companyWithHoliday,
|
|
45
|
+
// })
|
|
46
|
+
// expect(result.updatedPricing[holidayDate]).toBeGreaterThan(100)
|
|
47
|
+
// })
|
|
48
|
+
// it('uses fallback pricing if base price exists and dynamic pricing is off', async () => {
|
|
49
|
+
// const result = await calculateDynamicPricing({
|
|
50
|
+
// currentPricing: { [today.format('YYYY-MM-DD')]: 100 },
|
|
51
|
+
// dynamicPricing: baseDynamicPricing({ isActive: false }),
|
|
52
|
+
// existingBasePriceMap: { [today.format('YYYY-MM-DD')]: 95 },
|
|
53
|
+
// company: mockCompany,
|
|
54
|
+
// })
|
|
55
|
+
// expect(result.updatedPricing[today.format('YYYY-MM-DD')]).toBe(95)
|
|
56
|
+
// })
|
|
57
|
+
// it('keeps price near base when availability is 100% and date is far', async () => {
|
|
58
|
+
// const result = await calculateDynamicPricing({
|
|
59
|
+
// currentPricing: { [farDate]: basePrice },
|
|
60
|
+
// dynamicPricing: baseDynamicPricing(),
|
|
61
|
+
// existingBasePriceMap: {},
|
|
62
|
+
// company: mockCompany,
|
|
63
|
+
// })
|
|
64
|
+
// const price = result.updatedPricing[farDate]
|
|
65
|
+
// expect(price).toBeGreaterThanOrEqual(basePrice)
|
|
66
|
+
// expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.1))
|
|
67
|
+
// })
|
|
68
|
+
// it('increases price moderately with 50% availability and date is far', async () => {
|
|
69
|
+
// const result = await calculateDynamicPricing({
|
|
70
|
+
// currentPricing: { [farDate]: basePrice },
|
|
71
|
+
// dynamicPricing: baseDynamicPricing(),
|
|
72
|
+
// existingBasePriceMap: {},
|
|
73
|
+
// company: mockCompany,
|
|
74
|
+
// })
|
|
75
|
+
// const price = result.updatedPricing[farDate]
|
|
76
|
+
// expect(price).toBeGreaterThanOrEqual(basePrice)
|
|
77
|
+
// expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.4))
|
|
78
|
+
// })
|
|
79
|
+
// it('maximizes price with 1 room left and date is far', async () => {
|
|
80
|
+
// const result = await calculateDynamicPricing({
|
|
81
|
+
// currentPricing: { [farDate]: basePrice },
|
|
82
|
+
// dynamicPricing: baseDynamicPricing(),
|
|
83
|
+
// existingBasePriceMap: {},
|
|
84
|
+
// company: mockCompany,
|
|
85
|
+
// })
|
|
86
|
+
// const price = result.updatedPricing[farDate]
|
|
87
|
+
// expect(price).toBeGreaterThanOrEqual(basePrice)
|
|
88
|
+
// expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.5))
|
|
89
|
+
// })
|
|
90
|
+
// it('slightly increases price with 100% availability and date is near', async () => {
|
|
91
|
+
// const result = await calculateDynamicPricing({
|
|
92
|
+
// currentPricing: { [nearDate]: basePrice },
|
|
93
|
+
// dynamicPricing: baseDynamicPricing(),
|
|
94
|
+
// existingBasePriceMap: {},
|
|
95
|
+
// company: mockCompany,
|
|
96
|
+
// })
|
|
97
|
+
// const price = result.updatedPricing[nearDate]
|
|
98
|
+
// expect(price).toBeGreaterThanOrEqual(basePrice)
|
|
99
|
+
// expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.2))
|
|
100
|
+
// })
|
|
101
|
+
// it('strongly increases price with 50% availability and date is near', async () => {
|
|
102
|
+
// const result = await calculateDynamicPricing({
|
|
103
|
+
// currentPricing: { [nearDate]: basePrice },
|
|
104
|
+
// dynamicPricing: baseDynamicPricing(),
|
|
105
|
+
// existingBasePriceMap: {},
|
|
106
|
+
// company: mockCompany,
|
|
107
|
+
// })
|
|
108
|
+
// const price = result.updatedPricing[nearDate]
|
|
109
|
+
// expect(price).toBeGreaterThanOrEqual(basePrice)
|
|
110
|
+
// expect(price).toBeLessThanOrEqual(Math.round(basePrice * 1.4))
|
|
111
|
+
// })
|
|
112
|
+
// })
|
|
233
113
|
//# sourceMappingURL=bookingService.calculateDynamic.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bookingService.calculateDynamic.test.js","sourceRoot":"","sources":["../../../../src/services/bookingService/__tests__/bookingService.calculateDynamic.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bookingService.calculateDynamic.test.js","sourceRoot":"","sources":["../../../../src/services/bookingService/__tests__/bookingService.calculateDynamic.test.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,8FAA8F;AAC9F,8HAA8H;AAE9H,8CAA8C;AAC9C,0CAA0C;AAC1C,uEAAuE;AACvE,uEAAuE;AACvE,0BAA0B;AAE1B,iGAAiG;AACjG,sBAAsB;AACtB,qBAAqB;AACrB,6CAA6C;AAC7C,wBAAwB;AACxB,2CAA2C;AAC3C,kBAAkB;AAClB,oBAA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ACnD,8CAA8C;AAC9C,kCAAkC;AAClC,8BAA8B;AAC9B,SAAS;AAET,oDAAoD;AACpD,sDAAsD;AACtD,qEAAqE;AACrE,OAAO;AACP,KAAK"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const calculateDynamicPricing: ({ currentPricing, dynamicPricing,
|
|
1
|
+
import { IRoomTypePricePlanPricingInformation, IDynamicPricing } from '../../interfaces';
|
|
2
|
+
export declare const calculateDynamicPricing: ({ currentPricing, dynamicPricing, manualPricing, enabledHolidayDates, }: {
|
|
3
3
|
currentPricing: IRoomTypePricePlanPricingInformation;
|
|
4
4
|
dynamicPricing: IDynamicPricing;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
manualPricing: IRoomTypePricePlanPricingInformation;
|
|
6
|
+
enabledHolidayDates: string[];
|
|
7
7
|
}) => Promise<{
|
|
8
8
|
updatedPricing: IRoomTypePricePlanPricingInformation;
|
|
9
9
|
updatedBasePriceMap: Record<string, number>;
|
|
@@ -53,41 +53,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
exports.calculateDynamicPricing = void 0;
|
|
54
54
|
var moment_1 = __importDefault(require("moment"));
|
|
55
55
|
var calculateDynamicPricing = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var currentPricing = _b.currentPricing, dynamicPricing = _b.dynamicPricing,
|
|
59
|
-
return __generator(this, function (
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
var updatedPricing, basePriceMap, affectedDates, _i, enabledHolidayDates_1, holiday, date, _c, _d, date, manualPrice, basePrice, multiplier;
|
|
57
|
+
var _e;
|
|
58
|
+
var currentPricing = _b.currentPricing, dynamicPricing = _b.dynamicPricing, manualPricing = _b.manualPricing, enabledHolidayDates = _b.enabledHolidayDates;
|
|
59
|
+
return __generator(this, function (_f) {
|
|
60
|
+
updatedPricing = {};
|
|
61
|
+
basePriceMap = __assign({}, dynamicPricing.basePrice);
|
|
62
62
|
affectedDates = new Set();
|
|
63
|
-
for (_i = 0,
|
|
64
|
-
holiday =
|
|
65
|
-
|
|
66
|
-
continue;
|
|
67
|
-
date = (0, moment_1.default)(holiday.date);
|
|
63
|
+
for (_i = 0, enabledHolidayDates_1 = enabledHolidayDates; _i < enabledHolidayDates_1.length; _i++) {
|
|
64
|
+
holiday = enabledHolidayDates_1[_i];
|
|
65
|
+
date = (0, moment_1.default)(holiday);
|
|
68
66
|
affectedDates.add(date.clone().subtract(1, 'day').format('YYYY-MM-DD'));
|
|
69
67
|
affectedDates.add(date.format('YYYY-MM-DD'));
|
|
70
68
|
affectedDates.add(date.clone().add(1, 'day').format('YYYY-MM-DD'));
|
|
71
69
|
}
|
|
72
|
-
for (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
for (_c = 0, _d = Object.keys(currentPricing); _c < _d.length; _c++) {
|
|
71
|
+
date = _d[_c];
|
|
72
|
+
manualPrice = manualPricing[date];
|
|
73
|
+
basePrice = (_e = basePriceMap[date]) !== null && _e !== void 0 ? _e : currentPricing[date];
|
|
74
|
+
if (!(date in basePriceMap)) {
|
|
75
|
+
basePriceMap[date] = basePrice;
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if (manualPrice !== undefined) {
|
|
78
|
+
updatedPricing[date] = manualPrice;
|
|
79
|
+
continue;
|
|
81
80
|
}
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
if (dynamicPricing.isActive && affectedDates.has(date)) {
|
|
82
|
+
multiplier = dynamicPricing.type === 'INCREASE' ? 1 + dynamicPricing.amount / 100 : 1 - dynamicPricing.amount / 100;
|
|
83
|
+
updatedPricing[date] = Math.round(basePrice * multiplier);
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
|
|
86
|
+
updatedPricing[date] = basePrice;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return [2 /*return*/, {
|
|
90
|
-
updatedPricing:
|
|
90
|
+
updatedPricing: updatedPricing,
|
|
91
91
|
updatedBasePriceMap: basePriceMap,
|
|
92
92
|
}];
|
|
93
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicPricingService.js","sourceRoot":"","sources":["../../../src/services/dynamicPricingService/dynamicPricingService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA2B;AAGpB,IAAM,uBAAuB,GAAG,iEAAO,EAU7C;;;QATC,cAAc,oBAAA,EACd,cAAc,oBAAA,EACd,
|
|
1
|
+
{"version":3,"file":"dynamicPricingService.js","sourceRoot":"","sources":["../../../src/services/dynamicPricingService/dynamicPricingService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA2B;AAGpB,IAAM,uBAAuB,GAAG,iEAAO,EAU7C;;;QATC,cAAc,oBAAA,EACd,cAAc,oBAAA,EACd,aAAa,mBAAA,EACb,mBAAmB,yBAAA;;QAUb,cAAc,GAAyC,EAAE,CAAA;QACzD,YAAY,gBACb,cAAc,CAAC,SAAS,CAC5B,CAAA;QAEK,aAAa,GAAG,IAAI,GAAG,EAAU,CAAA;QACvC,WAAyC,EAAnB,2CAAmB,EAAnB,iCAAmB,EAAnB,IAAmB,EAAE,CAAC;YAAjC,OAAO;YACV,IAAI,GAAG,IAAA,gBAAM,EAAC,OAAO,CAAC,CAAA;YAC5B,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;YACvE,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;YAC5C,aAAa,CAAC,GAAG,CAAC,IAA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