From e92cc8cf1fb2b48918f09ccfa6f43f0b4ee4be18 Mon Sep 17 00:00:00 2001 From: marcoitaloesp-ai Date: Tue, 16 Dec 2025 18:15:11 +0000 Subject: [PATCH] =?UTF-8?q?v1.43.19=20-=20Revis=C3=A3o=20completa=20do=20m?= =?UTF-8?q?odal=20de=20editar=20template=20recorrente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 14 + VERSION | 2 +- frontend/src/pages/RecurringTransactions.jsx | 297 ++++++++++++++++--- 3 files changed, 270 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 543aadd..e29afe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ O formato segue [Keep a Changelog](https://keepachangelog.com/pt-BR/). Este projeto adota [Versionamento Semântico](https://semver.org/pt-BR/). +## [1.43.19] - 2025-12-16 + +### Changed +- **Revisão Completa do Modal de Editar Template Recorrente** + - Adicionados TODOS os campos disponíveis no modelo (17 campos totais) + - Campos adicionados: `transaction_description`, `frequency_interval`, `start_date`, `end_date`, `max_occurrences`, `cost_center_id`, `is_active` + - Interface reorganizada com ícones e labels claros + - Campos condicionais (day_of_month apenas para frequências mensais) + - Validação e parsing corretos dos dados antes do envio + - Placeholders e textos de ajuda para melhor UX + - Informações do template (ID, data criação, ocorrências geradas) exibidas no rodapé + - Suporte a status ativo/pausado com toggle visual + - Campo de intervalo para repetições personalizadas (ex: a cada 2 meses) + ## [1.43.18] - 2025-12-16 ### Changed diff --git a/VERSION b/VERSION index 3890156..3f05860 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.43.18 +1.43.19 diff --git a/frontend/src/pages/RecurringTransactions.jsx b/frontend/src/pages/RecurringTransactions.jsx index 6ac269a..b063dfe 100644 --- a/frontend/src/pages/RecurringTransactions.jsx +++ b/frontend/src/pages/RecurringTransactions.jsx @@ -1069,26 +1069,46 @@ const ReconcileModal = ({ show, onClose, instance, candidates, onSubmit, formatC const EditTemplateModal = ({ show, onClose, template, accounts, categories, onSubmit, t }) => { const [formData, setFormData] = useState({ name: '', - amount: '', + transaction_description: '', + planned_amount: '', frequency: 'monthly', - type: 'expense', + type: 'debit', account_id: '', category_id: '', + cost_center_id: '', day_of_month: '', - notes: '' + frequency_interval: '1', + start_date: '', + end_date: '', + max_occurrences: '', + notes: '', + is_active: true }); + // Helper para converter data ISO para yyyy-MM-dd + const formatDateForInput = (dateStr) => { + if (!dateStr) return ''; + return dateStr.split('T')[0]; + }; + useEffect(() => { if (template) { setFormData({ name: template.name || '', - amount: template.amount || '', + transaction_description: template.transaction_description || '', + planned_amount: template.planned_amount || '', frequency: template.frequency || 'monthly', - type: template.type || 'expense', + type: template.type || 'debit', account_id: template.account_id || '', category_id: template.category_id || '', + cost_center_id: template.cost_center_id || '', day_of_month: template.day_of_month || '', - notes: template.notes || '' + frequency_interval: template.frequency_interval || '1', + start_date: formatDateForInput(template.start_date) || '', + end_date: formatDateForInput(template.end_date) || '', + max_occurrences: template.max_occurrences || '', + notes: template.notes || '', + is_active: template.is_active !== undefined ? template.is_active : true }); } }, [template]); @@ -1097,90 +1117,211 @@ const EditTemplateModal = ({ show, onClose, template, accounts, categories, onSu const handleSubmit = (e) => { e.preventDefault(); - onSubmit(formData); + + // Preparar dados para envio (remover campos vazios opcionais) + const submitData = { + name: formData.name, + transaction_description: formData.transaction_description, + planned_amount: parseFloat(formData.planned_amount), + frequency: formData.frequency, + type: formData.type, + account_id: formData.account_id, + is_active: formData.is_active, + frequency_interval: formData.frequency_interval ? parseInt(formData.frequency_interval) : 1 + }; + + // Adicionar campos opcionais apenas se preenchidos + if (formData.category_id) submitData.category_id = formData.category_id; + if (formData.cost_center_id) submitData.cost_center_id = formData.cost_center_id; + if (formData.day_of_month) submitData.day_of_month = parseInt(formData.day_of_month); + if (formData.start_date) submitData.start_date = formData.start_date; + if (formData.end_date) submitData.end_date = formData.end_date; + if (formData.max_occurrences) submitData.max_occurrences = parseInt(formData.max_occurrences); + if (formData.notes) submitData.notes = formData.notes; + + onSubmit(submitData); }; + // Verificar se é frequência baseada em meses ou dias + const isMonthlyBased = ['monthly', 'bimonthly', 'quarterly', 'semiannual', 'annual'].includes(formData.frequency); + const isWeeklyBased = ['weekly', 'biweekly'].includes(formData.frequency); + return (
+ {/* Nome e Descrição */}
-
- +
+ setFormData(f => ({ ...f, name: e.target.value }))} - required - /> -
-
- - setFormData(f => ({ ...f, amount: e.target.value }))} + placeholder="Ex: Recibo Luz, Salário, etc." required />
+
+
+ + setFormData(f => ({ ...f, transaction_description: e.target.value }))} + placeholder="Descrição que aparecerá nas transações geradas" + /> +
+
+ + {/* Tipo, Valor e Status */}
- +
- + + setFormData(f => ({ ...f, planned_amount: e.target.value }))} + placeholder="0.00" + required + /> +
+
+ + +
+
+ + {/* Frequência e Intervalo */} +
+
+
- + setFormData(f => ({ ...f, day_of_month: e.target.value }))} + value={formData.frequency_interval} + onChange={(e) => setFormData(f => ({ ...f, frequency_interval: e.target.value }))} + placeholder="1" /> + A cada X {formData.frequency === 'monthly' ? 'meses' : 'períodos'}
+ {/* Dia do Mês (apenas para mensais) */} + {isMonthlyBased && ( +
+
+ + setFormData(f => ({ ...f, day_of_month: e.target.value }))} + placeholder="Ex: 5 para dia 5 de cada mês" + /> + Deixe vazio para usar a data de início +
+
+ )} + + {/* Conta e Categoria */}
- +
- +
-
- -