fix(reconcile): prevent split/tag double-counting on reconciled transactions

Move splits, tags and overrides from manual to statement side on reconcile
(delete from manual after copying) instead of just copying. Add read-time
filter to exclude reconciled manual transactions from balance and shared
transaction queries. Also adds participant filter to shared expenses page.
This commit is contained in:
2026-05-11 19:15:41 +10:00
parent ce67e38d77
commit b8cd1b0f89
5 changed files with 41 additions and 10 deletions
+15 -2
View File
@@ -4,6 +4,7 @@ import { useState, useRef, useEffect } from "react";
import {
useSharedTransactions,
useParticipantBalances,
useParticipants,
useCreateParticipant,
useRecordPayment,
usePaymentHistory,
@@ -274,10 +275,12 @@ type SortCol = "transaction_date" | "created_at" | "amount";
export default function SharedPage() {
const [tagIds, setTagIds] = useState<string[]>([]);
const [participantId, setParticipantId] = useState<number | undefined>(undefined);
const [sortCol, setSortCol] = useState<SortCol>("transaction_date");
const [sortDir, setSortDir] = useState<"asc" | "desc">("desc");
const realTagIds = tagIds.filter((id) => id !== "untagged");
const { data: rawTransactions = [], isLoading: txLoading } = useSharedTransactions(tagIds);
const { data: participants = [] } = useParticipants();
const { data: rawTransactions = [], isLoading: txLoading } = useSharedTransactions(tagIds, participantId);
const transactions = [...rawTransactions].sort((a, b) => {
const av = sortCol === "amount" ? Number(a.amount) : new Date(a[sortCol]).getTime();
@@ -305,7 +308,17 @@ export default function SharedPage() {
<div className="space-y-6">
<div className="flex items-center justify-between gap-3">
<h2 className="text-xl font-semibold">Shared Expenses</h2>
<div className="flex items-center gap-2 ml-auto">
<div className="flex items-center gap-2 ml-auto flex-wrap">
<select
value={participantId ?? ""}
onChange={(e) => setParticipantId(e.target.value ? Number(e.target.value) : undefined)}
className={`border rounded px-3 py-1.5 text-sm bg-zinc-900 ${participantId ? "border-indigo-500 text-white" : "border-zinc-700 text-zinc-400"}`}
>
<option value="">All People</option>
{participants.map((p: { id: number; name: string }) => (
<option key={p.id} value={p.id}>{p.name}</option>
))}
</select>
<TagFilter value={tagIds} onChange={setTagIds} />
{!addingParticipant && (
<button onClick={() => setAddingParticipant(true)}