/*
* =============================================================================
* VibeQuant (vquant) — AI-Powered Financial Intelligence Platform
* -----------------------------------------------------------------------------
* File: client/src/components/explore/financial-statements-view.tsx
*
* Author: Simon-Pierre Boucher
* Contact: contact@spboucher.ai
* Website: https://www.spboucher.ai
* Demo: https://www.vquant.ai
* License: MIT (see LICENSE)
*
* Copyright © 2026 Simon-Pierre Boucher. All rights reserved.
* =============================================================================
*/
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { TrendingUp, TrendingDown, FileText, DollarSign, Wallet, Activity } from "lucide-react";
interface FinancialStatement {
date: string;
symbol: string;
reportedCurrency: string;
cik: string;
fillingDate: string;
acceptedDate: string;
calendarYear: string;
period: string;
link: string;
finalLink: string;
[key: string]: any;
}
interface FinancialStatementsViewProps {
incomeStatement?: FinancialStatement[];
balanceSheet?: FinancialStatement[];
cashFlow?: FinancialStatement[];
period: "annual" | "quarter";
}
export function FinancialStatementsView({
incomeStatement,
balanceSheet,
cashFlow,
period
}: FinancialStatementsViewProps) {
const formatCurrency = (value: number) => {
if (!value) return "N/A";
const absValue = Math.abs(value);
if (absValue >= 1e12) return `$${(value / 1e12).toFixed(2)}T`;
if (absValue >= 1e9) return `$${(value / 1e9).toFixed(2)}B`;
if (absValue >= 1e6) return `$${(value / 1e6).toFixed(2)}M`;
if (absValue >= 1e3) return `$${(value / 1e3).toFixed(2)}K`;
return `$${value.toFixed(2)}`;
};
const formatPercent = (value: number) => {
if (!value) return "N/A";
return `${(value * 100).toFixed(2)}%`;
};
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString('fr-FR', {
year: 'numeric',
month: 'short',
day: 'numeric'
});
};
const getChangeIndicator = (current: number, previous: number) => {
if (!current || !previous) return null;
const change = ((current - previous) / Math.abs(previous)) * 100;
const isPositive = change >= 0;
return (
{isPositive ? : }
{isPositive ? '+' : ''}{change.toFixed(1)}%
);
};
// Income Statement
const incomeStatementRows = [
{ label: "Revenu Total", key: "revenue", highlight: true },
{ label: "Coût des Revenus", key: "costOfRevenue" },
{ label: "Marge Brute", key: "grossProfit", highlight: true },
{ label: "Dépenses R&D", key: "researchAndDevelopmentExpenses" },
{ label: "Dépenses Générales", key: "generalAndAdministrativeExpenses" },
{ label: "Dépenses Marketing", key: "sellingAndMarketingExpenses" },
{ label: "Dépenses d'Exploitation", key: "operatingExpenses" },
{ label: "Revenu d'Exploitation", key: "operatingIncome", highlight: true },
{ label: "Revenu d'Intérêts", key: "interestIncome" },
{ label: "Dépenses d'Intérêts", key: "interestExpense" },
{ label: "Autres Revenus/Dépenses", key: "otherExpenses" },
{ label: "Revenu avant Impôts", key: "incomeBeforeTax", highlight: true },
{ label: "Charge d'Impôt", key: "incomeTaxExpense" },
{ label: "Revenu Net", key: "netIncome", highlight: true, important: true },
{ label: "BPA", key: "eps", isEPS: true },
{ label: "BPA Dilué", key: "epsdiluted", isEPS: true },
];
// Balance Sheet
const balanceSheetRows = [
{ label: "Actifs", section: true },
{ label: "Trésorerie", key: "cashAndCashEquivalents" },
{ label: "Placements Court Terme", key: "shortTermInvestments" },
{ label: "Comptes Clients", key: "netReceivables" },
{ label: "Inventaire", key: "inventory" },
{ label: "Actifs Courants", key: "totalCurrentAssets", highlight: true },
{ label: "Immobilisations", key: "propertyPlantEquipmentNet" },
{ label: "Goodwill", key: "goodwill" },
{ label: "Actifs Intangibles", key: "intangibleAssets" },
{ label: "Placements Long Terme", key: "longTermInvestments" },
{ label: "Total Actifs", key: "totalAssets", highlight: true, important: true },
{ label: "Passifs", section: true },
{ label: "Comptes Fournisseurs", key: "accountPayables" },
{ label: "Dette Court Terme", key: "shortTermDebt" },
{ label: "Passifs Courants", key: "totalCurrentLiabilities", highlight: true },
{ label: "Dette Long Terme", key: "longTermDebt" },
{ label: "Total Passifs", key: "totalLiabilities", highlight: true, important: true },
{ label: "Capitaux Propres", section: true },
{ label: "Actions Ordinaires", key: "commonStock" },
{ label: "Bénéfices Non Répartis", key: "retainedEarnings" },
{ label: "Total Capitaux Propres", key: "totalStockholdersEquity", highlight: true, important: true },
];
// Cash Flow
const cashFlowRows = [
{ label: "Activités d'Exploitation", section: true },
{ label: "Revenu Net", key: "netIncome", highlight: true },
{ label: "Dépréciation & Amortissement", key: "depreciationAndAmortization" },
{ label: "Variation Fonds de Roulement", key: "changeInWorkingCapital" },
{ label: "Flux de Trésorerie d'Exploitation", key: "operatingCashFlow", highlight: true, important: true },
{ label: "Activités d'Investissement", section: true },
{ label: "Investissements en Immobilisations", key: "capitalExpenditure" },
{ label: "Acquisitions", key: "acquisitionsNet" },
{ label: "Achats d'Investissements", key: "purchasesOfInvestments" },
{ label: "Ventes d'Investissements", key: "salesMaturitiesOfInvestments" },
{ label: "Flux de Trésorerie d'Investissement", key: "netCashUsedForInvestingActivites", highlight: true },
{ label: "Activités de Financement", section: true },
{ label: "Dette Émise", key: "debtRepayment" },
{ label: "Actions Rachetées", key: "commonStockRepurchased" },
{ label: "Dividendes Payés", key: "dividendsPaid" },
{ label: "Flux de Trésorerie de Financement", key: "netCashUsedProvidedByFinancingActivities", highlight: true },
{ label: "Variation Nette de Trésorerie", key: "netChangeInCash", highlight: true, important: true },
{ label: "Flux de Trésorerie Libre", key: "freeCashFlow", highlight: true, important: true },
];
const renderTable = (
data: FinancialStatement[] | undefined,
rows: Array<{ label: string; key?: string; highlight?: boolean; important?: boolean; section?: boolean; isEPS?: boolean }>,
title: string,
description: string,
icon: React.ReactNode
) => {
if (!data || data.length === 0) {
return (
{icon}
{title}
{description}
Aucune donnée disponible
);
}
return (
{icon}
{title}
{description}
Élément
{data.slice(0, 5).map((item, idx) => (
{formatDate(item.date)}
{item.period}
))}
{rows.map((row, rowIdx) => {
if (row.section) {
return (
{row.label}
);
}
return (
{row.label}
{data.slice(0, 5).map((item, idx) => {
const value = row.key ? item[row.key] : null;
const prevValue = idx < data.length - 1 && row.key ? data[idx + 1][row.key] : null;
return (
{row.isEPS ? (value ? `$${value.toFixed(2)}` : 'N/A') : formatCurrency(value)}
{value && prevValue && getChangeIndicator(value, prevValue)}
);
})}
);
})}
{data[0]?.link && (
)}
);
};
return (
{renderTable(
incomeStatement,
incomeStatementRows,
"Compte de Résultat",
"Performance financière et rentabilité",
)}
{renderTable(
balanceSheet,
balanceSheetRows,
"Bilan",
"Actifs, passifs et capitaux propres",
)}
{renderTable(
cashFlow,
cashFlowRows,
"Tableau de Flux de Trésorerie",
"Flux de trésorerie par activité",
)}
);
}