negative currency bug fixed #178
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Refactor TransactionModal component for improved readability and functionality. Added validation for cost input and adjusted form handling for better user experience.also fix negative currency issue
Description
This PR refactors the TransactionModal component to enhance readability, maintainability, and user experience.
It also adds validation logic to prevent users from entering negative or invalid values in the amount (cost) field.
Additionally, the form handling flow has been simplified to improve clarity and usability.
Key updates include:
Added validation to block negative or zero values for cost.
Improved input handling and error feedback for smoother UX.
Refactored code into smaller logical sections for better readability.
Adjusted default form data initialization and view switching.
Fixed issue where negative amounts appeared in transaction history.
Related Issue
This PR addresses a reported bug where negative transaction amounts were accepted and displayed.
Motivation and Context
Previously, users were able to input negative values for transaction amounts, which caused inaccurate balance calculations and incorrect transaction records.
This fix ensures that:
Expense and income inputs remain positive.
The form provides clear feedback when invalid input is detected.
The overall user experience and data consistency are improved.
Types of Changes
How Has This Been Tested?
Manually tested form submissions for both expense and income transactions.
Attempted to enter negative and non-numeric values — validation prevented submission as expected.
Verified transactions are recorded correctly in both add and edit modes.
Checked modal switching between expense/income modes for data consistency.
Confirmed UI displays correct error messages and handles valid inputs smoothly.
Environment:
OS: Windows 11
Browser: Chrome (latest)
Framework: React 18
Backend: Flask API (via Docker)
Checklist