fix(campaigns): show the real balance on a prepay ad account

"Balance: INR 0.00" was technically accurate and completely misleading —
that field means amount owed, not money on deposit, and it is 0 by design
on a prepay account right after funds are added. A prepay account now
shows "Available funds" using Meta's own display string instead
(e.g. "Available balance (₹50.00 INR)"); a post-pay account is unaffected
and still shows Balance as before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
AFFAANh
2026-08-07 17:12:50 +05:30
co-authored by Claude Opus 5
parent ba5818b2fd
commit 4eb60800d1
2 changed files with 27 additions and 4 deletions
+8
View File
@@ -84,6 +84,14 @@ export interface AdAccount {
min_daily_budget?: number;
is_prepay_account?: boolean;
funding_source?: string;
/**
* On a prepay account, `balance` is the amount owed — 0 even with money
* loaded, because nothing has been billed yet. The wallet amount is only
* available here, as a string Meta has already formatted for display
* (e.g. "Available balance (₹50.00 INR)"); Graph exposes no separate
* number for it.
*/
funding_source_details?: { id?: string; display_string?: string; type?: number };
account_status?: number;
}
+15
View File
@@ -134,10 +134,25 @@ export default function CampaignsPage() {
{account && (
<Card title="Ad account">
<Space size="large" wrap>
{account.is_prepay_account ? (
// On a prepay account "balance" means amount owed, which is
// legitimately 0 even with money loaded — nothing has been
// billed yet. Meta only exposes the wallet amount as an
// already-formatted string, not a separate number, so that
// is what gets shown here instead of a confusing "0.00".
<Statistic
title="Available funds"
value={
account.funding_source_details?.display_string ??
"No funding source"
}
/>
) : (
<Statistic
title="Balance"
value={money(account.balance, account.currency)}
/>
)}
<Statistic
title="Lifetime spend"
value={money(account.amount_spent, account.currency)}