Add activity detail, Jalali pickers, and customer/user profiles.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,3 +22,20 @@ export function formatMoney(amount: number, currency = 'IRR'): string {
|
||||
return `${amount} ${currency}`;
|
||||
}
|
||||
}
|
||||
|
||||
/** مثل ماکاپ: ۲۴۰ میلیون ریال */
|
||||
export function formatCompactMoney(amount: number, currency = 'IRR'): string {
|
||||
const suffix = currencySuffix(currency);
|
||||
const abs = Math.abs(amount);
|
||||
if (abs >= 1_000_000_000) {
|
||||
const n = amount / 1_000_000_000;
|
||||
const rounded = Math.abs(n - Math.round(n)) < 0.05 ? Math.round(n) : Math.round(n * 10) / 10;
|
||||
return `${new Intl.NumberFormat('fa-IR', { maximumFractionDigits: 1 }).format(rounded)} میلیارد ${suffix}`;
|
||||
}
|
||||
if (abs >= 1_000_000) {
|
||||
const n = amount / 1_000_000;
|
||||
const rounded = Math.abs(n - Math.round(n)) < 0.05 ? Math.round(n) : Math.round(n * 10) / 10;
|
||||
return `${new Intl.NumberFormat('fa-IR', { maximumFractionDigits: 1 }).format(rounded)} میلیون ${suffix}`;
|
||||
}
|
||||
return formatMoney(amount, currency);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user