Show selected account balance beside the treasury account field.

Color the balance green, red, or gray on income and expense forms so users see cash position before posting.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-15 13:48:30 +03:30
co-authored by Cursor
parent 4409ded0ab
commit 1b08ab1230
3 changed files with 52 additions and 4 deletions
@@ -11,3 +11,13 @@ export function partyNetPosition(receivable: number, payable: number) {
if (net < 0) return { text: `بس ${toman(-net)}`, type: 'success' as const };
return { text: `مانده ${toman(0)}`, type: 'secondary' as const };
}
/** موجودی حساب: مثبت سبز، منفی قرمز، صفر خاکستری. */
export function accountBalanceTone(balance: string | number | null | undefined) {
const n = Number(balance ?? 0);
if (!Number.isFinite(n) || n === 0) {
return { text: `موجودی ${toman(0)}`, type: 'secondary' as const };
}
if (n > 0) return { text: `موجودی ${toman(n)}`, type: 'success' as const };
return { text: `موجودی ${toman(n)}`, type: 'danger' as const };
}