Skip to content

Commit 27c538b

Browse files
authored
Fix verb assignment for transaction descriptions
Handle None case for subType in transaction description.
1 parent 1a18867 commit 27c538b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ws_api/wealthsimple_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,13 @@ def _activity_add_description(self, act):
556556
act['description'] = f"Money transfer: {direction} Wealthsimple {account_description}"
557557

558558
elif act['type'] in ['DIY_BUY', 'DIY_SELL', 'MANAGED_BUY', 'MANAGED_SELL']:
559-
verb = act['subType'].replace('_', ' ').capitalize()
559+
# subType is None in some cases, so we can't rely on it up front.
560+
# This could be the case for MANAGED actions, so we handle that separately.
561+
verb = ''
560562
if 'MANAGED' in act['type']:
561563
verb = "Managed transaction"
564+
else:
565+
verb = act['subType'].replace('_', ' ').capitalize()
562566
action = 'buy' if act['type'] == 'DIY_BUY' or act['type'] == 'MANAGED_BUY' else 'sell'
563567
security = self.security_id_to_symbol(act['securityId'])
564568
if act['assetQuantity'] is None:

0 commit comments

Comments
 (0)