Skip to content

Commit

Permalink
fix: schwab_csv_checking format changed #91
Browse files Browse the repository at this point in the history
Schwab also has json and xml, we should move to those, since they are
far more stable formats
  • Loading branch information
redstreet committed Jan 5, 2024
1 parent 4bba61d commit 9cababa
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions beancount_reds_importers/importers/schwab/schwab_csv_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ class Importer(csvreader.Importer, banking.Importer):
def custom_init(self):
self.max_rounding_error = 0.04
self.filename_pattern_def = '.*_Checking_Transactions_'
self.header_identifier = '"Transactions for Checking account.*'
self.column_labels_line = '"Date","Type","Check #","Description","Withdrawal (-)","Deposit (+)","RunningBalance"'
self.header_identifier = ''
self.column_labels_line = '"Date","Status","Type","CheckNumber","Description","Withdrawal","Deposit","RunningBalance"'
self.date_format = '%m/%d/%Y'
self.skip_comments = '# '
self.header_map = {
"Date": "date",
"Type": "type",
"Check #": "checknum",
"CheckNumber": "checknum",
"Description": "payee",
"Withdrawal (-)": "withdrawal",
"Deposit (+)": "deposit",
"Withdrawal": "withdrawal",
"Deposit": "deposit",
"RunningBalance": "balance"
}
self.transaction_type_map = {
Expand All @@ -31,18 +31,8 @@ def custom_init(self):
self.skip_transaction_types = ['Journal']

def prepare_table(self, rdr):
if self.config.get('include_pending', False):
rows_to_remove = ['Pending Transactions', 'Posted Transactions', 'Total Pending Check']
rdr = rdr.select(lambda x: not any(x[0].startswith(i) for i in rows_to_remove))
# TODO: this doesn't work with generating balance assertions: pending transactions
# don't include balance assertion data. So what we need to do is generate a balance
# assertion at the end of posted transactions. This has not yet been done.
else:
# There are two sub-tables: pending and posted transactions. Skip pending transactions
rdr = self.skip_until_row_contains(rdr, "Posted Transactions")

rdr = rdr.addfield('amount',
lambda x: "-" + x['Withdrawal (-)'] if x['Withdrawal (-)'] != '' else x['Deposit (+)'])
lambda x: "-" + x['Withdrawal'] if x['Withdrawal'] != '' else x['Deposit'])
rdr = rdr.addfield('memo', lambda x: '')
return rdr

Expand Down

0 comments on commit 9cababa

Please sign in to comment.