diff --git a/src/libs/PolicyDistanceRatesUtils.ts b/src/libs/PolicyDistanceRatesUtils.ts index 64f430ddbc42..6e180e4ecaf8 100644 --- a/src/libs/PolicyDistanceRatesUtils.ts +++ b/src/libs/PolicyDistanceRatesUtils.ts @@ -50,7 +50,7 @@ function validateRateValue( function validateTaxClaimableValue(values: FormOnyxValues, rate: Rate | undefined): FormInputErrors { const errors: FormInputErrors = {}; - if (rate?.rate && Number(values.taxClaimableValue) > rate.rate / 100) { + if (rate?.rate && Number(values.taxClaimableValue) >= rate.rate / 100) { errors.taxClaimableValue = Localize.translateLocal('workspace.taxes.error.updateTaxClaimableFailureMessage'); } return errors; diff --git a/tests/unit/PolicyDistanceRatesUtilsTest.ts b/tests/unit/PolicyDistanceRatesUtilsTest.ts new file mode 100644 index 000000000000..5a72d5336cd0 --- /dev/null +++ b/tests/unit/PolicyDistanceRatesUtilsTest.ts @@ -0,0 +1,13 @@ +import {validateTaxClaimableValue} from '@libs/PolicyDistanceRatesUtils'; + +describe('PolicyDistanceRatesUtils', () => { + describe('validateTaxClaimableValue', () => { + it('should return an error when taxClaimableValue is equal to tax rate', () => { + // Given a tax claimable value inserted for a distance rate + // When the taxClaimableValue is equal to the tax rate + const validate = validateTaxClaimableValue({taxClaimableValue: '0.67'}, {rate: 67, customUnitRateID: ''}); + // Then validateTaxClaimableValue will return an error. + expect(validate.taxClaimableValue).toBeDefined(); + }); + }); +});