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
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.tsadds aresolveRoundingfunction that converts each percentage to stroops, sums them, and assigns any remainder stroops to the first recipient.src/components/invoice/SplitSummaryCard.tsxshows a soft warning when a rounding adjustment was applied, explaining how many stroops were redistributed.src/lib/stellar.tsvalidates the resolved amounts sum exactly to the invoice total in stroops before building the transaction.Acceptance Criteria
resolveRoundingfunction always produces amounts that sum to the invoice total in stroopssrc/__tests__/useSplitCalculator.test.tscover the rounding logic for 3-, 7-, and 11-recipient splits