Skip to content

Commit 87f7885

Browse files
committed
new: various transactions' description
Fixes #41, #42, #43, #44, #45, #46, #47
1 parent f398262 commit 87f7885

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "ws-api"
7-
version = "0.31.0"
7+
version = "0.32.0"
88
description = "Access your Wealthsimple account using their (GraphQL) API."
99
readme = "README.md"
1010
license = {file = "LICENSE"}

ws_api/formatters.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,29 @@ def format_activity_description(act: dict, api_context) -> None:
232232
f"Money transfer: {direction} Wealthsimple {account_description}"
233233
)
234234

235-
elif act["type"] in ["DIY_BUY", "DIY_SELL", "MANAGED_BUY", "MANAGED_SELL"]:
235+
elif act["type"] == "LEGACY_INTERNAL_TRANSFER":
236+
act["description"] = "Transfer in" if act["subType"] == "DESTINATION" else "Transfer out"
237+
238+
elif act["type"] == "CRYPTO_STAKING_ACTION":
239+
action = "stake" if act["subType"] == "STAKE" else "unstake"
240+
security = api_context.security_id_to_symbol(act["securityId"])
241+
act["description"] = f"Crypto {action}: {float(act['assetQuantity'])} x {security}"
242+
243+
if act["type"] == "CRYPTO_TRANSFER":
244+
action = "sent" if act["subType"] == "TRANSFER_OUT" else "received"
245+
security = api_context.security_id_to_symbol(act["securityId"])
246+
act["description"] = (
247+
f"Crypto {action}: {float(act['assetQuantity'])} x {security}"
248+
)
249+
250+
elif act["type"] in ["DIY_BUY", "DIY_SELL", "MANAGED_BUY", "MANAGED_SELL", "CRYPTO_BUY", "CRYPTO_SELL"]:
236251
if "MANAGED" in act["type"]:
237252
verb = "Managed transaction"
238253
else:
239254
verb = act["subType"].replace("_", " ").capitalize()
240-
action = (
241-
"buy"
242-
if act["type"] == "DIY_BUY" or act["type"] == "MANAGED_BUY"
243-
else "sell"
244-
)
255+
if "CRYPTO" in act["type"]:
256+
verb = f"Crypto {verb}"
257+
action = "buy" if "_BUY" in act["type"] else "sell"
245258
security = api_context.security_id_to_symbol(act["securityId"])
246259
if act["assetQuantity"] is None:
247260
act["description"] = f"{verb}: {action} TBD"
@@ -284,6 +297,9 @@ def format_activity_description(act: dict, api_context) -> None:
284297
elif act["type"] == "REFUND" and act["subType"] == "TRANSFER_FEE_REFUND":
285298
act["description"] = "Reimbursement: account transfer fee"
286299

300+
elif act["type"] == "REFUND":
301+
act["description"] = "Refund"
302+
287303
elif act["type"] == "INTEREST":
288304
if act["subType"] == "FPL_INTEREST":
289305
act["description"] = "Stock Lending Earnings"
@@ -349,6 +365,12 @@ def format_activity_description(act: dict, api_context) -> None:
349365
)
350366
act["description"] = f"Cash back {program}".rstrip()
351367

368+
elif act["type"] == "REIMBURSEMENT" and act["subType"] == "ETF_REBATE":
369+
act["description"] = "Reimbursement: Exchange-traded fund rebate"
370+
371+
elif act["type"] == "REIMBURSEMENT" and act["subType"] == "REWARD":
372+
act["description"] = "Reimbursement: Reward"
373+
352374
elif act["type"] == "SPEND" and act["subType"] == "PREPAID":
353375
merchant = act["spendMerchant"]
354376
act["description"] = f"Purchase: {merchant}"

0 commit comments

Comments
 (0)