- {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 || '-'}
-
@@ -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 (
+