From 58fda356c3a52840d5ecac657b1af4c1f2b8969f Mon Sep 17 00:00:00 2001 From: frakarr Date: Thu, 11 Dec 2025 21:16:58 +0100 Subject: [PATCH] Update mockDb.ts --- services/mockDb.ts | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/services/mockDb.ts b/services/mockDb.ts index 2cde5c1..92d2e25 100644 --- a/services/mockDb.ts +++ b/services/mockDb.ts @@ -2,7 +2,7 @@ import { Condo, Family, Payment, AppSettings, User, AuthResponse, Ticket, TicketComment, ExtraordinaryExpense, Notice, - AlertDefinition, NoticeRead + AlertDefinition, NoticeRead, CondoExpense } from '../types'; const API_URL = '/api'; @@ -390,5 +390,37 @@ export const CondoService = { deleteExpensePayment: async (paymentId: string): Promise => { return request(`/expenses/payments/${paymentId}`, { method: 'DELETE' }); + }, + + // --- CONDO EXPENSES (ORDINARY/SUPPLIERS) --- + getCondoExpenses: async (year?: number): Promise => { + const activeId = CondoService.getActiveCondoId(); + let url = `/condo-expenses?condoId=${activeId}`; + if (year) url += `&year=${year}`; + return request(url); + }, + + saveCondoExpense: async (expense: Partial): Promise => { + const activeId = CondoService.getActiveCondoId(); + const payload = { ...expense, condoId: activeId }; + if (expense.id) { + return request(`/condo-expenses/${expense.id}`, { + method: 'PUT', + body: JSON.stringify(payload) + }); + } else { + return request('/condo-expenses', { + method: 'POST', + body: JSON.stringify(payload) + }); + } + }, + + deleteCondoExpense: async (id: string): Promise => { + return request(`/condo-expenses/${id}`, { method: 'DELETE' }); + }, + + getCondoExpenseAttachment: async (expenseId: string, attId: string): Promise => { + return request(`/condo-expenses/${expenseId}/attachments/${attId}`); } };