Skip to content

Commit

Permalink
fix: mizrahi no pending transactions (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
baruchiro authored Jul 13, 2023
1 parent 2f9d736 commit 66e29d5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/scrapers/mizrahi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ class MizrahiScraper extends BaseScraperWithBrowser<ScraperSpecificCredentials>
}
}

private async getPendingTransactions(): Promise<Transaction[]> {
await this.page.$eval(`a[href*="${PENDING_TRANSACTIONS_PAGE}"]`, (el) => (el as HTMLElement).click());
const frame = await waitUntilIframeFound(this.page, (f) => f.url().includes(PENDING_TRANSACTIONS_IFRAME));
const isPending = await waitUntilElementFound(frame, pendingTrxIdentifierId).then(() => true).catch(() => false);
if (!isPending) {
return [];
}

const pendingTxn = await extractPendingTransactions(frame);
return pendingTxn;
}

private async fetchAccount() {
await this.page.$eval(`a[href*="${OSH_PAGE}"]`, (el) => (el as HTMLElement).click());
await waitUntilElementFound(this.page, `a[href*="${TRANSACTIONS_PAGE}"]`);
Expand All @@ -220,11 +232,7 @@ class MizrahiScraper extends BaseScraperWithBrowser<ScraperSpecificCredentials>
const startMoment = getStartMoment(this.options.startDate);
const oshTxnAfterStartDate = oshTxn.filter((txn) => moment(txn.date).isSameOrAfter(startMoment));

await this.page.$eval(`a[href*="${PENDING_TRANSACTIONS_PAGE}"]`, (el) => (el as HTMLElement).click());
const frame = await waitUntilIframeFound(this.page, (f) => f.url().includes(PENDING_TRANSACTIONS_IFRAME));
await waitUntilElementFound(frame, pendingTrxIdentifierId);
const pendingTxn = await extractPendingTransactions(frame);

const pendingTxn = await this.getPendingTransactions();
const allTxn = oshTxnAfterStartDate.concat(pendingTxn);

return {
Expand Down

0 comments on commit 66e29d5

Please sign in to comment.