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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,10 +134,25 @@ export default function CampaignsPage() {
|
||||
{account && (
|
||||
<Card title="Ad account">
|
||||
<Space size="large" wrap>
|
||||
<Statistic
|
||||
title="Balance"
|
||||
value={money(account.balance, account.currency)}
|
||||
/>
|
||||
{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)}
|
||||
|
||||
Reference in New Issue
Block a user