diff --git a/src/app/DRE/analitico.tsx b/src/app/DRE/analitico.tsx index e2d5514..2b0a841 100644 --- a/src/app/DRE/analitico.tsx +++ b/src/app/DRE/analitico.tsx @@ -147,6 +147,12 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { }).format(value); }; + const formatCurrencyWithColor = (value: number) => { + const formatted = formatCurrency(value); + const isNegative = value < 0; + return { formatted, isNegative }; + }; + const formatDate = (dateString: string) => { return new Date(dateString).toLocaleDateString('pt-BR'); }; @@ -208,7 +214,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { return (
-
+

Análise Analítica

{data.length > 0 && (
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
Histórico
-
- Histórico 2 -
-
Recnum
+
Histórico
+
Histórico 2
+
Recnum
@@ -375,44 +379,56 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { ) : ( sortedData.map((row, index) => (
-
+
{formatDate(row.data_competencia)}
-
+
{formatDate(row.data_vencimento)}
-
+
{formatDate(row.data_caixa)}
-
+
{row.codigo_fornecedor || '-'}
-
+
{row.nome_fornecedor || '-'}
-
+
{row.codigo_centrocusto || '-'}
-
+
{row.codigo_conta || '-'}
-
+
{row.conta || '-'}
-
- {formatCurrency( - typeof row.valor === 'string' - ? parseFloat(row.valor) - : row.valor - )} +
+ {(() => { + const valor = + typeof row.valor === 'string' + ? parseFloat(row.valor) + : row.valor; + const { formatted, isNegative } = + formatCurrencyWithColor(valor); + return ( + + {formatted} + + ); + })()}
-
+
{row.historico || '-'}
-
+
{row.historico2 || '-'}
-
+
{row.recnum || '-'}
@@ -430,7 +446,17 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {

- Valor Total: {formatCurrency(totalValor)} + {(() => { + const { formatted, isNegative } = + formatCurrencyWithColor(totalValor); + return ( + + Valor Total: {formatted} + + ); + })()}

diff --git a/src/app/DRE/teste.tsx b/src/app/DRE/teste.tsx index 0817b0a..ce11257 100644 --- a/src/app/DRE/teste.tsx +++ b/src/app/DRE/teste.tsx @@ -112,6 +112,13 @@ export default function Teste() { }); }; + const formatCurrencyWithColor = (value: string | number) => { + const numValue = typeof value === 'string' ? parseFloat(value) : value; + const formatted = formatCurrency(value); + const isNegative = numValue < 0; + return { formatted, isNegative }; + }; + // Função para extrair códigos dos grupos e subgrupos const extractCodes = (grupo: string, subgrupo?: string) => { const grupoMatch = grupo.match(/^(\d+)/); @@ -640,7 +647,19 @@ export default function Teste() { onClick={() => handleRowClick(row, mes)} > {row.valoresPorMes && row.valoresPorMes[mes] - ? formatCurrency(row.valoresPorMes[mes]) + ? (() => { + const { formatted, isNegative } = + formatCurrencyWithColor(row.valoresPorMes[mes]); + return ( + + {formatted} + + ); + })() : '-'}
))} @@ -648,7 +667,18 @@ export default function Teste() { className="flex-1 min-w-[120px] max-w-[150px] text-right font-medium p-1 border-b px-1 text-xs cursor-pointer hover:bg-blue-50" onClick={() => handleRowClick(row)} > - {formatCurrency(row.total!)} + {(() => { + const { formatted, isNegative } = formatCurrencyWithColor( + row.total! + ); + return ( + + {formatted} + + ); + })()}
))}