16 lines
593 B
TypeScript
16 lines
593 B
TypeScript
export const formatCurrency = (value: number | string | undefined): string => {
|
|
if (value === undefined || value === null) return "€0.00";
|
|
const numValue = typeof value === "string" ? parseFloat(value) : value;
|
|
if (isNaN(numValue)) return "€0.00";
|
|
return `€${numValue.toFixed(2)}`;
|
|
};
|
|
|
|
export const formatPercentage = (
|
|
value: number | string | undefined
|
|
): string => {
|
|
if (value === undefined || value === null) return "0%";
|
|
const numValue = typeof value === "string" ? parseFloat(value) : value;
|
|
if (isNaN(numValue)) return "0%";
|
|
return `${numValue.toFixed(2)}%`;
|
|
};
|