Skip to content

Commit

Permalink
fix: ugly hack to handle #41 until that is resolved upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
redstreet committed Feb 27, 2023
1 parent 22831a1 commit 996ad32
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions beancount_reds_importers/libreader/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ def file_name(self, file):
return '{}'.format(ntpath.basename(file.name))

def file_account(self, _):
# Ugly hack to handle:
# https://github.com/redstreet/beancount_reds_importers/issues/41
# https://github.com/beancount/smart_importer/issues/122
# https://github.com/beancount/smart_importer/issues/30
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)

if any('predictor' in i.filename for i in calframe): # smart_importer call
if 'smart_importer_hack' in self.config:
return self.config['smart_importer_hack']

# bean-file call
if 'filing_account' in self.config:
return self.config['filing_account']
return self.config['main_account'].replace(':{ticker}', '').replace(':{currency}', '')
Expand Down

0 comments on commit 996ad32

Please sign in to comment.