Only getting one entry for CSV import using Reds importer

136 views
Skip to first unread message

Christian Kohler

unread,
Jan 13, 2024, 8:49:27 PM1/13/24
to Beancount
I'm trying to import a CSV file from USAA Bank. The CSV file looks like this:
Date,Description,Original Description,Category,Amount,Status
2023-01-03,"Credit Card Payment","CARDMEMBER SERV  WEB PYMT   ***********1234",Credit Card Payment,-663.94,Posted
2023-01-03,"Overdraft Advance Transfer In","OD ADVANCE TRANSFER IN",Transfer,622.42,Posted


When I run my importer, I only get one entry (as opposed to both legs of a double entry accounting transaction). Is this a problem with my transaction_type_map? The output I get looks like this:
2023-01-03 * "CARDMEMBER SERV  WEB PYMT   ***********1234" "Credit Card Payment"
  Assets:US:USAA:Savings  -663.94 USD

2023-01-03 * "OD ADVANCE TRANSFER IN" "Overdraft Advance Transfer In"
  Assets:US:USAA:Savings  622.42 USD


I've created a __init__.py file under beancount_reds_importers/importers/usaa with the following content:
""" USAA csv importer."""

from beancount_reds_importers.libreader import csvreader
from beancount_reds_importers.libtransactionbuilder import banking


class Importer(csvreader.Importer,banking.Importer):
    IMPORTER_NAME = 'USAA CSV'
    def custom_init(self):
        self.max_rounding_error = 0.14
        self.filename_pattern_def = 'bk_download*'
        self.date_format = '%Y-%m-%d'
        self.skip_head_rows = 0
        self.skip_transaction_types = []
        self.header_identifier = 'Date,Description,Original Description,Category,Amount,Status'
     

        # CSV column spec
        self.header_map = {
            "Date": "date",
            "Description": "payee",
            "Category": "type",
            "Original Description":"memo",
            "Amount": "amount",
         }

        self.transaction_type_map = {
            "Interest Income": "income",
            "Credit Card Payment": "expense",
            "Shopping": "expense",
            "Transfer": "transfer",
            "ATM": "cash",
            "FEE": "fees",
        }

Here is what my.import looks like:
"""Import configuration."""

import sys
from os import path

sys.path.insert(0, path.join(path.dirname(__file__)))

from beancount_reds_importers.importers import vanguard,chase,usaa
from beancount_reds_importers.importers.schwab import schwab_csv_brokerage
from fund_info import *
CONFIG = [
        usaa.Importer({
        'main_account'  : 'Assets:US:USAA:SavingsChristian',
        'interest'      : 'Income:US:Interest:USAA:SavingsChristian',
        'income'        : 'Income:US:USAA:SavingsChristian',
        'expense'       : 'Expenses:Shopping',
        'currency'      : 'USD',
    }),
]


Can you tell me what I'm missing here?
Thanks

Christian
Message has been deleted

Max Tower

unread,
Jan 14, 2024, 4:07:01 PM1/14/24
to Beancount

Disregard what I said in my earlier post. I think your config may be missing: target_account

You could override the method below to use different targets for different types, like expense or interest you have specified above.
def get_target_account(self, ot):
     """Can be overridden by importer"""
     return self.config.get('target_account')

Red S

unread,
Jan 16, 2024, 6:41:46 AM1/16/24
to Beancount

Hi there,
That’s by design. From this article:

Banks and credit cards benefit from a postings predictor like smart_importer. Hence, the transaction builders for these are the simplest, producing only a single posting per account, with the assumption that the other posting(s) will be automatically filled in by smart_importer.

Here’s example code that uses smart_importer.

Red S

unread,
Jan 16, 2024, 6:46:27 AM1/16/24
to Beancount

This is also correct, apparently (I’d forgotten!). See this code.

Reply all
Reply to author
Forward
0 new messages