mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
fix(budget): a phone ticket split keeps the share of everyone a receipt line names (#1382)
On the phone, a ticket split where a receipt line named someone who was not ticked as a participant saved only the ticked people as members. Their share of the line was dropped, the member amounts no longer added up to total_price, and the settlement kept a difference nobody could clear. The desktop editor had been fixed for this in #1382. Cause: useExpenseForm only added the people named on ticket lines when the caller passed ticketShareMembers, and only the desktop CostsPanel did. The phone MCostSheet kept the old behaviour. Fix: the hook always sends everyone a ticket line names, and the ticketShareMembers option is gone, so both editors save the same members. Red test: src/components/Budget/useExpenseForm.test.ts FE-BUDGET-EXPFORM-021 failed on the unfixed code with "AssertionError: expected { name: 'Lunch', ... } to match object { ... }": member_ids was [1] and members held only user 1, without user 2's 6. Changed assertions: useExpenseForm.test.ts FE-BUDGET-EXPFORM-017 used to expect the phone run (ticketShareMembers false) to send members [{ user_id: 1, amount: 6 }] and member_ids [1]; that phone half is removed and the test now expects every editor to send members for users 1 and 2 with 6 each and member_ids [1, 2].
This commit is contained in:
@@ -38,7 +38,6 @@ let ticketItemSeq = 0;
|
||||
* through the trip store. Both surfaces lay it out their own way.
|
||||
*
|
||||
* Where the two save differently today, the surface says which way:
|
||||
* `ticketShareMembers` (desktop) also sends everyone a ticket line names (#1382);
|
||||
* `oneSaveAtATime` (phone) ignores a save while one is out; `keepSavingOnSuccess`
|
||||
* (phone) leaves the form busy after a save that went through, as the sheet closes.
|
||||
*/
|
||||
@@ -50,7 +49,6 @@ export function useExpenseForm({
|
||||
editing,
|
||||
prefill,
|
||||
onSaved,
|
||||
ticketShareMembers = false,
|
||||
oneSaveAtATime = false,
|
||||
keepSavingOnSuccess = false,
|
||||
}: {
|
||||
@@ -61,7 +59,6 @@ export function useExpenseForm({
|
||||
editing: BudgetItem | null;
|
||||
prefill?: ExpensePrefill;
|
||||
onSaved: () => void;
|
||||
ticketShareMembers?: boolean;
|
||||
oneSaveAtATime?: boolean;
|
||||
keepSavingOnSuccess?: boolean;
|
||||
}) {
|
||||
@@ -349,7 +346,7 @@ export function useExpenseForm({
|
||||
// only the ticked set would drop their share, leaving the member sum short of
|
||||
// total_price and handing the settlement a difference it can never clear (#1382).
|
||||
const memberIds =
|
||||
splitMode === 'ticket' && ticketShareMembers
|
||||
splitMode === 'ticket'
|
||||
? [...new Set([...participants, ...Object.keys(ticketInfo.shares).map(Number)])].sort((a, b) => a - b)
|
||||
: [...participants];
|
||||
const memberList = memberIds.map((id) => ({
|
||||
|
||||
Reference in New Issue
Block a user