-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathDistanceRequestUtils.ts
More file actions
545 lines (493 loc) · 21.8 KB
/
Copy pathDistanceRequestUtils.ts
File metadata and controls
545 lines (493 loc) · 21.8 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {CurrencyListActionsContextType} from '@components/CurrencyListContextProvider';
import type {LocaleContextProps} from '@components/LocaleContextProvider';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {LastSelectedDistanceRates, OnyxInputOrEntry, Transaction} from '@src/types/onyx';
import type DefaultP2PMileageRate from '@src/types/onyx/DefaultP2PMileageRate';
import type {Unit} from '@src/types/onyx/Policy';
import type Policy from '@src/types/onyx/Policy';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import getStoredDefaultP2PMileageRate from './getStoredDefaultP2PMileageRate';
import {replaceAllDigits} from './MoneyRequestUtils';
import {getDistanceRateCustomUnit, getDistanceRateCustomUnitRate, getUnitRateValue} from './PolicyUtils';
import {getCurrency, getRateID, isCustomUnitRateIDForP2P, isExpenseUnreported} from './TransactionUtils';
type MileageRate = {
customUnitRateID?: string;
rate?: number;
currency?: string;
unit: Unit;
name?: string;
enabled?: boolean;
index?: number;
};
/** @private Only for getRate function */
let allPolicies: OnyxCollection<Policy>;
Onyx.connectWithoutView({
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
});
const METERS_TO_KM = 0.001; // 1 kilometer is 1000 meters
const METERS_TO_MILES = 0.000621371; // There are approximately 0.000621371 miles in a meter
const DEFAULT_P2P_RATE_CENTS_PER_MILE = 67;
function getMileageRates(policy: OnyxInputOrEntry<Policy>, includeDisabledRates = false, selectedRateID?: string): Record<string, MileageRate> {
const mileageRates: Record<string, MileageRate> = {};
if (!policy?.customUnits) {
return mileageRates;
}
const distanceUnit = getDistanceRateCustomUnit(policy);
if (!distanceUnit?.rates) {
return mileageRates;
}
for (const [rateID, rate] of Object.entries(distanceUnit.rates)) {
if (!includeDisabledRates && rate.enabled === false && (!selectedRateID || rateID !== selectedRateID)) {
continue;
}
if (!distanceUnit.attributes) {
continue;
}
mileageRates[rateID] = {
rate: rate.rate,
currency: rate.currency,
unit: distanceUnit.attributes.unit,
name: rate.name,
customUnitRateID: rate.customUnitRateID,
enabled: rate.enabled,
index: rate.index,
};
}
return mileageRates;
}
/**
* Retrieves the default mileage rate based on a given policy.
* Default rate is the first created rate when you create the policy.
* It's NOT always the rate whose name is "Default rate" because rate name is now changeable.
*
* @param policy - The policy from which to extract the default mileage rate.
*
* @returns An object containing the rate and unit for the default mileage or null if not found.
* @returns [rate] - The default rate for the mileage.
* @returns [currency] - The currency associated with the rate.
* @returns [unit] - The unit of measurement for the distance.
*/
function getDefaultMileageRate(policy: OnyxInputOrEntry<Policy>): MileageRate | undefined {
if (isEmptyObject(policy) || !policy?.customUnits) {
return undefined;
}
const distanceUnit = getDistanceRateCustomUnit(policy);
if (!distanceUnit?.rates || !distanceUnit.attributes) {
return;
}
const mileageRates = Object.values(getMileageRates(policy)).sort((a, b) => {
const aIndex = a.index ?? CONST.DEFAULT_NUMBER_ID;
const bIndex = b.index ?? CONST.DEFAULT_NUMBER_ID;
return aIndex - bIndex;
});
const distanceRate = mileageRates.at(0) ?? ({} as MileageRate);
return {
customUnitRateID: distanceRate.customUnitRateID,
rate: distanceRate.rate,
currency: distanceRate.currency,
unit: distanceUnit.attributes.unit,
name: distanceRate.name,
index: distanceRate.index,
};
}
/**
* Converts a given distance in meters to the specified unit (kilometers or miles).
*
* @param distanceInMeters - The distance in meters to be converted.
* @param unit - The desired unit of conversion, either 'km' for kilometers or 'mi' for miles.
*
* @returns The converted distance in the specified unit.
*/
function convertDistanceUnit(distanceInMeters: number, unit: Unit): number {
switch (unit) {
case CONST.CUSTOM_UNITS.DISTANCE_UNIT_KILOMETERS:
return distanceInMeters * METERS_TO_KM;
case CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES:
return distanceInMeters * METERS_TO_MILES;
default:
throw new Error('Unsupported unit. Supported units are "mi" or "km".');
}
}
/**
* @param distanceInMeters Distance traveled
* @param unit Unit that should be used to display the distance
* @returns The distance in requested units, rounded to 2 decimals
*/
function getRoundedDistanceInUnits(distanceInMeters: number, unit: Unit): string {
const convertedDistance = convertDistanceUnit(distanceInMeters, unit);
return convertedDistance.toFixed(CONST.DISTANCE_DECIMAL_PLACES);
}
/**
* @param unit Unit that should be used to display the distance
* @param rate Expensable amount allowed per unit
* @param currency The currency associated with the rate
* @param translate Translate function
* @param toLocaleDigit Function to convert to localized digit
* @param useShortFormUnit If true, the unit will be returned in short form (e.g., "mi", "km").
* @returns A string that displays the rate used for expense calculation
*/
function getFormattedRateValue(
unit: Unit | undefined,
rate: number | undefined,
currency: string | undefined,
translate: LocaleContextProps['translate'],
toLocaleDigit: LocaleContextProps['toLocaleDigit'],
getCurrencySymbol: CurrencyListActionsContextType['getCurrencySymbol'],
isOffline?: boolean,
useShortFormUnit?: boolean,
): string {
if (isOffline && !rate) {
return translate('iou.defaultRate');
}
if (!rate || !currency || !unit) {
return translate('iou.fieldPending');
}
const singularDistanceUnit = unit === CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES ? translate('common.mile') : translate('common.kilometer');
const formattedRate = getUnitRateValue(toLocaleDigit, {rate}, useShortFormUnit);
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const currencySymbol = getCurrencySymbol(currency) || `${currency} `;
return `${currencySymbol}${formattedRate} / ${useShortFormUnit ? unit : singularDistanceUnit}`;
}
/**
* Get the rate title to display on the expense page.
* If the rate is out of policy, displays "Rate out of policy".
* For workspace expenses, shows the rate name (e.g., "Default Rate") so that updating a rate's
* value on the workspace does not retroactively change the displayed rate on historical expenses.
* For P2P expenses (no rate name), shows the formatted rate value (e.g., "$0.67 / mi").
*/
function getRateForExpenseDisplay(
rateName: string | undefined,
isCustomUnitOutOfPolicy: boolean,
unit: Unit | undefined,
rate: number | undefined,
currency: string | undefined,
translate: LocaleContextProps['translate'],
toLocaleDigit: LocaleContextProps['toLocaleDigit'],
getCurrencySymbol: CurrencyListActionsContextType['getCurrencySymbol'],
isOffline?: boolean,
): string {
if (isCustomUnitOutOfPolicy) {
return translate('common.rateOutOfPolicy');
}
if (rateName) {
return rateName;
}
return getFormattedRateValue(unit, rate, currency, translate, toLocaleDigit, getCurrencySymbol, isOffline);
}
/**
* @param hasRoute Whether the route exists for the distance expense
* @param distanceInMeters Distance traveled
* @param unit Unit that should be used to display the distance
* @param rate Expensable amount allowed per unit
* @param translate Translate function
* @param useShortFormUnit If true, the unit will be returned in short form (e.g., "mi", "km").
* @returns A string that describes the distance traveled
*/
function getDistanceForDisplay(
hasRoute: boolean,
distanceInMeters: number,
unit: Unit | undefined,
rate: number | undefined,
translate: LocaleContextProps['translate'],
useShortFormUnit?: boolean,
isZeroDistanceAllowed?: boolean,
): string {
if (!hasRoute || !unit) {
return translate('iou.fieldPending');
}
if (!distanceInMeters && !isZeroDistanceAllowed) {
return '';
}
const distanceInUnits = getRoundedDistanceInUnits(distanceInMeters, unit);
if (useShortFormUnit) {
return `${distanceInUnits} ${unit}`;
}
const distanceUnit = unit === CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES ? translate('common.miles') : translate('common.kilometers');
const singularDistanceUnit = unit === CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES ? translate('common.mile') : translate('common.kilometer');
const unitString = distanceInUnits === '1' ? singularDistanceUnit : distanceUnit;
return `${distanceInUnits} ${unitString}`;
}
function getDistanceForDisplayLabel(distanceInMeters: number, unit: Unit): string {
const distanceInUnits = getRoundedDistanceInUnits(distanceInMeters, unit);
return `${distanceInUnits} ${unit}`;
}
/**
* @param hasRoute Whether the route exists for the distance expense
* @param distanceInMeters Distance traveled
* @param unit Unit that should be used to display the distance
* @param rate Expensable amount allowed per unit
* @param currency The currency associated with the rate
* @param translate Translate function
* @param toLocaleDigit Function to convert to localized digit
* @returns A string that describes the distance traveled and the rate used for expense calculation
*/
function getDistanceMerchant(
hasRoute: boolean,
distanceInMeters: number,
unit: Unit | undefined,
rate: number | undefined,
currency: string,
translate: LocaleContextProps['translate'],
toLocaleDigit: LocaleContextProps['toLocaleDigit'],
getCurrencySymbol: CurrencyListActionsContextType['getCurrencySymbol'],
isZeroDistanceAllowed?: boolean,
): string {
if (!hasRoute || !rate) {
return translate('iou.fieldPending');
}
if (!distanceInMeters && !isZeroDistanceAllowed) {
return '';
}
const distanceInUnits = getDistanceForDisplay(hasRoute, distanceInMeters, unit, rate, translate, true, isZeroDistanceAllowed);
const ratePerUnit = getFormattedRateValue(unit, rate, currency, translate, toLocaleDigit, getCurrencySymbol, undefined, true);
return `${distanceInUnits} ${CONST.DISTANCE_MERCHANT_SEPARATOR} ${ratePerUnit}`;
}
/**
* Retrieves the rate and unit for a P2P distance expense for a given currency.
*
* Let's ensure this logic is consistent with the logic in the backend (Auth), since we're using the same method to calculate the rate value in distance requests created via Concierge.
*
* @param currency
* @returns The rate and unit in MileageRate object.
*/
function getRateForP2P(currency: string, transaction: OnyxEntry<Transaction>): MileageRate {
const defaultRate = getStoredDefaultP2PMileageRate();
const p2pRate: DefaultP2PMileageRate = defaultRate ?? {rate: DEFAULT_P2P_RATE_CENTS_PER_MILE, unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES};
const rate = transaction && getCurrency(transaction) === currency ? (transaction.comment?.customUnit?.defaultP2PRate ?? p2pRate.rate) : p2pRate.rate;
// If a distance expense is being edited, the defaultP2PRate may not have been loaded yet, so use data from the existing transaction.
const fallbackUnit = transaction?.comment?.customUnit?.distanceUnit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES;
return {
rate,
unit: defaultRate ? p2pRate.unit : fallbackUnit,
currency: defaultRate ? currency : getCurrency(transaction),
};
}
/**
* Rounds a distance (already in the target unit) to 2 decimal places,
* multiplies by the rate, and rounds to the nearest integer (cents).
*/
function roundDistanceAmount(distanceInUnits: number, rate: number): number {
const roundedDistance = parseFloat(distanceInUnits.toFixed(2));
return Math.round(roundedDistance * rate);
}
/**
* Calculates the expense amount based on distance, unit, and rate.
*
* @param distance - The distance traveled in meters
* @param unit - The unit of measurement for the distance
* @param rate - Rate used for calculating the expense amount
* @returns The computed expense amount (rounded) in "cents".
*/
function getDistanceRequestAmount(distance: number, unit: Unit, rate: number): number {
return roundDistanceAmount(convertDistanceUnit(distance, unit), rate);
}
/**
* Converts the distance from kilometers or miles to meters.
*
* @param distance - The distance to be converted.
* @param unit - The unit of measurement for the distance.
* @returns The distance in meters.
*/
function convertToDistanceInMeters(distance: number, unit: Unit): number {
if (unit === CONST.CUSTOM_UNITS.DISTANCE_UNIT_KILOMETERS) {
return distance / METERS_TO_KM;
}
return distance / METERS_TO_MILES;
}
/**
* Returns custom unit rate ID for the distance transaction
*/
function getCustomUnitRateID({
reportID,
isPolicyExpenseChat,
policy,
isTrackDistanceExpense = false,
lastSelectedDistanceRates,
}: {
reportID: string | undefined;
isPolicyExpenseChat: boolean;
policy: OnyxEntry<Policy> | undefined;
lastSelectedDistanceRates?: OnyxEntry<LastSelectedDistanceRates>;
isTrackDistanceExpense?: boolean;
}): string {
let customUnitRateID: string = CONST.CUSTOM_UNITS.FAKE_P2P_ID;
if (!reportID) {
return customUnitRateID;
}
if (isEmptyObject(policy)) {
return customUnitRateID;
}
// For TrackDistanceExpense we will return the default or last selected rate of the policyForMovingExpenses.
if (isPolicyExpenseChat || isTrackDistanceExpense) {
const distanceUnit = Object.values(policy.customUnits ?? {}).find((unit) => unit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE);
const lastSelectedDistanceRateID = lastSelectedDistanceRates?.[policy.id];
const lastSelectedDistanceRate = lastSelectedDistanceRateID ? distanceUnit?.rates[lastSelectedDistanceRateID] : undefined;
if (lastSelectedDistanceRate?.enabled && lastSelectedDistanceRateID) {
customUnitRateID = lastSelectedDistanceRateID;
} else {
const defaultMileageRate = getDefaultMileageRate(policy);
if (!defaultMileageRate?.customUnitRateID) {
return customUnitRateID;
}
customUnitRateID = defaultMileageRate.customUnitRateID;
}
}
return customUnitRateID;
}
/**
* Get taxable amount from a specific distance rate, taking into consideration the tax claimable amount configured for the distance rate
*/
function getTaxableAmount(policy: OnyxEntry<Policy>, customUnitRateID: string, distance: number) {
const distanceUnit = getDistanceRateCustomUnit(policy);
const customUnitRate = getDistanceRateCustomUnitRate(policy, customUnitRateID);
if (!distanceUnit?.customUnitID || !customUnitRate) {
return 0;
}
const unit = distanceUnit?.attributes?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES;
const rate = customUnitRate?.rate ?? CONST.DEFAULT_NUMBER_ID;
const amount = getDistanceRequestAmount(distance, unit, rate);
const taxClaimablePercentage = customUnitRate.attributes?.taxClaimablePercentage ?? CONST.DEFAULT_NUMBER_ID;
return amount * taxClaimablePercentage;
}
function getDistanceUnit(transaction: OnyxEntry<Transaction>, mileageRate: OnyxEntry<MileageRate>): Unit {
return transaction?.comment?.customUnit?.distanceUnit ?? mileageRate?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES;
}
/** @private This is only for internal use for getRate function */
function getPersonalPolicy() {
return Object.values(allPolicies ?? {}).find((policy) => policy?.type === CONST.POLICY.TYPE.PERSONAL);
}
/**
* Get the selected rate for a transaction, from the policy or P2P default rate.
* Use the distanceUnit stored on the transaction by default to prevent policy changes modifying existing transactions. Otherwise, get the unit from the rate.
*
* Let's ensure this logic is consistent with the logic in the backend (Auth), since we're using the same method to calculate the rate value in distance requests created via Concierge.
*/
function getRate({
transaction,
policy,
policyDraft,
useTransactionDistanceUnit = true,
policyForMovingExpenses,
isFakeP2PRate,
isMovingTransactionFromTrackExpense,
personalPolicyOutputCurrency,
}: {
transaction: OnyxEntry<Transaction>;
policy: OnyxEntry<Policy>;
policyDraft?: OnyxEntry<Policy>;
policyForMovingExpenses?: OnyxEntry<Policy>;
useTransactionDistanceUnit?: boolean;
isFakeP2PRate?: boolean;
isMovingTransactionFromTrackExpense?: boolean;
personalPolicyOutputCurrency?: string;
}): MileageRate {
let mileageRates = getMileageRates(policy, true, transaction?.comment?.customUnit?.customUnitRateID);
if (isEmptyObject(mileageRates) && policyDraft) {
mileageRates = getMileageRates(policyDraft, true, transaction?.comment?.customUnit?.customUnitRateID);
}
const mileageRatesForMovingExpenses = getMileageRates(policyForMovingExpenses, true, transaction?.comment?.customUnit?.customUnitRateID);
const policyCurrency = policy?.outputCurrency ?? personalPolicyOutputCurrency ?? getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD;
const isUnreportedExpense = isExpenseUnreported(transaction);
const defaultMileageRate = getDefaultMileageRate(policy);
const customUnitRateID = getRateID(transaction);
const customMileageRate =
(customUnitRateID && (mileageRates?.[customUnitRateID] ?? mileageRatesForMovingExpenses?.[customUnitRateID])) ||
(isUnreportedExpense || isMovingTransactionFromTrackExpense ? undefined : defaultMileageRate);
const mileageRate = isCustomUnitRateIDForP2P(transaction) || isFakeP2PRate ? getRateForP2P(policyCurrency, transaction) : customMileageRate;
const unit = getDistanceUnit(useTransactionDistanceUnit ? transaction : undefined, mileageRate);
return {
...mileageRate,
unit,
currency: mileageRate?.currency ?? policyCurrency,
};
}
/**
* Get the updated distance unit from the selected rate instead of the distanceUnit stored on the transaction.
* Useful for updating the transaction distance unit when the distance or rate changes.
*
* For example, if an expense is '10 mi @ $1.00 / mi' and the rate is updated to '$1.00 / km',
* then the updated distance unit should be 'km' from the updated rate, not 'mi' from the currently stored transaction distance unit.
*/
function getUpdatedDistanceUnit({
transaction,
policy,
policyDraft,
personalPolicyOutputCurrency,
}: {
transaction: OnyxEntry<Transaction>;
policy: OnyxEntry<Policy>;
policyDraft?: OnyxEntry<Policy>;
personalPolicyOutputCurrency?: string;
}) {
return getRate({transaction, policy, policyDraft, useTransactionDistanceUnit: false, personalPolicyOutputCurrency}).unit;
}
/**
* Get the mileage rate by its ID in the form it's configured for the policy.
* If not found, return undefined.
*/
function getRateByCustomUnitRateID({customUnitRateID, policy}: {customUnitRateID: string; policy: OnyxEntry<Policy>}): MileageRate | undefined {
return getMileageRates(policy, true, customUnitRateID)[customUnitRateID];
}
/**
* Returns whether the calculated distance expense amount (distance * rate) is within the backend's safe limit.
* The backend WAF rejects amounts exceeding 12 digits (999,999,999,999 cents).
*
* @param distance - The distance in the unit specified (km or mi), NOT meters
* @param rate - The rate in cents per unit
* @returns true if the amount is within limits, false if it would exceed the backend limit
*/
function isDistanceAmountWithinLimit(distance: number, rate: number): boolean {
return Math.abs(roundDistanceAmount(distance, rate)) <= CONST.IOU.MAX_SAFE_AMOUNT;
}
/**
* Normalize odometer text by standardizing locale digits and stripping all
* non-numeric characters except the decimal point. fromLocaleDigit converts
* each locale character to its standard equivalent (e.g. German ',' → '.'
* for decimal, German '.' → ',' for group separator), so after conversion
* dots are always decimals and commas are always group separators.
* We then strip everything except digits and the standard decimal point.
*/
function normalizeOdometerText(text: string, fromLocaleDigit: (char: string) => string): string {
const standardized = replaceAllDigits(text, fromLocaleDigit);
const stripped = standardized.replaceAll(/[^0-9.]/g, '');
// Remove redundant leading zeroes (e.g. "007" → "7", "000" → "0") but
// keep a single zero before a decimal point (e.g. "0.5" stays "0.5").
return stripped.replace(/^0+(?=\d)/, '');
}
/**
* Prepare odometer input text for display by removing non-numeric characters
* (except the decimal point, comma, and space — which serve as group or
* decimal separators depending on locale) and stripping redundant leading zeroes.
*/
function prepareTextForDisplay(text: string): string {
return text.replaceAll(/[^0-9., ]/g, '').replace(/^0+(?=\d)/, '');
}
export default {
getDefaultMileageRate,
getDistanceMerchant,
getDistanceRequestAmount,
getFormattedRateValue,
getMileageRates,
getDistanceForDisplay,
getRoundedDistanceInUnits,
getRateForP2P,
getCustomUnitRateID,
convertToDistanceInMeters,
getTaxableAmount,
getDistanceUnit,
getUpdatedDistanceUnit,
getRate,
getRateByCustomUnitRateID,
getDistanceForDisplayLabel,
convertDistanceUnit,
getRateForExpenseDisplay,
isDistanceAmountWithinLimit,
normalizeOdometerText,
prepareTextForDisplay,
};
export type {MileageRate};