import { apiRequest } from './api.js' function buildQuery(params = {}) { const search = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { if (typeof value === 'undefined' || value === null || value === '') return search.set(key, String(value)) }) const query = search.toString() return query ? `?${query}` : '' } export function fetchBudgetSummary(params = {}) { return apiRequest(`/budgets/summary${buildQuery(params)}`) } export function fetchBudgetAllocations(params = {}) { return apiRequest(`/budgets/allocations${buildQuery(params)}`) } export function createBudgetAllocation(payload = {}) { return apiRequest('/budgets/allocations', { method: 'POST', body: JSON.stringify(payload) }) } export function fetchBudgetTransactions(allocationId) { return apiRequest(`/budgets/allocations/${encodeURIComponent(String(allocationId || '').trim())}/transactions`) }