Skip to content

feat(messenger): group requests take a total split between people - #1917

Merged
bmc08gt merged 4 commits into
code/cashfrom
feat/group-requests-total-amount
Oct 30, 2026
Merged

bmc08gt merged 4 commits into
code/cashfrom
feat/group-requests-total-amount

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Group payment requests now take the total the creator wants back, not an amount per person. The app splits that total between everyone checked, per the "Splitting the total" section of the spec in code-payments/flipcash-client-orchestrator#85.

Splitting

splitTotal in NewRequestDraft.kt works in the currency's smallest unit. With a total of T units and N shares, each share gets floor(T / N). The T mod N units left over go one each to the first non-creator shares in roster order. The creator's share takes a unit only once every other share has one, since that share is marked paid at creation. Shares always sum to T. When T < N there's no valid split, so canSend is false and Request stays disabled.

$100 between the creator and two others comes out as $33.33 (creator), $33.34, $33.33.

NewSplitRequest.shares is now a list of NewShare(userId, amount), and asGroupChatPaymentRequest sets each share's native_amount from its own amount. The single perPerson field is gone.

Copy

  • Amount entry: "Amount Per Person" becomes "Total Amount".
  • Summary: the label under the amount reads "Total" instead of "per person".
  • The member picker is titled "Split Between" in the request flow. GroupSelectPeopleContent takes a title, and group send keeps the "Select People" default.
  • The button reads "Request <share> Each" and updates as the selection changes. When the total splits evenly, <share> is the exact share. When it doesn't, <share> is the smaller share with "~" in front, since some shares are a cent more: $100 between three reads "Request ~$33.33 Each", and $100.02 between three reads "Request $33.34 Each". This replaces the action_requestFromPeople plural.

Analytics

"Payment Request: Created" now reports the total as its amount, not the largest share, so $100 split three ways reports $100. iOS already sends the total (Analytics.paymentRequestCreated(payerCount:amount:error:) in PaymentRequestCreateViewModel.swift). The event's description in events.toml and EVENTS.md says the amount is the request's total, split between everyone in it, the creator included when they are.

Tests

NewRequestDraftTest covers spec cases 14, 15 and 49–53: the even splits, the remainder skipping the creator, a deselected creator, and a total too small to split. RequestCopyTest checks the button for cases 49 and 53, with and without "~". RequestMoneyAnalyticsTest checks that a $5 request between the creator and two others reports $5.

The amount entry now asks for the total, titled Total Amount, and the
summary labels it total. Select People reads Split Between in the
request flow; group send keeps its title.

The total is split in the currency's smallest unit: each share gets
floor(T/N) and the T mod N leftover units go one each to the first
non-creator shares in roster order, so the shares sum to T. Request is
disabled when T < N. Each share's native_amount now comes from that
split, and the button reads "Request <largest share> Each".
@bmc08gt bmc08gt self-assigned this Oct 30, 2026
@github-actions github-actions Bot added area: network gRPC, connectivity, API, exchange rates type: feature New functionality labels Oct 30, 2026
When the total does not divide evenly, the summary button shows the
smaller share with a tilde: $100 split three ways reads
"Request ~$33.33 Each" instead of "Request $33.34 Each". An even split
keeps the exact share. The label under the amount reads "Total".
Created's amount was the largest share. It is now the total the creator
typed, which is what iOS sends (Analytics.paymentRequestCreated in
PaymentRequestCreateViewModel.swift). The catalogue description and
EVENTS.md say so.
@bmc08gt
bmc08gt merged commit 92091f1 into code/cash Oct 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: network gRPC, connectivity, API, exchange rates type: feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant