Files
finance-app/src/app/api/shared-transactions/route.ts
T
siddharthd b8cd1b0f89 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.
2026-05-11 19:15:41 +10:00

18 lines
922 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { getSharedTransactions } from "@/lib/queries";
import { getCurrentUser } from "@/lib/auth";
export async function GET(req: NextRequest) {
const user = await getCurrentUser(req);
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const tagParam = req.nextUrl.searchParams.get("tag_ids");
const rawIds = tagParam ? tagParam.split(",").filter(Boolean) : [];
const noTags = rawIds.includes("untagged");
const tagIds = rawIds.filter((id) => id !== "untagged").map(Number).filter((n) => !isNaN(n));
const participantParam = req.nextUrl.searchParams.get("participant_id");
const participantId = participantParam ? Number(participantParam) : undefined;
const transactions = await getSharedTransactions(user.id, tagIds.length ? tagIds : undefined, noTags, participantId);
return NextResponse.json(transactions);
}