Skip to content

Commit

Permalink
Merge pull request #26 from hades/master
Browse files Browse the repository at this point in the history
add filtering by the "Product" column
  • Loading branch information
mlaitinen authored Sep 8, 2024
2 parents 18d04cb + 7bce386 commit 04d684d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ofxstatement/plugins/revolut.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class RevolutCSVStatementParser(CsvStatementParser):

__slots__ = 'columns'
__slots__ = ('columns', 'product')

date_format = "%Y-%m-%d %H:%M:%S"

Expand Down Expand Up @@ -56,6 +56,9 @@ def parse_record(self, line: List[str]) -> Optional[StatementLine]:
if line[c["State"]] != "COMPLETED":
return None

if self.product and line[c["Product"]] != self.product:
return None

stmt_line = super().parse_record(line)

# Generate a unique ID
Expand Down Expand Up @@ -106,14 +109,16 @@ def get_parser(self, filename: str) -> RevolutCSVStatementParser:
"Description",
"Amount",
"Currency",
"Balance"
"Balance",
"Product",
]

if set(required_columns).issubset(csv_columns):

f.seek(0)
parser = RevolutCSVStatementParser(f)
parser.columns = {col: csv_columns.index(col) for col in csv_columns}
parser.product = self.settings.get('product')
if 'account' in self.settings:
parser.statement.account_id = self.settings['account']
else:
Expand Down

0 comments on commit 04d684d

Please sign in to comment.