2026-10-18 18:49:49 +03:30
|
|
|
|
export function toman(value: string | number | null | undefined) {
|
|
|
|
|
|
const n = Number(value ?? 0);
|
|
|
|
|
|
if (!Number.isFinite(n)) return '۰';
|
|
|
|
|
|
return `${new Intl.NumberFormat('fa-IR').format(Math.round(n))} تومان`;
|
|
|
|
|
|
}
|
2026-11-10 11:09:51 +03:30
|
|
|
|
|
|
|
|
|
|
/** ماندهٔ دریافتنی منهای ماندهٔ پرداختنی: بد قرمز، بس سبز، صفر خاکستری. */
|
|
|
|
|
|
export function partyNetPosition(receivable: number, payable: number) {
|
|
|
|
|
|
const net = receivable - payable;
|
|
|
|
|
|
if (net > 0) return { text: `بد ${toman(net)}`, type: 'danger' as const };
|
|
|
|
|
|
if (net < 0) return { text: `بس ${toman(-net)}`, type: 'success' as const };
|
|
|
|
|
|
return { text: `مانده ${toman(0)}`, type: 'secondary' as const };
|
|
|
|
|
|
}
|