@driveflux/api-functions 0.0.2 → 0.0.3
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 +327 -73
- package/dist/auth/emails.js +210 -43
- package/dist/auth/formatter.js +11 -11
- package/dist/auth/otp.js +392 -122
- package/dist/auth/register.js +396 -100
- package/dist/auth/tokens.js +430 -115
- package/dist/auth/verifications.js +512 -154
- package/dist/constants.js +4 -5
- package/dist/mailjet/calls/manage-contacts-in-list.js +166 -22
- package/dist/mailjet/calls/manage-subscription-status.js +153 -13
- package/dist/mailjet/calls/request-service.js +183 -18
- package/dist/mailjet/refresh-email-preferences.js +225 -26
- package/dist/mailjet/set-contact.js +214 -23
- package/dist/mailjet/types.js +1 -2
- package/dist/mailjet/utils/convert-to-array.js +58 -9
- package/dist/mailjet/utils/extract-email-preferences.js +217 -41
- package/dist/mailjet/utils/lists.js +249 -30
- package/dist/mailjet/utils/update-email-references.js +208 -27
- package/dist/notion/client.js +197 -48
- package/dist/notion/helpful.js +170 -29
- package/dist/notion/schemas/block.js +43 -49
- package/dist/notion/schemas/common.js +14 -17
- package/dist/notion/schemas/database.js +159 -125
- package/dist/notion/schemas/emoji.js +2 -3
- package/dist/notion/schemas/file.js +10 -10
- package/dist/notion/schemas/kb.js +8 -9
- package/dist/notion/schemas/page.js +171 -126
- package/dist/notion/schemas/parent.js +8 -9
- package/dist/notion/schemas/user.js +20 -21
- package/dist/reservation/agree.js +158 -19
- package/dist/reservation/checks.js +178 -23
- package/dist/reservation/display-vehicle.js +514 -142
- package/dist/reservation/fetch-or-create.js +482 -197
- package/dist/reservation/invoice.js +501 -200
- package/dist/reservation/payer.js +177 -28
- package/dist/reservation/reserve.js +191 -31
- package/dist/reservation/types.js +1 -2
- package/dist/reservation/vehicle.js +186 -24
- package/dist/slack.js +273 -67
- package/dist/validation.js +92 -52
- package/dist/vehicle/vehicle-pricing/constants.js +36 -33
- package/dist/vehicle/vehicle-pricing/index.js +257 -99
- package/dist/vehicle/vehicle-pricing/types.js +1 -2
- package/package.json +1 -1
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var DEFAUALT_MILEAGE_MATRIX = {
|
|
2
|
+
lite: 0,
|
|
3
|
+
standard: 0,
|
|
4
|
+
plus: 0,
|
|
5
|
+
unlimited: 0
|
|
6
|
+
};
|
|
7
|
+
export var DEFAULT_MATRIX = {
|
|
3
8
|
plan1: DEFAUALT_MILEAGE_MATRIX,
|
|
4
9
|
plan12: DEFAUALT_MILEAGE_MATRIX,
|
|
5
10
|
plan24: DEFAUALT_MILEAGE_MATRIX,
|
|
6
11
|
plan36: DEFAUALT_MILEAGE_MATRIX,
|
|
7
12
|
plan60: DEFAUALT_MILEAGE_MATRIX,
|
|
8
|
-
planWeekly: DEFAUALT_MILEAGE_MATRIX
|
|
13
|
+
planWeekly: DEFAUALT_MILEAGE_MATRIX
|
|
9
14
|
};
|
|
10
|
-
export
|
|
11
|
-
|
|
15
|
+
export var FLUX_MIN_TAKE = 200;
|
|
16
|
+
var EMPTY_MILEAGE_PACKAGES = {
|
|
12
17
|
lite: 0,
|
|
13
18
|
standard: 0,
|
|
14
19
|
plus: 0,
|
|
15
|
-
unlimited: 0
|
|
20
|
+
unlimited: 0
|
|
16
21
|
};
|
|
17
|
-
export
|
|
22
|
+
export var EMPTY_FLUX_PRICING_MATRIX_CONTROLLER = {
|
|
18
23
|
plan60: 0,
|
|
19
24
|
plan36: 0,
|
|
20
25
|
plan24: 0,
|
|
@@ -22,17 +27,17 @@ export const EMPTY_FLUX_PRICING_MATRIX_CONTROLLER = {
|
|
|
22
27
|
plan1: 0,
|
|
23
28
|
planWeekly: 0,
|
|
24
29
|
add: EMPTY_MILEAGE_PACKAGES,
|
|
25
|
-
excessMileage: 0
|
|
30
|
+
excessMileage: 0
|
|
26
31
|
};
|
|
27
|
-
export
|
|
32
|
+
export var EMPTY_FLUX_START_FEE_MATRIX_CONTROLLER = {
|
|
28
33
|
plan60: EMPTY_MILEAGE_PACKAGES,
|
|
29
34
|
plan36: EMPTY_MILEAGE_PACKAGES,
|
|
30
35
|
plan24: EMPTY_MILEAGE_PACKAGES,
|
|
31
36
|
plan12: EMPTY_MILEAGE_PACKAGES,
|
|
32
37
|
plan1: EMPTY_MILEAGE_PACKAGES,
|
|
33
|
-
planWeekly: EMPTY_MILEAGE_PACKAGES
|
|
38
|
+
planWeekly: EMPTY_MILEAGE_PACKAGES
|
|
34
39
|
};
|
|
35
|
-
export
|
|
40
|
+
export var EMPTY_ULTRA_TIERS = {
|
|
36
41
|
tier1: 0,
|
|
37
42
|
tier2: 0,
|
|
38
43
|
tier3: 0,
|
|
@@ -47,60 +52,59 @@ export const EMPTY_ULTRA_TIERS = {
|
|
|
47
52
|
tier12: 0,
|
|
48
53
|
tier13: 0,
|
|
49
54
|
tier14: 0,
|
|
50
|
-
tier15: 0
|
|
55
|
+
tier15: 0
|
|
51
56
|
};
|
|
52
|
-
export
|
|
57
|
+
export var EMPTY_MATRIX = {
|
|
53
58
|
plan60: EMPTY_MILEAGE_PACKAGES,
|
|
54
59
|
plan36: EMPTY_MILEAGE_PACKAGES,
|
|
55
60
|
plan24: EMPTY_MILEAGE_PACKAGES,
|
|
56
61
|
plan12: EMPTY_MILEAGE_PACKAGES,
|
|
57
62
|
plan1: EMPTY_MILEAGE_PACKAGES,
|
|
58
|
-
planWeekly: EMPTY_MILEAGE_PACKAGES
|
|
63
|
+
planWeekly: EMPTY_MILEAGE_PACKAGES
|
|
59
64
|
};
|
|
60
65
|
/**
|
|
61
66
|
* Matrix representing the dealership's take in percentages
|
|
62
67
|
*
|
|
63
68
|
* @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
|
|
64
|
-
*/
|
|
65
|
-
export const HOST_MATRIX_COEFFICIENTS = {
|
|
69
|
+
*/ export var HOST_MATRIX_COEFFICIENTS = {
|
|
66
70
|
plan60: {
|
|
67
71
|
lite: 0.8,
|
|
68
72
|
standard: 0.9,
|
|
69
73
|
plus: 1,
|
|
70
|
-
unlimited: 1.25
|
|
74
|
+
unlimited: 1.25
|
|
71
75
|
},
|
|
72
76
|
plan36: {
|
|
73
77
|
lite: 1,
|
|
74
78
|
standard: 1.1,
|
|
75
79
|
plus: 1.2,
|
|
76
|
-
unlimited: 1.45
|
|
80
|
+
unlimited: 1.45
|
|
77
81
|
},
|
|
78
82
|
plan24: {
|
|
79
83
|
lite: 1.1,
|
|
80
84
|
standard: 1.2,
|
|
81
85
|
plus: 1.3,
|
|
82
|
-
unlimited: 1.55
|
|
86
|
+
unlimited: 1.55
|
|
83
87
|
},
|
|
84
88
|
plan12: {
|
|
85
89
|
lite: 1.2,
|
|
86
90
|
standard: 1.3,
|
|
87
91
|
plus: 1.4,
|
|
88
|
-
unlimited: 1.65
|
|
92
|
+
unlimited: 1.65
|
|
89
93
|
},
|
|
90
94
|
plan1: {
|
|
91
95
|
lite: 0,
|
|
92
96
|
standard: 0,
|
|
93
97
|
plus: 0,
|
|
94
|
-
unlimited: 0
|
|
98
|
+
unlimited: 0
|
|
95
99
|
},
|
|
96
100
|
planWeekly: {
|
|
97
101
|
lite: 0,
|
|
98
102
|
standard: 0,
|
|
99
103
|
plus: 0,
|
|
100
|
-
unlimited: 0
|
|
101
|
-
}
|
|
104
|
+
unlimited: 0
|
|
105
|
+
}
|
|
102
106
|
};
|
|
103
|
-
export
|
|
107
|
+
export var ULTRA_HOST_TIERS_PRICING = {
|
|
104
108
|
tier1: 800,
|
|
105
109
|
tier2: 1000,
|
|
106
110
|
tier3: 1100,
|
|
@@ -115,9 +119,9 @@ export const ULTRA_HOST_TIERS_PRICING = {
|
|
|
115
119
|
tier12: 8500,
|
|
116
120
|
tier13: 10500,
|
|
117
121
|
tier14: 12800,
|
|
118
|
-
tier15: 15000
|
|
122
|
+
tier15: 15000
|
|
119
123
|
};
|
|
120
|
-
export
|
|
124
|
+
export var ULTRA_FLUX_TIERS_PRICING = {
|
|
121
125
|
tier1: 999,
|
|
122
126
|
tier2: 1199,
|
|
123
127
|
tier3: 1399,
|
|
@@ -132,11 +136,10 @@ export const ULTRA_FLUX_TIERS_PRICING = {
|
|
|
132
136
|
tier12: 9999,
|
|
133
137
|
tier13: 12599,
|
|
134
138
|
tier14: 14999,
|
|
135
|
-
tier15: 17999
|
|
139
|
+
tier15: 17999
|
|
136
140
|
};
|
|
137
|
-
export
|
|
138
|
-
export
|
|
139
|
-
export
|
|
140
|
-
export
|
|
141
|
-
export
|
|
142
|
-
//# sourceMappingURL=constants.js.map
|
|
141
|
+
export var HOST_EXCESS_MILEAGE_COEFFICIENT = 0.00048;
|
|
142
|
+
export var MAX_HOST_EXCESS_MILEAGE = 4;
|
|
143
|
+
export var MIN_HOST_EXCESS_MILEAGE = 0.52;
|
|
144
|
+
export var MAX_FLUX_EXCESS_MILEAGE = 5;
|
|
145
|
+
export var MIN_FLUX_EXCESS_MILEAGE = 0.65;
|
|
@@ -5,55 +5,120 @@ 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
|
-
*/
|
|
9
|
-
export const getRecommendedMotorcycleDeposit = (baseline) => {
|
|
8
|
+
*/ export var getRecommendedMotorcycleDeposit = function(baseline) {
|
|
10
9
|
return Math.max(Math.min(baseline * 5, 1500), 1000);
|
|
11
10
|
};
|
|
12
|
-
export
|
|
11
|
+
export var getHostsMatrix = function(pricingData, baseline, tier, flatPricing) {
|
|
13
12
|
// Let's not mutate percentages
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
var newMatrix = cloneDeep(pricingData.hostEarnings.matrixCoefficients);
|
|
14
|
+
var baseCoefficients = cloneDeep(newMatrix.plan36);
|
|
15
|
+
var plans = Object.keys(newMatrix);
|
|
16
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
17
|
+
try {
|
|
18
|
+
for(var _iterator = plans[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
19
|
+
var plan = _step.value;
|
|
20
|
+
var mileagePackages = Object.keys(newMatrix[plan]);
|
|
21
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
22
|
+
try {
|
|
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]));
|
|
24
34
|
}
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_didIteratorError1 = true;
|
|
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;
|
|
27
61
|
}
|
|
28
|
-
newMatrix[plan][mileagePackage] = round(baseline *
|
|
29
|
-
(flatPricing
|
|
30
|
-
? baseCoefficients[mileagePackage]
|
|
31
|
-
: newMatrix[plan][mileagePackage]));
|
|
32
62
|
}
|
|
33
63
|
}
|
|
34
64
|
return sortMatrix(newMatrix);
|
|
35
65
|
};
|
|
36
|
-
export
|
|
66
|
+
export var getHostExcessMileage = function(pricingData, baseline) {
|
|
37
67
|
return decimals(Math.max(Math.min(baseline * pricingData.hostEarnings.excessMileage.coefficient, pricingData.hostEarnings.excessMileage.upperBound), pricingData.hostEarnings.excessMileage.lowerBound));
|
|
38
68
|
};
|
|
39
|
-
export
|
|
69
|
+
export var getEmptyMatrix = function() {
|
|
40
70
|
return cloneDeep(EMPTY_MATRIX);
|
|
41
71
|
};
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
export var sortMatrix = function(unorderedMatrix) {
|
|
73
|
+
var ordered = {};
|
|
74
|
+
var plans = getVehicleDataVariant(PLANS, 'car');
|
|
75
|
+
var mileagePackages = getVehicleDataVariant(MILEAGE_PACKAGES, 'car');
|
|
76
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
77
|
+
try {
|
|
78
|
+
for(var _iterator = plans[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
79
|
+
var plan = _step.value;
|
|
80
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
81
|
+
try {
|
|
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
|
+
}
|
|
52
117
|
}
|
|
53
118
|
}
|
|
54
119
|
return ordered;
|
|
55
120
|
};
|
|
56
|
-
|
|
121
|
+
var round = function(number) {
|
|
57
122
|
return Math.round(number * 100) / 100;
|
|
58
123
|
};
|
|
59
124
|
/**
|
|
@@ -66,81 +131,145 @@ const round = (number) => {
|
|
|
66
131
|
* @param customLitePicing
|
|
67
132
|
*
|
|
68
133
|
* @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
|
|
69
|
-
*/
|
|
70
|
-
export const getFluxPiceMatrix = (pricingData, vehicleType, baseline, dealershipPriceMatrix, tier, flatPricing, customMileagePackage, customLitePicing) => {
|
|
134
|
+
*/ export var getFluxPiceMatrix = function(pricingData, vehicleType, baseline, dealershipPriceMatrix, tier, flatPricing, customMileagePackage, customLitePicing) {
|
|
71
135
|
// Let's not mutate percentages
|
|
72
|
-
|
|
73
|
-
|
|
136
|
+
var newMatrix = cloneDeep(pricingData.hostEarnings.matrixCoefficients);
|
|
137
|
+
var plans = Object.keys(newMatrix);
|
|
74
138
|
if (flatPricing) {
|
|
75
139
|
// if flat pricing, we order the plans by 36 months first, then the rest,
|
|
76
140
|
// that's because we perform the operations on the same matrix, so 36 is the base
|
|
77
141
|
// and should influence th rest of the plans
|
|
78
|
-
plans.sort((a, _b)
|
|
142
|
+
plans.sort(function(a, _b) {
|
|
79
143
|
if (a === 'plan36') {
|
|
80
144
|
return -1;
|
|
81
145
|
}
|
|
82
146
|
return 0;
|
|
83
147
|
});
|
|
84
148
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
149
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
150
|
+
try {
|
|
151
|
+
// This code is highly vulnerable to order. The order **MUST** be sorted,
|
|
152
|
+
// this is because it edits "lite" plan, then the other plans depend on the outcome of this one.
|
|
153
|
+
// TODO: Fix this code so that it sorts lite package first.
|
|
154
|
+
for(var _iterator = plans[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
155
|
+
var plan = _step.value;
|
|
156
|
+
var mileagePackages = Object.keys(newMatrix[plan]);
|
|
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
|
+
}
|
|
103
200
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
newMatrix[plan][mileagePackage] = decimals(round(basePlanMileagePackagePricing +
|
|
119
|
-
(cutomMileagePackageAdd || mileagePackageAdd)));
|
|
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;
|
|
214
|
+
}
|
|
120
215
|
}
|
|
121
216
|
}
|
|
122
217
|
return sortMatrix(newMatrix);
|
|
123
218
|
};
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(
|
|
219
|
+
export var updateMatrixWithCustomPackages = function(matrix, add) {
|
|
220
|
+
var newMatrix = cloneDeep(matrix);
|
|
221
|
+
var plans = getVehicleDataVariant(PLANS, 'car');
|
|
222
|
+
var mileagePackages = getVehicleDataVariant(MILEAGE_PACKAGES, 'car');
|
|
223
|
+
var baseMileagePackage = mileagePackages[0];
|
|
224
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
225
|
+
try {
|
|
226
|
+
for(var _iterator = plans[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
227
|
+
var plan = _step.value;
|
|
228
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
229
|
+
try {
|
|
230
|
+
for(var _iterator1 = mileagePackages[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
231
|
+
var mileagePackage = _step1.value;
|
|
232
|
+
if (mileagePackage === baseMileagePackage) {
|
|
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;
|
|
138
267
|
}
|
|
139
268
|
}
|
|
140
269
|
}
|
|
141
270
|
return newMatrix;
|
|
142
271
|
};
|
|
143
|
-
export
|
|
272
|
+
export var getFluxExcessMileage = function(pricingData, baseline) {
|
|
144
273
|
return decimals(Math.max(Math.min(baseline * pricingData.fluxPricing.matrixCoefficients.excessMileage, pricingData.fluxPricing.excessMileage.upperBound), pricingData.fluxPricing.excessMileage.lowerBound));
|
|
145
274
|
};
|
|
146
275
|
/**
|
|
@@ -149,21 +278,50 @@ export const getFluxExcessMileage = (pricingData, baseline) => {
|
|
|
149
278
|
* @param coefficient
|
|
150
279
|
*
|
|
151
280
|
* @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
|
|
152
|
-
*/
|
|
153
|
-
export const getStartFeeMatrix = (pricingData, baseline, flatPricing) => {
|
|
281
|
+
*/ export var getStartFeeMatrix = function(pricingData, baseline, flatPricing) {
|
|
154
282
|
// Let's not mutate percentages
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
for (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
283
|
+
var newMatrix = cloneDeep(pricingData.startFee.matrixCoefficients);
|
|
284
|
+
var baseCoefficients = cloneDeep(newMatrix.plan36);
|
|
285
|
+
var plans = Object.keys(newMatrix);
|
|
286
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
287
|
+
try {
|
|
288
|
+
for(var _iterator = plans[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
289
|
+
var plan = _step.value;
|
|
290
|
+
var mileagePackages = Object.keys(newMatrix[plan]);
|
|
291
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
292
|
+
try {
|
|
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
|
+
}
|
|
165
324
|
}
|
|
166
325
|
}
|
|
167
326
|
return sortMatrix(newMatrix);
|
|
168
327
|
};
|
|
169
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export { };
|