-
Notifications
You must be signed in to change notification settings - Fork 11
Update to reflect latest changes in Revolut outputs #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,8 @@ | |
|
|
||
| class RowParser: | ||
| OPERATIONS = { | ||
| "BUY - MARKET": OperationType.BUY, | ||
| "BUY - LIMIT": OperationType.BUY, | ||
| "SELL - MARKET": OperationType.SELL, | ||
| "SELL - LIMIT": OperationType.SELL, | ||
| "BUY": OperationType.BUY, | ||
| "SELL": OperationType.SELL, | ||
| "DIVIDEND": OperationType.DIVIDEND, | ||
| "CUSTODY FEE": OperationType.SERVICE_FEE, | ||
| "STOCK SPLIT": OperationType.STOCK_SPLIT, | ||
|
|
@@ -27,6 +25,7 @@ def _fiat_value(cls, row: Dict) -> FiatValue: | |
| currency = CurrencyBuilder.build(row['Currency']) | ||
| # e.g."-$1,003.01" | ||
| amount_row = row['Total Amount'] | ||
| amount_row = amount_row.strip(str(currency)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I handled it already in #36 :) |
||
| if amount_row.startswith("-"): | ||
| amount_row = amount_row[1:] | ||
| amount_row = amount_row[1:].replace(",", "") | ||
|
|
@@ -43,4 +42,10 @@ def _date(cls, row: dict) -> pendulum.DateTime: | |
|
|
||
| @classmethod | ||
| def _operation_type(cls, row: dict) -> OperationType: | ||
| return cls.OPERATIONS.get(row['Type']) | ||
| operation_type = cls.OPERATIONS.get(row['Type']) | ||
| if operation_type: | ||
| return operation_type | ||
| for operation_name, operation_type in cls.OPERATIONS.items(): | ||
| if operation_name in row['Type']: | ||
| return operation_type | ||
| return None | ||
|
Comment on lines
+45
to
+51
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather make this whole function a regex matching, instead of that. 'BUY\w+' is OperationType.BUY etc, |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the whole _datetime function can look just like this:
with include
from dateutil import parser as dateutil_parserat the top of the fileIn that way we won't be dependent on any other future date format changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to give it a try - if it works it would be awesome! 👍
It's really tedious to work out those Revolut date formats...
@MarvinRucinski could you check it out?