Check latest transaction before logging in
If the latest transaction was recent enough to skip importing transactions, we don't even need to log in to the bank websites. Thus, we should delay the login step until after we've checked this.master
parent
22a5c6972e
commit
6091666471
|
@ -206,7 +206,6 @@ def download_chase(
|
||||||
page: Page, end_date: datetime.date, token: str, importer: FireflyImporter
|
page: Page, end_date: datetime.date, token: str, importer: FireflyImporter
|
||||||
) -> bool:
|
) -> bool:
|
||||||
with Chase(page) as c, ntfyerror('Chase', page) as r:
|
with Chase(page) as c, ntfyerror('Chase', page) as r:
|
||||||
c.login()
|
|
||||||
key = ACCOUNTS['chase']
|
key = ACCOUNTS['chase']
|
||||||
try:
|
try:
|
||||||
start_date = get_last_transaction_date(key, token)
|
start_date = get_last_transaction_date(key, token)
|
||||||
|
@ -222,6 +221,7 @@ def download_chase(
|
||||||
start_date,
|
start_date,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
c.login()
|
||||||
csv = c.download_transactions(start_date, end_date)
|
csv = c.download_transactions(start_date, end_date)
|
||||||
log.info('Importing transactions from Chase into Firefly III')
|
log.info('Importing transactions from Chase into Firefly III')
|
||||||
c.firefly_import(csv, key, importer)
|
c.firefly_import(csv, key, importer)
|
||||||
|
@ -237,7 +237,6 @@ def download_commerce(
|
||||||
log.info('Downloading transaction lists from Commerce Bank')
|
log.info('Downloading transaction lists from Commerce Bank')
|
||||||
csvs = []
|
csvs = []
|
||||||
with CommerceBank(page) as c, ntfyerror('Commerce Bank', page) as r:
|
with CommerceBank(page) as c, ntfyerror('Commerce Bank', page) as r:
|
||||||
c.login()
|
|
||||||
for name, key in ACCOUNTS['commerce'].items():
|
for name, key in ACCOUNTS['commerce'].items():
|
||||||
try:
|
try:
|
||||||
start_date = get_last_transaction_date(key, token)
|
start_date = get_last_transaction_date(key, token)
|
||||||
|
@ -260,6 +259,7 @@ def download_commerce(
|
||||||
start_date,
|
start_date,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
c.login()
|
||||||
c.open_account(name)
|
c.open_account(name)
|
||||||
csvs.append((key, c.download_transactions(start_date, end_date)))
|
csvs.append((key, c.download_transactions(start_date, end_date)))
|
||||||
log.info('Importing transactions from Commerce Bank into Firefly III')
|
log.info('Importing transactions from Commerce Bank into Firefly III')
|
||||||
|
@ -382,6 +382,8 @@ class CommerceBank:
|
||||||
self.logout()
|
self.logout()
|
||||||
|
|
||||||
def login(self) -> None:
|
def login(self) -> None:
|
||||||
|
if self._logged_in:
|
||||||
|
return
|
||||||
log.debug('Navigating to %s', self.URL)
|
log.debug('Navigating to %s', self.URL)
|
||||||
self.page.goto(self.URL)
|
self.page.goto(self.URL)
|
||||||
password = rbw_get(self.vault_item, self.vault_folder, self.username)
|
password = rbw_get(self.vault_item, self.vault_folder, self.username)
|
||||||
|
@ -567,6 +569,8 @@ class Chase:
|
||||||
log.info('Successfully saved cookies to %s', self.saved_cookies)
|
log.info('Successfully saved cookies to %s', self.saved_cookies)
|
||||||
|
|
||||||
def login(self) -> None:
|
def login(self) -> None:
|
||||||
|
if self._logged_in:
|
||||||
|
return
|
||||||
log.debug('Navigating to %s', self.URL)
|
log.debug('Navigating to %s', self.URL)
|
||||||
self.page.goto(self.URL)
|
self.page.goto(self.URL)
|
||||||
self.page.wait_for_load_state()
|
self.page.wait_for_load_state()
|
||||||
|
|
Loading…
Reference in New Issue