Skip to content

Split Amount Rounding Discrepancy Handler and Warning #500

Description

@Kingsman-99

Description

Converting floating-point percentage splits to integer stroops produces rounding errors where the sum of recipient amounts is one or two stroops less than the invoice total, causing contract rejections that confuse users. The frontend must detect and resolve these discrepancies before sending the transaction.

Technical Context

src/hooks/useSplitCalculator.ts adds a resolveRounding function that converts each percentage to stroops, sums them, and assigns any remainder stroops to the first recipient. src/components/invoice/SplitSummaryCard.tsx shows a soft warning when a rounding adjustment was applied, explaining how many stroops were redistributed. src/lib/stellar.ts validates the resolved amounts sum exactly to the invoice total in stroops before building the transaction.

Acceptance Criteria

  • The resolveRounding function always produces amounts that sum to the invoice total in stroops
  • A warning label appears when a rounding adjustment of one or more stroops is applied
  • The warning label explains which recipient received the adjustment and by how many stroops
  • The transaction is blocked from submission if the amounts do not sum correctly after resolution
  • Unit tests in src/__tests__/useSplitCalculator.test.ts cover the rounding logic for 3-, 7-, and 11-recipient splits
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions