feat: ajouter les factures litiges et leurs commentaires (recette)
Some checks failed
Validation applicative / TypeScript, tests et build (push) Failing after 2m14s
Some checks failed
Validation applicative / TypeScript, tests et build (push) Failing after 2m14s
This commit is contained in:
@@ -296,6 +296,15 @@ export async function updateInvoice(id: number, data: Partial<Invoice>) {
|
||||
await db.update(invoices).set(data).where(eq(invoices.id, id));
|
||||
}
|
||||
|
||||
/** Les admins consultent tous les litiges ; les autres restent limités à leurs factures. */
|
||||
export async function getDisputedInvoices(userId?: number): Promise<Invoice[]> {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Database not available");
|
||||
return db.select().from(invoices)
|
||||
.where(userId === undefined ? eq(invoices.isDisputed, 1) : and(eq(invoices.isDisputed, 1), eq(invoices.userId, userId)))
|
||||
.orderBy(desc(invoices.updatedAt), desc(invoices.id));
|
||||
}
|
||||
|
||||
export async function deleteInvoice(id: number) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Database not available");
|
||||
|
||||
Reference in New Issue
Block a user