diff --git a/beancount_cde_importer/__init__.py b/beancount_cde_importer/__init__.py index 59042f3..260f8ef 100644 --- a/beancount_cde_importer/__init__.py +++ b/beancount_cde_importer/__init__.py @@ -16,6 +16,7 @@ COL_LABEL = "Libelle simplifie" COL_DEBIT = "Debit" COL_CREDIT = "Credit" COL_DETAIL = "Informations complementaires" +COL_DATE_OP = "Date operation" END_DATE_REGEX = "Date de fin de téléchargement : ([0-3][0-9]/[0-1][0-9]/[0-9]{4})" START_DATE_REGEX = "Date de début de téléchargement : ([0-3][0-9]/[0-1][0-9]/[0-9]{4})" @@ -58,9 +59,7 @@ class CDEImporter(importer.ImporterProtocol): if row is None: return None - return datetime.strptime( - row[COL_DATE], "%d/%m/%Y" - ).date() + return datetime.strptime(row[COL_DATE], "%d/%m/%Y").date() def extract(self, file: cache._FileMemo, existing_entries=None) -> list[Any]: directives: list[Any] = [] @@ -74,9 +73,8 @@ class CDEImporter(importer.ImporterProtocol): lineno: int = index + 2 # entries start at line 2 meta = data.new_metadata(file.name, lineno) - transaction_date: date = datetime.strptime( - row[COL_DATE], "%d/%m/%Y" - ).date() + transaction_date: date = datetime.strptime(row[COL_DATE], "%d/%m/%Y").date() + op_date: date = datetime.strptime(row[COL_DATE_OP], "%d/%m/%Y") label: str = row[COL_LABEL] debit: str = row[COL_DEBIT] credit: str = row[COL_CREDIT] @@ -88,7 +86,12 @@ class CDEImporter(importer.ImporterProtocol): amount = Decimal(debit.replace(",", ".")) postings.append( data.Posting( - self.account, Amount(amount, "EUR"), None, None, None, None + self.account, + Amount(amount, "EUR"), + None, + None, + None, + {"op-date": op_date}, ) ) @@ -96,7 +99,12 @@ class CDEImporter(importer.ImporterProtocol): amount = Decimal(credit.replace(",", ".")) postings.append( data.Posting( - self.account, Amount(amount, "EUR"), None, None, None, None + self.account, + Amount(amount, "EUR"), + None, + None, + None, + {"op-date": op_date}, ) )