Skip to content

Commit

Permalink
Merge pull request Expensify#54107 from FitseTLT/fix-allowing=tax-rec…
Browse files Browse the repository at this point in the history
…laimable-equal-to-tax-rates
  • Loading branch information
dangrous authored Jan 7, 2025
2 parents cd43345 + 7d8a5e9 commit 89a18c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/PolicyDistanceRatesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function validateRateValue(
function validateTaxClaimableValue(values: FormOnyxValues<TaxReclaimableForm>, rate: Rate | undefined): FormInputErrors<TaxReclaimableForm> {
const errors: FormInputErrors<TaxReclaimableForm> = {};

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;
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/PolicyDistanceRatesUtilsTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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();

// When the taxClaimableValue is greater than the tax rate
const validate2 = validateTaxClaimableValue({taxClaimableValue: '0.69'}, {rate: 67, customUnitRateID: ''});
// Then validateTaxClaimableValue will return an error.
expect(validate2.taxClaimableValue).toBeDefined();

// When the taxClaimableValue is less than the tax rate
const validate3 = validateTaxClaimableValue({taxClaimableValue: '0.65'}, {rate: 67, customUnitRateID: ''});
// Then validateTaxClaimableValue will not return an error.
expect(validate3.taxClaimableValue).toBeUndefined();
});
});
});

0 comments on commit 89a18c6

Please sign in to comment.