Skip to content

Update Split table logic to update amounts/percentages to match the original transaction amount #70799

@garrettmknight

Description

@garrettmknight

Holding on #66064 to implement for both % and amounts.

In Classic, when a user splits an expense, we try to update the amounts for all splits to equal the amount of the original transaction automatically. We opted to go a simpler route with NewDot splits to start, avoiding any automatic updates, and punted adding this logic to a follow-up. This is that follow-up:

Problem: When users are editing the separate portions of a split they are typically trying to ensure all the portions add up to the original transaction amount.

Solution: Automatically change amounts and percentages when creating a split to add up to the original transaction amount to remove clicks/steps for the submitter. To do so, we'll implement our Classic logic:

Core logic:

  • Default/unmodified values adjust automatically: Any split that hasn't been manually edited (i.e., still at its default value) will auto-adjust evenly so that all splits add up to 100% (for percentages) or the total amount (for amounts).
  • Edited values are preserved: Once a user manually edits a percentage (or amount), that value is “locked in” and will never be auto-updated.
  • Editing an initial split will preserve all Split values: We've added the ability to edit existing splits in NewDot and the individaul splits of an expense may be on different reports and in different states. To avoid complexity, when a user edits an amount or percentage on an existing split, we treat all splits as manually edited and stop auto-adjusting them.

Behavior for Adding Splits

  • When a new split is added: Instead of defaulting to 0%, the system will redistribute all unedited splits automatically so they balance out to 100%.

Simple adding splits Example:

  1. Submitter taps More > Split on a $10 expense
  2. Two initial splits exist at 50/50 = $5/$5
  3. Submitter taps 'Add split'
  4. A third split is added and the amounts are updated to 33%/33%/34% = $3.33/$3.33/$3.34

Further editing example:

  1. Submitter taps More > Split on a $10 expense
  2. Two initial splits exist at 50/50 = $5/$5
  3. Submitter edits Split A to $3.
  4. Split B automatically updates to $7
  5. Submitter taps 'Add split'
  6. A third split is added. A remains $3, B updates to $3.50, the new split C is added as $3.50.

Error handling:

  • Users can still manually override and push totals over/under 100%.
  • In those cases, the same existing error message for invalid totals will be shown.

Metadata

Metadata

Labels

NewFeatureSomething to build that is a new item.ReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Status

CRITICAL

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions