chore: commit previously untracked runtime files (splits, auth, participants, shared)

This commit is contained in:
2026-03-08 18:00:46 +11:00
parent 30a7857d13
commit 5dbeb0cb87
11 changed files with 450 additions and 0 deletions
@@ -0,0 +1,32 @@
import { NextRequest, NextResponse } from "next/server";
import { queryRaw } from "@/lib/db";
interface BalanceRow {
participant_id: number;
name: string;
total_owed: number;
transaction_count: number;
}
export async function GET(
_req: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
const rows = await queryRaw<BalanceRow>(
`SELECT ts.participant_id, p.name,
SUM(t.amount * ts.share_percent / 100)::numeric(12,2) as total_owed,
COUNT(*)::int as transaction_count
FROM transaction_splits ts
JOIN transactions t ON t.id = ts.transaction_id
JOIN participants p ON p.id = ts.participant_id
WHERE ts.participant_id = $1 AND ts.settled = false
GROUP BY ts.participant_id, p.name`,
[Number(id)]
);
return NextResponse.json(
rows[0] ?? { participant_id: Number(id), total_owed: 0, transaction_count: 0 }
);
}