Skip to content

Commit

Permalink
fix: one-file-per-account broke with smart_importer #97
Browse files Browse the repository at this point in the history
  • Loading branch information
redstreet committed Apr 4, 2024
1 parent e94b3f1 commit 45fb855
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
3 changes: 0 additions & 3 deletions beancount_reds_importers/importers/workday/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,3 @@ def valid_header_label(label):
for header in table.header():
table = table.rename(header, valid_header_label(header))
self.alltables[section] = table

def build_metadata(self, file, metatype=None, data={}):
return {"filing_account": self.config["main_account"]}
6 changes: 0 additions & 6 deletions beancount_reds_importers/libtransactionbuilder/banking.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ def build_account_map(self):
# }
pass

def build_metadata(self, file, metatype=None, data={}):
"""This method is for importers to override. The overridden method can
look at the metatype ('transaction', 'balance', 'account', 'commodity', etc.)
and the data dictionary to return additional metadata"""
return {}

def match_account_number(self, file_account, config_account):
return file_account.endswith(config_account)

Expand Down
12 changes: 3 additions & 9 deletions beancount_reds_importers/libtransactionbuilder/investments.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ def build_account_map(self):
)
# fmt: on

def build_metadata(self, file, metatype=None, data={}):
"""This method is for importers to override. The overridden method can
look at the metatype ('transaction', 'balance', 'account', 'commodity', etc.)
and the data dictionary to return additional metadata"""
return {}

def custom_init(self):
if not self.custom_init_run:
self.max_rounding_error = 0.04
Expand Down Expand Up @@ -276,9 +270,9 @@ def generate_trade_entry(self, ot, file, counter):
if "sell" in ot.type:
units = -1 * abs(ot.units)
if not is_money_market:
metadata["todo"] = (
"TODO: this entry is incomplete until lots are selected (bean-doctor context <filename> <lineno>)" # noqa: E501
)
metadata[
"todo"
] = "TODO: this entry is incomplete until lots are selected (bean-doctor context <filename> <lineno>)" # noqa: E501
if ot.type in [
"reinvest"
]: # dividends are booked to commodity_leaf. Eg: Income:Dividends:HOOLI
Expand Down
6 changes: 0 additions & 6 deletions beancount_reds_importers/libtransactionbuilder/paycheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ def build_postings(self, entry):
newentry = entry._replace(postings=postings)
return newentry

def build_metadata(self, file, metatype=None, data={}):
"""This method is for importers to override. The overridden method can
look at the metatype ('transaction', 'balance', 'account', 'commodity', etc.)
and the data dictionary to return additional metadata"""
return {}

def extract(self, file, existing_entries=None):
self.initialize(file)
config = self.config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ def set_config_variables(self, substs):
self.config["filing_account"] = self.remove_empty_subaccounts(
filing_account
)

def build_metadata(self, file, metatype=None, data={}):
"""This method is for importers to override. The overridden method can
look at the metatype ('transaction', 'balance', 'account', 'commodity', etc.)
and the data dictionary to return additional metadata"""

# This 'filing_account' is read by a patch to bean-extract so it can output transactions to
# a file that corresponds with filing_account, when the one-file-per-account feature is
# used.
acct = self.config.get("filing_account", self.config.get("main_account", None))
return {"filing_account": acct}

0 comments on commit 45fb855

Please sign in to comment.