Skip to content

Commit

Permalink
Merge d9031e8 into 5748edd
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbPy committed Aug 8, 2020
2 parents 5748edd + d9031e8 commit 2f6d6f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions beancount_import/source/generic_importer_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import itertools
from typing import Hashable, List, Dict, Optional

from beancount.core.data import Transaction, Posting, Directive
from beancount.core.data import Balance, Transaction, Posting, Directive
from beancount.core.amount import Amount
from beancount.ingest.importer import ImporterProtocol
from beancount.ingest.cache import get_file
Expand Down Expand Up @@ -109,7 +109,11 @@ def _get_source_posting(self, entry:Transaction) -> Optional[Posting]:
return posting
return None

def _get_key_from_imported_entry(self, entry:Transaction) -> Hashable:
def _get_key_from_imported_entry(self, entry:Directive) -> Hashable:
if isinstance(entry, Balance):
return (entry.account, entry.date, entry.amount)
if not isinstance(entry, Transaction):
raise ValueError("currently, ImporterSource only supports Transaction and Balance Directive")
source_posting = self._get_source_posting(entry)
if source_posting is None:
raise ValueError("entry has no postings for account: {}".format(self.account))
Expand Down

0 comments on commit 2f6d6f1

Please sign in to comment.