Add a wipe & recalculate button to the account detail page

Cached daily P&L rows outlive what the Cash History report still
produces (stale pre-roll dates being the recent example), and nothing
deletes them any more. POST /api/accounts/[id]/wipe drops the account's
cached P&L, fund transactions and meta, clears the in-memory view, and
rebuilds from a fresh report — fetchDaysTraded now takes an optional
account filter so one account doesn't cost a report round-trip on every
other. The button confirms inline first: rows older than the report's
28-day window cannot be refetched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-09-08 21:27:34 -05:00
co-authored by Claude Fable 5
parent bd72c4b1f6
commit 5a69ea2f64
4 changed files with 128 additions and 1 deletions
+4 -1
View File
@@ -437,7 +437,9 @@ export class TradovateClient {
return { active, prior };
}
public async fetchDaysTraded(): Promise<{ failedAccounts: number }> {
/** Pass onlyAccountIds to refresh a subset (e.g. one wiped account) without
* paying for a report round-trip on every other account of the firm. */
public async fetchDaysTraded(onlyAccountIds?: number[]): Promise<{ failedAccounts: number }> {
if (!this.accessInfo?.accessToken) return { failedAccounts: 0 };
this.fetchDaysComplete = false;
let failedAccounts = 0;
@@ -524,6 +526,7 @@ export class TradovateClient {
};
for (const account of this.accountList) {
if (onlyAccountIds && !onlyAccountIds.includes(account.id)) continue;
// Load last known fund date and fund transactions from DB
const storedFundDate = loadAccountMeta(account.id, 'last_fund_date');
this.lastFundDates[account.id] = storedFundDate;