Skip to content

Commit

Permalink
Add Dividende word in the filename (#45)
Browse files Browse the repository at this point in the history
Adding separate Dividende folder and improving name 
Makes it  easy to filter files by name, add Dividende word to the file name and logs.
  • Loading branch information
miry authored Jul 2, 2024
1 parent 32d6d62 commit 74ab06f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions pytr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,13 @@ async def timelineDetail(self, response, dl, max_age_timestamp=0):

isSavingsPlan = (event["eventType"] == "SAVINGS_PLAN_EXECUTED")

isSavingsPlan_fmt = ''
if not isSavingsPlan and event['subtitle'] is not None:
isSavingsPlan = 'Sparplan' in event['subtitle']
isSavingsPlan_fmt = ' -- SPARPLAN' if isSavingsPlan else ''

max_details_digits = len(str(self.num_timeline_details))
self.log.info(
f"{self.received_detail:>{max_details_digits}}/{self.num_timeline_details}: "
+ f"{event['title']} -- {event['subtitle']}{isSavingsPlan_fmt}"
+ f"{event['title']} -- {event['subtitle']} [{event['eventType']}]"
)

if isSavingsPlan:
Expand All @@ -456,22 +454,26 @@ async def timelineDetail(self, response, dl, max_age_timestamp=0):
subfolder = {
'benefits_saveback_execution': 'Saveback',
'benefits_spare_change_execution': 'RoundUp',
'ssp_corporate_action_invoice_cash': 'Dividende',
'CREDIT': 'Dividende',
'INTEREST_PAYOUT_CREATED': 'Zinsen',
}.get(event["eventType"])

for section in response['sections']:
if section['type'] == 'documents':
for doc in section['data']:
try:
timestamp = datetime.strptime(doc['detail'], '%d.%m.%Y').timestamp() * 1000
except (ValueError, KeyError):
timestamp = datetime.now().timestamp() * 1000
if max_age_timestamp == 0 or max_age_timestamp < timestamp:
# save all savingsplan documents in a subdirectory
title = f"{doc['title']} - {event['title']}"
if event['eventType'] in ["ACCOUNT_TRANSFER_INCOMING", "ACCOUNT_TRANSFER_OUTGOING"]:
title += f" - {event['subtitle']}"
dl.dl_doc(doc, title, doc.get('detail'), subfolder)
if section['type'] != 'documents':
continue

for doc in section['data']:
try:
timestamp = datetime.strptime(doc['detail'], '%d.%m.%Y').timestamp() * 1000
except (ValueError, KeyError):
timestamp = datetime.now().timestamp() * 1000
if max_age_timestamp == 0 or max_age_timestamp < timestamp:
# save all savingsplan documents in a subdirectory
title = f"{doc['title']} - {event['title']}"
if event['eventType'] in ["ACCOUNT_TRANSFER_INCOMING", "ACCOUNT_TRANSFER_OUTGOING", "CREDIT"]:
title += f" - {event['subtitle']}"
dl.dl_doc(doc, title, doc.get('detail'), subfolder)

if self.received_detail == self.num_timeline_details:
self.log.info('Received all details')
Expand Down

0 comments on commit 74ab06f

Please sign in to comment.