Beancount importers for Chilean banks
Project description
beancount-chile
Beancount importers for Chilean banks using the beangulp framework.
This project provides importers for various Chilean bank account statement formats, enabling automatic import of transactions into Beancount for double-entry bookkeeping.
Supported Banks and Formats
| Bank | Format | Status | File Extension |
|---|---|---|---|
| Banco de Chile | Cartola (Account Statement) | ✅ Supported | .xls, .xlsx, .pdf |
| Banco de Chile | Credit Card Statements (Facturado/No Facturado) | ✅ Supported | .xls, .xlsx |
Installation
Prerequisites
- Python 3.10 or higher
- Beancount 3.x
From Source
git clone https://github.com/yourusername/beancount-chile.git
cd beancount-chile
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
Usage
Banco de Chile Importer
The Banco de Chile importer supports XLS/XLSX/PDF account statement files (cartola).
Basic Usage
Create a configuration file (e.g., import_config.py):
from beancount_chile import BancoChileImporter, BancoChileCreditImporter
CONFIG = [
# Checking account
BancoChileImporter(
account_number="00-123-45678-90", # Your account number
account_name="Assets:BancoChile:Checking",
currency="CLP",
),
# Credit card
BancoChileCreditImporter(
card_last_four="1234", # Last 4 digits of your card
account_name="Liabilities:CreditCard:BancoChile",
currency="CLP",
),
]
Import Transactions
Use beangulp to extract transactions:
# Identify which importers can handle your files
bean-extract import_config.py ~/Downloads/
# Extract transactions from a specific file (XLS, XLSX, or PDF)
bean-extract import_config.py ~/Downloads/cartola.xls
bean-extract import_config.py ~/Downloads/cartola.pdf
# Extract and append to your beancount file
bean-extract import_config.py ~/Downloads/cartola.pdf >> accounts.beancount
Note: The importer automatically detects the file format (XLS/XLSX/PDF) and uses the appropriate parser. PDF files are parsed using text extraction, which handles the same transaction types as XLS files.
Example Output
The importer will generate Beancount entries like:
2026-01-01 * "Supermercado Santa Isabel" "Supermercado Santa Isabel"
channel: "Internet"
Assets:BancoChile:Checking -45000 CLP
2026-01-03 * "María González" "Traspaso A:María González"
channel: "Internet"
Assets:BancoChile:Checking -125000 CLP
2026-01-05 balance Assets:BancoChile:Checking 1230000 CLP
Banco de Chile Credit Card Importer
The credit card importer supports both billed (Facturado) and unbilled (No Facturado) statements.
Basic Usage
The credit card importer automatically detects whether a file contains billed or unbilled transactions:
from beancount_chile import BancoChileCreditImporter
CONFIG = [
BancoChileCreditImporter(
card_last_four="1234", # Last 4 digits of your card
account_name="Liabilities:CreditCard:BancoChile",
currency="CLP",
),
]
Example Output
Billed Transactions (Mov_Facturado.xls):
2026-01-08 note Liabilities:CreditCard:BancoChile "Credit Card Statement - FACTURADO (Billed) | Total Billed: $850,000 CLP | Minimum Payment: $42,500 CLP | Due Date: 2026-01-21"
2026-01-02 * "SUPERMERCADO JUMBO" "SUPERMERCADO JUMBO SANTIAGO"
statement_type: "facturado"
category: "Total de Pagos, Compras, Cuotas y Avance"
installments: "01/01"
Liabilities:CreditCard:BancoChile 75000 CLP
Unbilled Transactions (Saldo_y_Mov_No_Facturado.xls):
2026-01-16 note Liabilities:CreditCard:BancoChile "Credit Card Statement - NO FACTURADO (Unbilled) | Available Credit: $6,500,000 CLP | Total Limit: $7,000,000 CLP"
2026-01-16 ! "NETFLIX.COM" "NETFLIX.COM COMPRAS"
statement_type: "no_facturado"
city: "LAS CONDES"
installments: "01/01"
Liabilities:CreditCard:BancoChile 12000 CLP
Note: Billed transactions are marked as cleared (*) while unbilled transactions are marked as pending (!).
Features
- Automatic payee extraction: Extracts payee names from transaction descriptions
- Balance assertions: Adds balance assertions to verify account balances
- Metadata tracking: Preserves channel information (Internet, Sucursal, etc.)
- Deduplication support: Works with beangulp's existing entry detection
Development
Running Tests
# Activate virtual environment
source venv/bin/activate
# Run all tests
pytest
# Run with coverage
pytest --cov=beancount_chile
# Run specific test file
pytest tests/test_banco_chile.py -v
Code Quality
# Format code with ruff
ruff format .
# Lint code
ruff check .
# Fix auto-fixable issues
ruff check --fix .
Project Structure
beancount-chile/
├── beancount_chile/ # Main package
│ ├── __init__.py
│ ├── banco_chile.py # Checking account importer
│ ├── banco_chile_credit.py # Credit card importer
│ ├── helpers.py # Shared utilities
│ └── extractors/ # File format parsers
│ ├── __init__.py
│ ├── banco_chile_xls.py # Checking account XLS parser
│ ├── banco_chile_pdf.py # Checking account PDF parser
│ └── banco_chile_credit_xls.py # Credit card parser
├── tests/ # Test suite
│ ├── __init__.py
│ ├── test_banco_chile.py # Checking account tests
│ ├── test_banco_chile_credit.py # Credit card tests
│ ├── test_banco_chile_pdf.py # PDF parser tests
│ └── fixtures/ # Test data (anonymized)
│ ├── banco_chile_cartola_sample.xls
│ ├── banco_chile_credit_facturado_sample.xls
│ └── banco_chile_credit_no_facturado_sample.xls
├── pyproject.toml
├── requirements.txt
└── README.md
Contributing
Contributions are welcome! To add support for a new bank:
- Fork the repository
- Create a feature branch
- Add the importer in
beancount_chile/ - Add an extractor in
beancount_chile/extractors/ - Create anonymized test fixtures in
tests/fixtures/ - Write comprehensive tests
- Update this README
- Submit a pull request
Guidelines
- Privacy: Never commit real bank data. All test fixtures must use anonymized data.
- Testing: Every importer must have comprehensive tests.
- Documentation: Update README.md and CLAUDE.md with new features.
- Code Quality: Follow PEP 8 and use ruff for linting.
License
MIT License
Disclaimer
This project is not affiliated with any bank. Use at your own risk. Always verify imported transactions against your bank statements.
Support
For issues, questions, or contributions, please open an issue on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file beancount_chile-0.2.0.tar.gz.
File metadata
- Download URL: beancount_chile-0.2.0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6ab206dec136294357afc70ff0942ac62f255cd17006bcab5fc12d319b4663d
|
|
| MD5 |
fb77fb428ac8910eb2f8f8cee8f81d6e
|
|
| BLAKE2b-256 |
d4efed3568e27c65da010ddcc57e8e13279ade1deac4261f4b653fc7f104d4fa
|
Provenance
The following attestation bundles were made for beancount_chile-0.2.0.tar.gz:
Publisher:
publish.yml on mabahamo/beancount-chile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beancount_chile-0.2.0.tar.gz -
Subject digest:
a6ab206dec136294357afc70ff0942ac62f255cd17006bcab5fc12d319b4663d - Sigstore transparency entry: 832785468
- Sigstore integration time:
-
Permalink:
mabahamo/beancount-chile@15e09100b5fca33c0276dcbf3aa38399d811af63 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mabahamo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15e09100b5fca33c0276dcbf3aa38399d811af63 -
Trigger Event:
release
-
Statement type:
File details
Details for the file beancount_chile-0.2.0-py3-none-any.whl.
File metadata
- Download URL: beancount_chile-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2588c0f068635f795d831c577e358d8cf3c742fa391385995a3fcb5740c5395
|
|
| MD5 |
3fc964b2a1b363cc3ebe3f57c2240ece
|
|
| BLAKE2b-256 |
957723f308729fbd58c1dd0a05ba75489ddc98fc6778da4fb09df1014aa3e289
|
Provenance
The following attestation bundles were made for beancount_chile-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on mabahamo/beancount-chile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beancount_chile-0.2.0-py3-none-any.whl -
Subject digest:
d2588c0f068635f795d831c577e358d8cf3c742fa391385995a3fcb5740c5395 - Sigstore transparency entry: 832785469
- Sigstore integration time:
-
Permalink:
mabahamo/beancount-chile@15e09100b5fca33c0276dcbf3aa38399d811af63 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mabahamo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15e09100b5fca33c0276dcbf3aa38399d811af63 -
Trigger Event:
release
-
Statement type: