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: Web - No Error Generated When Adding a Track Distance Rate of 0.00 #26745

Merged
merged 2 commits into from
Sep 11, 2023
Merged
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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ export default {
fastReimbursementsVBACopy: "You're all set to reimburse receipts from your bank account!",
updateCustomUnitError: "Your changes couldn't be saved. The workspace was modified while you were offline, please try again.",
invalidRateError: 'Please enter a valid rate',
lowRateError: 'Rate must be greater than 0',
},
bills: {
manageYourBills: 'Manage your bills',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ export default {
fastReimbursementsVBACopy: '¡Todo listo para reembolsar recibos desde tu cuenta bancaria!',
updateCustomUnitError: 'Los cambios no han podido ser guardados. El espacio de trabajo ha sido modificado mientras estabas desconectado. Por favor, inténtalo de nuevo.',
invalidRateError: 'Por favor, introduce una tarifa válida',
lowRateError: 'La tarifa debe ser mayor que 0',
},
bills: {
manageYourBills: 'Gestiona tus facturas',
Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class WorkspaceRateAndUnitPage extends React.Component {
validate(values) {
const errors = {};
const decimalSeparator = this.props.toLocaleDigit('.');
const rateValueRegex = RegExp(String.raw`^\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
const rateValueRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
if (!rateValueRegex.test(values.rate) || values.rate === '') {
errors.rate = 'workspace.reimburse.invalidRateError';
} else if (parseFloat(values.rate) <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this caused #27595. We should have accounted for a , separator as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, unfortunately. Thanks for pointing this out.

errors.rate = 'workspace.reimburse.lowRateError';
}
return errors;
}
Expand Down
Loading