This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { query } from "./_generated/server"; | |
| import { v } from "convex/values"; | |
| // Упрощённый баланс: считаем, сколько заплатил ты и сколько заплатили не ты. | |
| // Net = youPaid - othersPaid. You are owed = max(Net, 0), You owe = max(-Net, 0). | |
| export const balances = query({ | |
| args: { me: v.string() }, // Clerk user.id | |
| handler: async ({ db }, { me }) => { | |
| const all = await db.query("expenses").collect(); | |
| let youPaid = 0, othersPaid = 0; |