fix(treasury): show a party's net balance as debtor or creditor

Income and expense forms now use the same receivable-minus-payable figure beside the party.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-10 11:09:51 +03:30
co-authored by Cursor
parent ba7f942059
commit 49459707cb
3 changed files with 47 additions and 23 deletions
@@ -3,3 +3,11 @@ export function toman(value: string | number | null | undefined) {
if (!Number.isFinite(n)) return '۰';
return `${new Intl.NumberFormat('fa-IR').format(Math.round(n))} تومان`;
}
/** ماندهٔ دریافتنی منهای ماندهٔ پرداختنی: بد قرمز، بس سبز، صفر خاکستری. */
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 };
}