From efbd5e8aa2d0a83ed13c0ff70ebcc28f8644c394 Mon Sep 17 00:00:00 2001 From: marcoitaloesp-ai Date: Tue, 16 Dec 2025 16:47:03 +0000 Subject: [PATCH] =?UTF-8?q?v1.43.11=20-=20Filtro=20de=20per=C3=ADodo=20per?= =?UTF-8?q?sonaliz=C3=A1vel=20em=20relat=C3=B3rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 26 ++++++++++++++++ VERSION | 2 +- frontend/src/i18n/locales/en.json | 2 ++ frontend/src/i18n/locales/es.json | 2 ++ frontend/src/i18n/locales/pt-BR.json | 2 ++ frontend/src/pages/Reports.jsx | 44 +++++++++++++++++++++++++--- 6 files changed, 73 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a4200..cfc6558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,32 @@ O formato segue [Keep a Changelog](https://keepachangelog.com/pt-BR/). Este projeto adota [Versionamento Semântico](https://semver.org/pt-BR/). +## [1.43.11] - 2025-12-16 + +### Added +- **Relatórios - Filtro de Período** + - Seletores de "Data Início" e "Data Fim" nos relatórios: + * Por Categoria + * Por Centro de Custo + * Maiores Gastos + - Período padrão: Início do ano (01/01/2025) até hoje (16/12/2025) + - Usuário pode alterar o período livremente + - Interface responsiva: campos lado a lado em desktop, empilhados em mobile + - Parâmetros `start_date` e `end_date` enviados à API + - Traduções: + * pt-BR: "Data Início", "Data Fim" + * en: "Start Date", "End Date" + * es: "Fecha Inicio", "Fecha Fin" + +### Changed +- **Frontend - Reports.jsx** + - Estados `startDate` e `endDate` adicionados + - useEffect atualizado com dependências `startDate` e `endDate` + - Parâmetros de data incluídos em: + * `reportService.getByCategory()` + * `reportService.getByCostCenter()` + * `reportService.getTopExpenses()` + ## [1.43.10] - 2025-12-16 ### Fixed diff --git a/VERSION b/VERSION index b073f13..340ce21 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.43.10 +1.43.11 diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 23554cb..0d57f42 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -1841,6 +1841,8 @@ "overdue": "Overdue", "savingsRate": "Savings Rate", "selectPeriod": "Select Period", + "startDate": "Start Date", + "endDate": "End Date", "subtitle": "Detailed analysis of your finances", "summary": "Summary", "thisMonth": "This Month", diff --git a/frontend/src/i18n/locales/es.json b/frontend/src/i18n/locales/es.json index 10b1a88..8f01a3c 100644 --- a/frontend/src/i18n/locales/es.json +++ b/frontend/src/i18n/locales/es.json @@ -1806,6 +1806,8 @@ "accounts": "Por Cuenta", "period": "Período", "selectPeriod": "Seleccionar período", + "startDate": "Fecha Inicio", + "endDate": "Fecha Fin", "thisMonth": "Este mes", "lastMonth": "Mes anterior", "last3Months": "Últimos 3 meses", diff --git a/frontend/src/i18n/locales/pt-BR.json b/frontend/src/i18n/locales/pt-BR.json index 3ec9ff6..566dfca 100644 --- a/frontend/src/i18n/locales/pt-BR.json +++ b/frontend/src/i18n/locales/pt-BR.json @@ -1847,6 +1847,8 @@ "overdue": "Vencidas", "savingsRate": "Taxa de Poupança", "selectPeriod": "Selecionar Período", + "startDate": "Data Início", + "endDate": "Data Fim", "subtitle": "Análise detalhada das suas finanças", "summary": "Resumo", "thisMonth": "Este Mês", diff --git a/frontend/src/pages/Reports.jsx b/frontend/src/pages/Reports.jsx index b52410d..b77df65 100644 --- a/frontend/src/pages/Reports.jsx +++ b/frontend/src/pages/Reports.jsx @@ -49,6 +49,10 @@ const Reports = () => { const [year, setYear] = useState(new Date().getFullYear()); const [months, setMonths] = useState(12); + // Date range filters (default: start of year to today) + const [startDate, setStartDate] = useState(new Date(new Date().getFullYear(), 0, 1).toISOString().split('T')[0]); + const [endDate, setEndDate] = useState(new Date().toISOString().split('T')[0]); + // Data states const [summary, setSummary] = useState(null); const [categoryData, setCategoryData] = useState(null); @@ -76,7 +80,7 @@ const Reports = () => { setSummary(summaryRes); break; case 'category': - const params = { type: 'debit' }; + const params = { type: 'debit', start_date: startDate, end_date: endDate }; if (selectedCategory) { params.parent_id = selectedCategory.category_id; } @@ -92,7 +96,7 @@ const Reports = () => { setDayOfWeekData(dowRes); break; case 'topExpenses': - const topRes = await reportService.getTopExpenses({ limit: 20 }); + const topRes = await reportService.getTopExpenses({ limit: 20, start_date: startDate, end_date: endDate }); setTopExpenses(topRes); break; case 'projection': @@ -104,7 +108,7 @@ const Reports = () => { setComparison(compRes); break; case 'costCenter': - const ccParams = {}; + const ccParams = { start_date: startDate, end_date: endDate }; if (selectedCostCenter) { ccParams.cost_center_id = selectedCostCenter.id ?? 0; } @@ -136,7 +140,7 @@ const Reports = () => { } finally { setLoading(false); } - }, [activeTab, year, months, selectedCategory, selectedCostCenter, selectedCostCenterCategory]); + }, [activeTab, year, months, selectedCategory, selectedCostCenter, selectedCostCenterCategory, startDate, endDate]); useEffect(() => { loadData(); @@ -2148,6 +2152,38 @@ const Reports = () => { {t('reports.subtitle')}

+ + {/* Date Range Filters */} + {(activeTab === 'category' || activeTab === 'costCenter' || activeTab === 'topExpenses') && ( +
+
+
+ + setStartDate(e.target.value)} + style={{ fontSize: isMobile ? '0.875rem' : '0.875rem' }} + /> +
+
+ + setEndDate(e.target.value)} + style={{ fontSize: isMobile ? '0.875rem' : '0.875rem' }} + /> +
+
+
+ )} {/* Tabs */}