From 9cababa34c0b6b21d2891bc1465960ad2232527f Mon Sep 17 00:00:00 2001 From: Red S Date: Fri, 5 Jan 2024 14:49:20 -0800 Subject: [PATCH] fix: schwab_csv_checking format changed #91 Schwab also has json and xml, we should move to those, since they are far more stable formats --- .../importers/schwab/schwab_csv_checking.py | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/beancount_reds_importers/importers/schwab/schwab_csv_checking.py b/beancount_reds_importers/importers/schwab/schwab_csv_checking.py index 1a972e3..d3132f4 100644 --- a/beancount_reds_importers/importers/schwab/schwab_csv_checking.py +++ b/beancount_reds_importers/importers/schwab/schwab_csv_checking.py @@ -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 = { @@ -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