bugfix: Fix share values being incorrectly divided by 100 in expense form#453
Merged
Petersmit27 merged 2 commits intospliit-app:mainfrom Nov 8, 2025
Merged
Conversation
Proposing fix to spliit-app#424 The issue is in the data flow between the form and the schema transform function: When editing existing expenses: Form loads shares by dividing database values by 100 (e.g., 200 / 100 = 2), but loads them as numbers When users change values: Input fields return strings via enforceCurrencyPattern Schema transform: Only multiplies by 100 for string values, not number values Result: Modified shares (strings) get multiplied by 100, unmodified shares (numbers) stay as-is Proposed fix: handle all shares consistently as strings throughout the form
Fix formatting.
9f4fee2 to
af95379
Compare
Collaborator
|
Thanks for the fix @yllar and @derekl-beep! I'm not really a fan of all the I'd love to have this restructured and have a test suite to make sure these things don't break in the future... |
This was referenced Nov 8, 2025
Contributor
Author
|
agree this should be a quick workaround for the current design. look forward to the restructuring 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR builds on #429 by adding type assertions to address TypeScript errors in the expense form. It potentially resolves issue #424.
Problem
When creating or editing expenses with split modes
BY_SHARES, orBY_PERCENTAGE, share values were sometimes incorrectly divided by 100 upon saving. For example:10.010.01→0.0001This bug occurred specifically when:
Root Cause
The issue was caused by inconsistent type handling in the form and schema transformation:
The schema transformation used a type-based check that only applied the
* 100multiplication to string values, assuming numbers were already in storage format. However, form initialization converted storage format (basis points) to display format (decimals) as numbers, which then bypassed the transformation on save.Solution
Ensure all share values in the form are consistently strings in display format:
This guarantees that all share values follow the same flow:
"1") → Schema transformation → Storage format number (e.g.,100)Changes
src/app/groups/[groupId]/expenses/expense-form.tsx(shares / 100).toString()(paidFor.shares / 100).toString()1to'1'in:Testing