Initiële commit: VibeFinance 3-container opzet
Basislijn van de bestaande applicatie (Vite/React frontend, Express backend, PostgreSQL) zoals die in de index stond, plus dev-, release- en documentatiescripts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/** Euro formatter (nl-NL, geen decimalen) */
|
||||
export const fmt = (n) =>
|
||||
new Intl.NumberFormat("nl-NL", {
|
||||
style: "currency", currency: "EUR", maximumFractionDigits: 0,
|
||||
}).format(n || 0);
|
||||
|
||||
/** Percentage formatter */
|
||||
export const pct = (n, d = 1) => `${((n || 0) * 100).toFixed(d)}%`;
|
||||
|
||||
/** ISO datum (YYYY-MM-DD) → Nederlandse notatie (DD-MM-YYYY) */
|
||||
export const fmtDatum = (s) => {
|
||||
if (!s) return s;
|
||||
const [y, m, d] = s.split("-");
|
||||
return `${d}-${m}-${y}`;
|
||||
};
|
||||
|
||||
/** Crypto-bedrag formatter (4 decimalen standaard) */
|
||||
export const fmtCrypto = (n, d = 4) => (parseFloat(n) || 0).toFixed(d);
|
||||
|
||||
/**
|
||||
* Bedrag in USD of EUR opmaken afhankelijk van geselecteerde valuta.
|
||||
* @param {number} amount
|
||||
* @param {"USD"|"EUR"} currency
|
||||
* @param {number} usdEurRate
|
||||
*/
|
||||
export function fmtMoney(amount, currency = "EUR", usdEurRate = 0.92) {
|
||||
const v = currency === "EUR" ? amount * usdEurRate : amount;
|
||||
return new Intl.NumberFormat("nl-NL", {
|
||||
style: "currency",
|
||||
currency,
|
||||
maximumFractionDigits: 0,
|
||||
}).format(v || 0);
|
||||
}
|
||||
Reference in New Issue
Block a user