From 63da72c7c608b5e5f866b1a7722f9d8233946a74 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 5 Feb 2022 19:50:59 +0100 Subject: [PATCH] handle start date balance --- beancount_cde_importer/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/beancount_cde_importer/__init__.py b/beancount_cde_importer/__init__.py index fa18450..264b0d0 100644 --- a/beancount_cde_importer/__init__.py +++ b/beancount_cde_importer/__init__.py @@ -126,6 +126,23 @@ class CaisseDEpargneImporter(importer.ImporterProtocol): for index, row in enumerate(csv_reader): lineno: int = index + 6 # entries start at line 6 meta = data.new_metadata(file.name, lineno) + + if row[0] == "Solde en début de période": + balance = Decimal(row[4].replace(",", ".")) + directives.append( + data.Balance( + meta=meta, + date=start_date, + account=self.account, + amount=Amount(balance, "EUR"), + tolerance=None, + diff_amount=None, + ) + ) + + # should be the last line anyway + continue + transaction_date: date = datetime.strptime( row[INDEX_DATE], "%d/%m/%y" ).date()