new files for beancount 3

This commit is contained in:
Visual Studio Web Coder
2025-08-17 17:20:23 +00:00
parent e908bad8a1
commit 0f3d48e0b9
7 changed files with 46 additions and 237 deletions

35
importers/csvbank.py Normal file
View File

@@ -0,0 +1,35 @@
import os
from beangulp import mimetypes
from beangulp.importers import csvbase
from beangulp.testing import main as testing_main
class Importer(csvbase.Importer):
# TODO Deutscher CSV header überprüfen: Posting Date ; Description ; Note ; Amount, Balance
date = csvbase.Date('Posting Date', '%Y-%m-%d') # ! date-Format anpassen
narration = csvbase.Columns('Description', 'Note', sep='; ')
amount = csvbase.Amount('Amount')
balance = csvbase.Amount('Balance')
""" Date,Posting Date,Description,Note,Amount,Balance
2025-08-01,2025-08-01,Grocery Store,, -54.20,1245.80
2025-08-03,2025-08-03,Salary,, 2500.00,3745.80
"""
def identify(self, filepath):
mimetype, _ = mimetypes.guess_type(filepath)
if mimetype != 'text/csv':
return false
with open(filepath, encoding='utf-8') as f:
header = f.readline()
# ! TODO
return header.startswith('Date, Posting Date, Description, Amount')
def filename(self, filepath):
name = os.path.basename(filepath)
return f'csvbank.{name}'
# ? Testing
__name__ '__main__':
# Test-Runner und CLI
testing_main(Importer('Assets:Bank:Checking', 'EUR'))