import 'package:hesabix_ui/core/api_client.dart'; class ExpenseIncomeService { final ApiClient api; ExpenseIncomeService(this.api); Future> create({ required int businessId, required String documentType, // 'expense' | 'income' required DateTime documentDate, required int currencyId, String? description, List> itemLines = const [], List> counterpartyLines = const [], }) async { final body = { 'document_type': documentType, 'document_date': documentDate.toIso8601String(), 'currency_id': currencyId, if (description != null && description.isNotEmpty) 'description': description, 'item_lines': itemLines, 'counterparty_lines': counterpartyLines, }; final res = await api.post>( '/api/v1/businesses/$businessId/expense-income/create', data: body, ); return res.data ?? {}; } Future> list({ required int businessId, String? documentType, // 'expense' | 'income' DateTime? fromDate, DateTime? toDate, int skip = 0, int take = 20, String? search, String? sortBy, bool sortDesc = true, }) async { final body = { 'skip': skip, 'take': take, 'sort_desc': sortDesc, if (sortBy != null) 'sort_by': sortBy, if (search != null && search.isNotEmpty) 'search': search, if (documentType != null) 'document_type': documentType, if (fromDate != null) 'from_date': fromDate.toUtc().toIso8601String(), if (toDate != null) 'to_date': toDate.toUtc().toIso8601String(), }; final res = await api.post>( '/api/v1/businesses/$businessId/expense-income', data: body, ); return res.data ?? {}; } }