@driveflux/api-functions 0.0.3 → 0.0.4
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/auth/confirm.js +73 -327
- package/dist/auth/emails.js +43 -210
- package/dist/auth/formatter.js +11 -11
- package/dist/auth/otp.js +122 -392
- package/dist/auth/register.d.ts +1 -1
- package/dist/auth/register.js +100 -396
- package/dist/auth/tokens.js +115 -430
- package/dist/auth/verifications.js +154 -512
- package/dist/constants.js +5 -4
- package/dist/mailjet/calls/manage-contacts-in-list.js +22 -166
- package/dist/mailjet/calls/manage-subscription-status.js +13 -153
- package/dist/mailjet/calls/request-service.js +18 -183
- package/dist/mailjet/refresh-email-preferences.js +26 -225
- package/dist/mailjet/set-contact.js +23 -214
- package/dist/mailjet/types.js +2 -1
- package/dist/mailjet/utils/convert-to-array.js +9 -58
- package/dist/mailjet/utils/extract-email-preferences.js +41 -217
- package/dist/mailjet/utils/lists.js +30 -249
- package/dist/mailjet/utils/update-email-references.js +27 -208
- package/dist/notion/client.js +48 -197
- package/dist/notion/helpful.js +29 -170
- package/dist/notion/schemas/block.js +49 -43
- package/dist/notion/schemas/common.js +17 -14
- package/dist/notion/schemas/database.js +125 -159
- package/dist/notion/schemas/emoji.js +3 -2
- package/dist/notion/schemas/file.js +10 -10
- package/dist/notion/schemas/kb.js +9 -8
- package/dist/notion/schemas/page.js +126 -171
- package/dist/notion/schemas/parent.js +9 -8
- package/dist/notion/schemas/user.js +21 -20
- package/dist/reservation/agree.js +19 -158
- package/dist/reservation/checks.js +23 -178
- package/dist/reservation/display-vehicle.js +142 -514
- package/dist/reservation/fetch-or-create.js +197 -482
- package/dist/reservation/invoice.d.ts.map +1 -1
- package/dist/reservation/invoice.js +199 -501
- package/dist/reservation/invoice.js.map +1 -1
- package/dist/reservation/payer.js +28 -177
- package/dist/reservation/reserve.js +31 -191
- package/dist/reservation/types.js +2 -1
- package/dist/reservation/vehicle.js +24 -186
- package/dist/slack.js +67 -273
- package/dist/validation.d.ts +11 -11
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +63 -96
- package/dist/validation.js.map +1 -1
- package/dist/vehicle/vehicle-pricing/constants.js +33 -36
- package/dist/vehicle/vehicle-pricing/index.js +99 -257
- package/dist/vehicle/vehicle-pricing/types.js +2 -1
- package/package.json +10 -10
|
@@ -5,120 +5,55 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
5
5
|
import { EMPTY_MATRIX } from './constants';
|
|
6
6
|
/**
|
|
7
7
|
* This is a last moment feature the CEO asked for and was not properly designed
|
|
8
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export const getRecommendedMotorcycleDeposit = (baseline) => {
|
|
9
10
|
return Math.max(Math.min(baseline * 5, 1500), 1000);
|
|
10
11
|
};
|
|
11
|
-
export
|
|
12
|
+
export const getHostsMatrix = (pricingData, baseline, tier, flatPricing) => {
|
|
12
13
|
// Let's not mutate percentages
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for(var _iterator1 = mileagePackages[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
24
|
-
var mileagePackage = _step1.value;
|
|
25
|
-
if (plan === 'plan1') {
|
|
26
|
-
if (tier === 'tierCustom') {
|
|
27
|
-
newMatrix[plan][mileagePackage] = 0;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
newMatrix[plan][mileagePackage] = Number(pricingData.hostEarnings.ultraTiers[tier]);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
newMatrix[plan][mileagePackage] = round(baseline * (flatPricing ? baseCoefficients[mileagePackage] : newMatrix[plan][mileagePackage]));
|
|
14
|
+
const newMatrix = cloneDeep(pricingData.hostEarnings.matrixCoefficients);
|
|
15
|
+
const baseCoefficients = cloneDeep(newMatrix.plan36);
|
|
16
|
+
const plans = Object.keys(newMatrix);
|
|
17
|
+
for (const plan of plans) {
|
|
18
|
+
const mileagePackages = Object.keys(newMatrix[plan]);
|
|
19
|
+
for (const mileagePackage of mileagePackages) {
|
|
20
|
+
if (plan === 'plan1') {
|
|
21
|
+
if (tier === 'tierCustom') {
|
|
22
|
+
newMatrix[plan][mileagePackage] = 0;
|
|
23
|
+
continue;
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_iteratorError1 = err;
|
|
38
|
-
} finally{
|
|
39
|
-
try {
|
|
40
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
41
|
-
_iterator1.return();
|
|
42
|
-
}
|
|
43
|
-
} finally{
|
|
44
|
-
if (_didIteratorError1) {
|
|
45
|
-
throw _iteratorError1;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} catch (err) {
|
|
51
|
-
_didIteratorError = true;
|
|
52
|
-
_iteratorError = err;
|
|
53
|
-
} finally{
|
|
54
|
-
try {
|
|
55
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
56
|
-
_iterator.return();
|
|
57
|
-
}
|
|
58
|
-
} finally{
|
|
59
|
-
if (_didIteratorError) {
|
|
60
|
-
throw _iteratorError;
|
|
25
|
+
newMatrix[plan][mileagePackage] = Number(pricingData.hostEarnings.ultraTiers[tier]);
|
|
26
|
+
continue;
|
|
61
27
|
}
|
|
28
|
+
newMatrix[plan][mileagePackage] = round(baseline *
|
|
29
|
+
(flatPricing
|
|
30
|
+
? baseCoefficients[mileagePackage]
|
|
31
|
+
: newMatrix[plan][mileagePackage]));
|
|
62
32
|
}
|
|
63
33
|
}
|
|
64
34
|
return sortMatrix(newMatrix);
|
|
65
35
|
};
|
|
66
|
-
export
|
|
36
|
+
export const getHostExcessMileage = (pricingData, baseline) => {
|
|
67
37
|
return decimals(Math.max(Math.min(baseline * pricingData.hostEarnings.excessMileage.coefficient, pricingData.hostEarnings.excessMileage.upperBound), pricingData.hostEarnings.excessMileage.lowerBound));
|
|
68
38
|
};
|
|
69
|
-
export
|
|
39
|
+
export const getEmptyMatrix = () => {
|
|
70
40
|
return cloneDeep(EMPTY_MATRIX);
|
|
71
41
|
};
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
for(var _iterator1 = mileagePackages[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
83
|
-
var mileagePackage = _step1.value;
|
|
84
|
-
var _unorderedMatrix_plan;
|
|
85
|
-
if (!ordered[plan]) {
|
|
86
|
-
ordered[plan] = {};
|
|
87
|
-
}
|
|
88
|
-
ordered[plan][mileagePackage] = (_unorderedMatrix_plan = unorderedMatrix[plan]) === null || _unorderedMatrix_plan === void 0 ? void 0 : _unorderedMatrix_plan[mileagePackage];
|
|
89
|
-
}
|
|
90
|
-
} catch (err) {
|
|
91
|
-
_didIteratorError1 = true;
|
|
92
|
-
_iteratorError1 = err;
|
|
93
|
-
} finally{
|
|
94
|
-
try {
|
|
95
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
96
|
-
_iterator1.return();
|
|
97
|
-
}
|
|
98
|
-
} finally{
|
|
99
|
-
if (_didIteratorError1) {
|
|
100
|
-
throw _iteratorError1;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} catch (err) {
|
|
106
|
-
_didIteratorError = true;
|
|
107
|
-
_iteratorError = err;
|
|
108
|
-
} finally{
|
|
109
|
-
try {
|
|
110
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
111
|
-
_iterator.return();
|
|
112
|
-
}
|
|
113
|
-
} finally{
|
|
114
|
-
if (_didIteratorError) {
|
|
115
|
-
throw _iteratorError;
|
|
116
|
-
}
|
|
42
|
+
export const sortMatrix = (unorderedMatrix) => {
|
|
43
|
+
const ordered = {};
|
|
44
|
+
const plans = getVehicleDataVariant(PLANS, 'car');
|
|
45
|
+
const mileagePackages = getVehicleDataVariant(MILEAGE_PACKAGES, 'car');
|
|
46
|
+
for (const plan of plans) {
|
|
47
|
+
for (const mileagePackage of mileagePackages) {
|
|
48
|
+
if (!ordered[plan]) {
|
|
49
|
+
ordered[plan] = {};
|
|
50
|
+
}
|
|
51
|
+
ordered[plan][mileagePackage] = unorderedMatrix[plan]?.[mileagePackage];
|
|
117
52
|
}
|
|
118
53
|
}
|
|
119
54
|
return ordered;
|
|
120
55
|
};
|
|
121
|
-
|
|
56
|
+
const round = (number) => {
|
|
122
57
|
return Math.round(number * 100) / 100;
|
|
123
58
|
};
|
|
124
59
|
/**
|
|
@@ -131,145 +66,81 @@ var round = function(number) {
|
|
|
131
66
|
* @param customLitePicing
|
|
132
67
|
*
|
|
133
68
|
* @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
|
|
134
|
-
*/
|
|
69
|
+
*/
|
|
70
|
+
export const getFluxPiceMatrix = (pricingData, vehicleType, baseline, dealershipPriceMatrix, tier, flatPricing, customMileagePackage, customLitePicing) => {
|
|
135
71
|
// Let's not mutate percentages
|
|
136
|
-
|
|
137
|
-
|
|
72
|
+
const newMatrix = cloneDeep(pricingData.hostEarnings.matrixCoefficients);
|
|
73
|
+
const plans = Object.keys(newMatrix);
|
|
138
74
|
if (flatPricing) {
|
|
139
75
|
// if flat pricing, we order the plans by 36 months first, then the rest,
|
|
140
76
|
// that's because we perform the operations on the same matrix, so 36 is the base
|
|
141
77
|
// and should influence th rest of the plans
|
|
142
|
-
plans.sort(
|
|
78
|
+
plans.sort((a, _b) => {
|
|
143
79
|
if (a === 'plan36') {
|
|
144
80
|
return -1;
|
|
145
81
|
}
|
|
146
82
|
return 0;
|
|
147
83
|
});
|
|
148
84
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
mileagePackages.sort(function(a) {
|
|
158
|
-
if (a === 'lite') {
|
|
159
|
-
return -1;
|
|
160
|
-
}
|
|
161
|
-
return 0;
|
|
162
|
-
});
|
|
163
|
-
var baseMileagePackage = vehicleType === 'motorcycle' ? 'standard' : 'lite';
|
|
164
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
165
|
-
try {
|
|
166
|
-
for(var _iterator1 = mileagePackages[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
167
|
-
var mileagePackage = _step1.value;
|
|
168
|
-
var targetPlan = flatPricing ? 'plan36' : plan;
|
|
169
|
-
if (plan === 'plan1') {
|
|
170
|
-
if (tier === 'tierCustom') {
|
|
171
|
-
newMatrix[plan][mileagePackage] = 0;
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
newMatrix[plan][mileagePackage] = Number(pricingData.fluxPricing.ultraTiers[tier]);
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (mileagePackage === baseMileagePackage) {
|
|
178
|
-
var baseMileagePackagePrice = Math.max(baseline * pricingData.fluxPricing.matrixCoefficients[targetPlan], Number(dealershipPriceMatrix[targetPlan][baseMileagePackage]) + pricingData.fluxPricing.minFluxTake);
|
|
179
|
-
var custom = customLitePicing === null || customLitePicing === void 0 ? void 0 : customLitePicing[plan];
|
|
180
|
-
newMatrix[plan][baseMileagePackage] = decimals(typeof custom === 'undefined' ? baseMileagePackagePrice : custom);
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
var mileagePackageAdd = baseline * pricingData.fluxPricing.matrixCoefficients.add[mileagePackage];
|
|
184
|
-
var cutomMileagePackageAdd = customMileagePackage === null || customMileagePackage === void 0 ? void 0 : customMileagePackage[mileagePackage];
|
|
185
|
-
var basePlanMileagePackagePricing = newMatrix[targetPlan][baseMileagePackage];
|
|
186
|
-
newMatrix[plan][mileagePackage] = decimals(round(basePlanMileagePackagePricing + (cutomMileagePackageAdd || mileagePackageAdd)));
|
|
187
|
-
}
|
|
188
|
-
} catch (err) {
|
|
189
|
-
_didIteratorError1 = true;
|
|
190
|
-
_iteratorError1 = err;
|
|
191
|
-
} finally{
|
|
192
|
-
try {
|
|
193
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
194
|
-
_iterator1.return();
|
|
195
|
-
}
|
|
196
|
-
} finally{
|
|
197
|
-
if (_didIteratorError1) {
|
|
198
|
-
throw _iteratorError1;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
} catch (err) {
|
|
204
|
-
_didIteratorError = true;
|
|
205
|
-
_iteratorError = err;
|
|
206
|
-
} finally{
|
|
207
|
-
try {
|
|
208
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
209
|
-
_iterator.return();
|
|
210
|
-
}
|
|
211
|
-
} finally{
|
|
212
|
-
if (_didIteratorError) {
|
|
213
|
-
throw _iteratorError;
|
|
85
|
+
// This code is highly vulnerable to order. The order **MUST** be sorted,
|
|
86
|
+
// this is because it edits "lite" plan, then the other plans depend on the outcome of this one.
|
|
87
|
+
// TODO: Fix this code so that it sorts lite package first.
|
|
88
|
+
for (const plan of plans) {
|
|
89
|
+
const mileagePackages = Object.keys(newMatrix[plan]);
|
|
90
|
+
mileagePackages.sort((a) => {
|
|
91
|
+
if (a === 'lite') {
|
|
92
|
+
return -1;
|
|
214
93
|
}
|
|
94
|
+
return 0;
|
|
95
|
+
});
|
|
96
|
+
const baseMileagePackage = vehicleType === 'motorcycle' ? 'standard' : 'lite';
|
|
97
|
+
for (const mileagePackage of mileagePackages) {
|
|
98
|
+
const targetPlan = flatPricing ? 'plan36' : plan;
|
|
99
|
+
if (plan === 'plan1') {
|
|
100
|
+
if (tier === 'tierCustom') {
|
|
101
|
+
newMatrix[plan][mileagePackage] = 0;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
newMatrix[plan][mileagePackage] = Number(pricingData.fluxPricing.ultraTiers[tier]);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (mileagePackage === baseMileagePackage) {
|
|
108
|
+
const baseMileagePackagePrice = Math.max(baseline * pricingData.fluxPricing.matrixCoefficients[targetPlan], Number(dealershipPriceMatrix[targetPlan][baseMileagePackage]) +
|
|
109
|
+
pricingData.fluxPricing.minFluxTake);
|
|
110
|
+
const custom = customLitePicing?.[plan];
|
|
111
|
+
newMatrix[plan][baseMileagePackage] = decimals(typeof custom === 'undefined' ? baseMileagePackagePrice : custom);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const mileagePackageAdd = baseline *
|
|
115
|
+
pricingData.fluxPricing.matrixCoefficients.add[mileagePackage];
|
|
116
|
+
const cutomMileagePackageAdd = customMileagePackage?.[mileagePackage];
|
|
117
|
+
const basePlanMileagePackagePricing = newMatrix[targetPlan][baseMileagePackage];
|
|
118
|
+
newMatrix[plan][mileagePackage] = decimals(round(basePlanMileagePackagePricing +
|
|
119
|
+
(cutomMileagePackageAdd || mileagePackageAdd)));
|
|
215
120
|
}
|
|
216
121
|
}
|
|
217
122
|
return sortMatrix(newMatrix);
|
|
218
123
|
};
|
|
219
|
-
export
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
var toAdd = add[mileagePackage];
|
|
236
|
-
if (toAdd) {
|
|
237
|
-
var _newMatrix_plan;
|
|
238
|
-
newMatrix[plan][mileagePackage] = (((_newMatrix_plan = newMatrix[plan]) === null || _newMatrix_plan === void 0 ? void 0 : _newMatrix_plan[baseMileagePackage]) || 0) + toAdd;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
} catch (err) {
|
|
242
|
-
_didIteratorError1 = true;
|
|
243
|
-
_iteratorError1 = err;
|
|
244
|
-
} finally{
|
|
245
|
-
try {
|
|
246
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
247
|
-
_iterator1.return();
|
|
248
|
-
}
|
|
249
|
-
} finally{
|
|
250
|
-
if (_didIteratorError1) {
|
|
251
|
-
throw _iteratorError1;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
} catch (err) {
|
|
257
|
-
_didIteratorError = true;
|
|
258
|
-
_iteratorError = err;
|
|
259
|
-
} finally{
|
|
260
|
-
try {
|
|
261
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
262
|
-
_iterator.return();
|
|
263
|
-
}
|
|
264
|
-
} finally{
|
|
265
|
-
if (_didIteratorError) {
|
|
266
|
-
throw _iteratorError;
|
|
124
|
+
export const updateMatrixWithCustomPackages = (matrix, add) => {
|
|
125
|
+
const newMatrix = cloneDeep(matrix);
|
|
126
|
+
const plans = getVehicleDataVariant(PLANS, 'car');
|
|
127
|
+
const mileagePackages = getVehicleDataVariant(MILEAGE_PACKAGES, 'car');
|
|
128
|
+
const baseMileagePackage = mileagePackages[0];
|
|
129
|
+
for (const plan of plans) {
|
|
130
|
+
for (const mileagePackage of mileagePackages) {
|
|
131
|
+
if (mileagePackage === baseMileagePackage) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const toAdd = add[mileagePackage];
|
|
135
|
+
if (toAdd) {
|
|
136
|
+
newMatrix[plan][mileagePackage] =
|
|
137
|
+
(newMatrix[plan]?.[baseMileagePackage] || 0) + toAdd;
|
|
267
138
|
}
|
|
268
139
|
}
|
|
269
140
|
}
|
|
270
141
|
return newMatrix;
|
|
271
142
|
};
|
|
272
|
-
export
|
|
143
|
+
export const getFluxExcessMileage = (pricingData, baseline) => {
|
|
273
144
|
return decimals(Math.max(Math.min(baseline * pricingData.fluxPricing.matrixCoefficients.excessMileage, pricingData.fluxPricing.excessMileage.upperBound), pricingData.fluxPricing.excessMileage.lowerBound));
|
|
274
145
|
};
|
|
275
146
|
/**
|
|
@@ -278,50 +149,21 @@ export var getFluxExcessMileage = function(pricingData, baseline) {
|
|
|
278
149
|
* @param coefficient
|
|
279
150
|
*
|
|
280
151
|
* @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
|
|
281
|
-
*/
|
|
152
|
+
*/
|
|
153
|
+
export const getStartFeeMatrix = (pricingData, baseline, flatPricing) => {
|
|
282
154
|
// Let's not mutate percentages
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
for
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
for(var _iterator1 = mileagePackages[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
294
|
-
var mileagePackage = _step1.value;
|
|
295
|
-
newMatrix[plan][mileagePackage] = round(baseline * (flatPricing ? baseCoefficients[mileagePackage] : newMatrix[plan][mileagePackage]));
|
|
296
|
-
}
|
|
297
|
-
} catch (err) {
|
|
298
|
-
_didIteratorError1 = true;
|
|
299
|
-
_iteratorError1 = err;
|
|
300
|
-
} finally{
|
|
301
|
-
try {
|
|
302
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
303
|
-
_iterator1.return();
|
|
304
|
-
}
|
|
305
|
-
} finally{
|
|
306
|
-
if (_didIteratorError1) {
|
|
307
|
-
throw _iteratorError1;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
} catch (err) {
|
|
313
|
-
_didIteratorError = true;
|
|
314
|
-
_iteratorError = err;
|
|
315
|
-
} finally{
|
|
316
|
-
try {
|
|
317
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
318
|
-
_iterator.return();
|
|
319
|
-
}
|
|
320
|
-
} finally{
|
|
321
|
-
if (_didIteratorError) {
|
|
322
|
-
throw _iteratorError;
|
|
323
|
-
}
|
|
155
|
+
const newMatrix = cloneDeep(pricingData.startFee.matrixCoefficients);
|
|
156
|
+
const baseCoefficients = cloneDeep(newMatrix.plan36);
|
|
157
|
+
const plans = Object.keys(newMatrix);
|
|
158
|
+
for (const plan of plans) {
|
|
159
|
+
const mileagePackages = Object.keys(newMatrix[plan]);
|
|
160
|
+
for (const mileagePackage of mileagePackages) {
|
|
161
|
+
newMatrix[plan][mileagePackage] = round(baseline *
|
|
162
|
+
(flatPricing
|
|
163
|
+
? baseCoefficients[mileagePackage]
|
|
164
|
+
: newMatrix[plan][mileagePackage]));
|
|
324
165
|
}
|
|
325
166
|
}
|
|
326
167
|
return sortMatrix(newMatrix);
|
|
327
168
|
};
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/api-functions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./notion": {
|
|
@@ -73,20 +73,20 @@
|
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@casl/ability": "^6.7.3",
|
|
76
|
-
"@driveflux/auth": "2.0.
|
|
77
|
-
"@driveflux/billing": "7.0.0-feature-billing-v7.
|
|
78
|
-
"@driveflux/config": "2.0.
|
|
79
|
-
"@driveflux/coupon": "8.0.0-feature-billing-v7.
|
|
80
|
-
"@driveflux/db": "3.0.0-feature-billing-v7.
|
|
81
|
-
"@driveflux/email": "6.0.0-feature-billing-v7.
|
|
82
|
-
"@driveflux/email-templates": "0.0.2-feature-billing-v7.
|
|
83
|
-
"@driveflux/engine": "0.1.2-feature-billing-v7.
|
|
76
|
+
"@driveflux/auth": "2.0.6",
|
|
77
|
+
"@driveflux/billing": "7.0.0-feature-billing-v7.16",
|
|
78
|
+
"@driveflux/config": "2.0.3",
|
|
79
|
+
"@driveflux/coupon": "8.0.0-feature-billing-v7.11",
|
|
80
|
+
"@driveflux/db": "3.0.0-feature-billing-v7.30",
|
|
81
|
+
"@driveflux/email": "6.0.0-feature-billing-v7.11",
|
|
82
|
+
"@driveflux/email-templates": "0.0.2-feature-billing-v7.12",
|
|
83
|
+
"@driveflux/engine": "0.1.2-feature-billing-v7.31",
|
|
84
84
|
"@driveflux/fetch": "7.0.2",
|
|
85
85
|
"@driveflux/format-money": "6.0.2",
|
|
86
86
|
"@driveflux/problem": "5.0.2",
|
|
87
87
|
"@driveflux/reporter": "6.0.2",
|
|
88
88
|
"@driveflux/result": "5.0.2",
|
|
89
|
-
"@driveflux/scheduler": "7.0.0-feature-billing-v7.
|
|
89
|
+
"@driveflux/scheduler": "7.0.0-feature-billing-v7.11",
|
|
90
90
|
"@driveflux/singleton": "2.0.2",
|
|
91
91
|
"@driveflux/subscription": "8.0.0-feature-billing-v7.11",
|
|
92
92
|
"@driveflux/time": "5.0.2",
|