Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Distance rates - Tax reclaimable can be equal Tax rates #54107

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions tests/unit/PolicyDistanceRatesUtilsTest.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
Loading