Repository navigation
fix: reopen 2:3 share splits as 2:3, not 1:1.5 (port of upstream #774) - #35
Conversation
Port of oss-apps/split-pro#774, adapted to the cloud's pick order: a 2:3 share split reopened as 1:1.5, and 43% of 7.03 reopened as 42.96%. Smallest whole shares (up to 100) and whole, then tenth percentages are now tried first, and still only used when they give back exactly the stored cents.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Port of upstream oss-apps/split-pro#774 (fixes upstream #727), adapted to how this repo rebuilds split inputs.
Problem
splitpro.app already keeps the cents unchanged when an expense is reopened. But the split inputs it rebuilds can look different from what was entered:
Change (
src/store/addStore.ts,calculateSplitShareBasedOnAmount)Upstream added a separate bigint recovery module. Here I added new candidates to the existing
pickorder instead.pickstill uses a candidate only if it gives back exactly the stored cents, so it can't move money.Trade-off, the same one upstream makes: on small amounts, a decimal share input can reopen as whole shares that give the same cents. For example, 1 : 1.37 on 77.93 reopens as 27:37. On 779.30 it stays 1 : 1.37. Halves become equivalent whole numbers (1 : 1.5 → 2:3).
Testing
src/tests/splitRoundTrip.test.ts. It opens a stored expense throughgetEditFormStatethree times in a row and checks two things: the shown inputs (2:3, 4:6→2:3, refunds, 3 people, zero share, halves, 43/57, 25/50/25, 37.5/62.5, 33.33/33.33/33.34), and that the cents never change.pnpm test: 202 passed, 0 failed (42 DB integration tests skipped).npx tsc --noEmit -p .passes.pnpm lintreports nothing in the changed files.Summary by CodeRabbit
Bug Fixes
Tests