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
+5 -2
View File
@@ -50,18 +50,20 @@ export async function POST(req: NextRequest) {
my_share_percent: override.my_share_percent,
},
});
await tx.transaction_overrides.deleteMany({ where: { transaction_id: manual_id } });
}
// Copy tags: manual → statement tx
// Move tags: manual → statement tx
const tags = await tx.transaction_tags.findMany({ where: { transaction_id: manual_id } });
if (tags.length) {
await tx.transaction_tags.createMany({
data: tags.map((t) => ({ transaction_id: statement_tx_id, tag_id: t.tag_id })),
skipDuplicates: true,
});
await tx.transaction_tags.deleteMany({ where: { transaction_id: manual_id } });
}
// Copy splits: manual → statement tx
// Move splits: manual → statement tx
const splits = await tx.transaction_splits.findMany({ where: { transaction_id: manual_id } });
if (splits.length) {
await tx.transaction_splits.createMany({
@@ -72,6 +74,7 @@ export async function POST(req: NextRequest) {
})),
skipDuplicates: true,
});
await tx.transaction_splits.deleteMany({ where: { transaction_id: manual_id } });
}
// Mark manual tx as reconciled (link to statement tx)