Skip to content

Commit

Permalink
add feature that finialize can remove current record
Browse files Browse the repository at this point in the history
  • Loading branch information
suqin-haha committed Jan 3, 2025
1 parent f8d2bc5 commit e7d13bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion beangulp/importers/csvbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ def extract(self, filepath, existing):
txn = self.finalize(txn, row)

# Add the transaction to the output list.
entries.append(txn)
if txn is not None:
entries.append(txn)

# Add balance to balances list.
balance = getattr(row, 'balance', None)
Expand Down
18 changes: 18 additions & 0 deletions beangulp/importers/csvbase_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,21 @@ def finalize(self, txn, row):
Assets:CSV -1.00 EUR
Expenses:Testing 1.00 EUR
""")

@docfile
def test_extract_finalize_remove(self, filename):
"""\
2021-05-17, Test, -1.00, Testing
"""
class CSVImporter(Base):
date = Date(0)
narration = Column(1)
amount = Amount(2)
category = Column(3)
names = False

def finalize(self, txn, row):
return None

importer = CSVImporter('Assets:CSV', 'EUR')
entries = importer.extract(filename, [])

0 comments on commit e7d13bd

Please sign in to comment.