--- // BankCard.astro const { frontmatter, allHumans } = Astro.props; const { name, monthly_allowance, type = "FLUX" } = frontmatter; // --- LOGIQUE DE COULEUR SUBTILE --- const bankConfigs = { UpDĂ©jeuner: { color: "#f97316", icon: "🍮" }, "La Banque Postale": { color: "#137bb1", icon: "🏩" }, Sumeria: { color: "#116853", icon: "⚡" }, }; const config = bankConfigs[name as keyof typeof bankConfigs] || { color: "#85a9bc", icon: "◈", }; const color = config.color; // --- LOGIQUE DE RÉCUPÉRATION TEMPORELLE DYNAMIQUE --- // 1. On cherche toutes les entrĂ©es qui contiennent rĂ©ellement des flux const entriesWithFlux = allHumans.filter((h: any) => h.data.manifestations?.some((m: any) => m.cercle === "FLX"), ); // 2. On trouve la date de la toute derniĂšre transaction enregistrĂ©e (pour ne pas ĂȘtre bloquĂ© par un changement de mois vide) const lastFluxEntry = entriesWithFlux.sort( (a: any, b: any) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime(), )[0]; // 3. On dĂ©finit la pĂ©riode de rĂ©fĂ©rence (Mois/AnnĂ©e) const refDate = lastFluxEntry ? new Date(lastFluxEntry.data.date) : new Date(); const refMonth = refDate.getMonth(); const refYear = refDate.getFullYear(); // 4. Somme des flux pour cette pĂ©riode et pour cette banque spĂ©cifique const totalFlux = allHumans.reduce((acc: number, entry: any) => { const d = new Date(entry.data.date); const isSamePeriod = d.getMonth() === refMonth && d.getFullYear() === refYear; if (!isSamePeriod) return acc; const flxManifests = entry.data.manifestations?.filter((m: any) => { const sourceName = m.source?.trim().toLowerCase(); const cardName = name?.trim().toLowerCase(); return m.cercle === "FLX" && sourceName === cardName; }) || []; return ( acc + flxManifests.reduce( (sum: number, m: any) => sum + (Number(m.amount) || 0), 0, ) ); }, 0); // Log de contrĂŽle dans ton terminal Lenovo console.log( `[${name}] Bilan basĂ© sur : ${refMonth + 1}/${refYear} | Total : ${totalFlux}`, ); const percentage = Math.max( 0, Math.min(100, Math.round((totalFlux / monthly_allowance) * 100)), ); // État du Hebel let status = { label: "ABONDANCE", color: "#10b981" }; if (percentage < 20) status = { label: "ÉPUISEMENT", color: "#ef4444" }; else if (percentage < 50) status = { label: "FLUX TENDU", color: "#f59e0b" }; else if (percentage < 85) status = { label: "ÉQUILIBRE", color: "#3b82f6" }; ---
{name} {config.icon}
{percentage}%
{status.label}
Ressource — {type}
{ percentage > 50 ? "Le souffle circule avec aisance." : "Le flux se raréfie, prudence." }
Intégrité
{ Array.from({ length: 5 }).map((_, i) => (
)) }