Skip to content

Commit

Permalink
Merge pull request #53610 from Krishna2323/krishna2323/issue/53427
Browse files Browse the repository at this point in the history
fix: Distance - No error when editing the default rate to 4 decimal places and creating a same one.
  • Loading branch information
MariaHCD authored Dec 9, 2024
2 parents 034b2d9 + faae31d commit 147fe76
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libs/PolicyDistanceRatesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ function validateRateValue(
const errors: FormInputErrors<RateValueForm> = {};
const parsedRate = MoneyRequestUtils.replaceAllDigits(values.rate, toLocaleDigit);
const decimalSeparator = toLocaleDigit('.');
const ratesList = Object.values(customUnitRates).filter((rate) => currentRateValue !== rate.rate);
const ratesList = Object.values(customUnitRates)
.filter((rate) => currentRateValue !== rate.rate)
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.map((r) => ({...r, rate: parseFloat(Number(r.rate || 0).toFixed(10))}));
// The following logic replicates the backend's handling of rates:
// - Multiply the rate by 100 (CUSTOM_UNIT_RATE_BASE_OFFSET) to scale it, ensuring precision.
// - This ensures rates are converted as follows:
Expand Down

0 comments on commit 147fe76

Please sign in to comment.