diff --git a/Inkomsten.beancount b/Inkomsten.beancount new file mode 100644 index 0000000..03b24a8 --- /dev/null +++ b/Inkomsten.beancount @@ -0,0 +1,20 @@ +option "name_assets" "Activa" +option "name_equity" "Vermogen" +option "name_expenses" "Uitgaven" +option "name_income" "Inkomsten" +option "name_liabilities" "Passiva" +option "account_previous_balances" "Openingsbalans" + +2025-01-20 document Inkomsten:Statiegeld "docs/Inkomsten/Statiegeld/2025-01-20.SNL-RP18513300.pdf" ^SNL-RP18513300 + +2025-02-24 document Inkomsten:Statiegeld "docs/Inkomsten/Statiegeld/2025-02-24.SNL-RP18714447.pdf" ^SNL-RP18714447 + +2025-03-03 document Inkomsten:Statiegeld "docs/Inkomsten/Statiegeld/2025-03-03.SNL-RP18760713.pdf" ^SNL-RP18760713 + +2025-03-17 document Inkomsten:Statiegeld "docs/Inkomsten/Statiegeld/2025-03-17.SNL-RP18845689.pdf" ^SNL-RP18845689 + +2025-05-06 document Inkomsten:Statiegeld "docs/Inkomsten/Statiegeld/2025-05-06.SNL-RP19169907.pdf" ^SNL-RP19169907 + +2025-06-17 document Inkomsten:Statiegeld "docs/Inkomsten/Statiegeld/2025-06-17.SNL-RP19476245.pdf" ^SNL-RP19476245 + + diff --git a/bitlair.beancount b/bitlair.beancount index e748d66..e6895f9 100644 --- a/bitlair.beancount +++ b/bitlair.beancount @@ -50,6 +50,7 @@ plugin "beancount_periodic.recur" "{'generate_until':'2025-05-31'}" include "Activa/Betaalrekening.beancount" include "Activa/Debiteuren/Huurders.beancount" include "Activa/Debiteuren/Deelnemers.beancount" +include "Inkomsten.beancount" include "Uitgaven.beancount" include "reimburse.beancount" diff --git a/docs/Inkomsten/Statiegeld/2025-01-20.SNL-RP18513300.pdf b/docs/Inkomsten/Statiegeld/2025-01-20.SNL-RP18513300.pdf new file mode 100644 index 0000000..5aa412e Binary files /dev/null and b/docs/Inkomsten/Statiegeld/2025-01-20.SNL-RP18513300.pdf differ diff --git a/docs/Inkomsten/Statiegeld/2025-02-24.SNL-RP18714447.pdf b/docs/Inkomsten/Statiegeld/2025-02-24.SNL-RP18714447.pdf new file mode 100644 index 0000000..4dbcd75 Binary files /dev/null and b/docs/Inkomsten/Statiegeld/2025-02-24.SNL-RP18714447.pdf differ diff --git a/docs/Inkomsten/Statiegeld/2025-03-03.SNL-RP18760713.pdf b/docs/Inkomsten/Statiegeld/2025-03-03.SNL-RP18760713.pdf new file mode 100644 index 0000000..24759af Binary files /dev/null and b/docs/Inkomsten/Statiegeld/2025-03-03.SNL-RP18760713.pdf differ diff --git a/docs/Inkomsten/Statiegeld/2025-03-17.SNL-RP18845689.pdf b/docs/Inkomsten/Statiegeld/2025-03-17.SNL-RP18845689.pdf new file mode 100644 index 0000000..20abd07 Binary files /dev/null and b/docs/Inkomsten/Statiegeld/2025-03-17.SNL-RP18845689.pdf differ diff --git a/docs/Inkomsten/Statiegeld/2025-05-06.SNL-RP19169907.pdf b/docs/Inkomsten/Statiegeld/2025-05-06.SNL-RP19169907.pdf new file mode 100644 index 0000000..e735dc0 Binary files /dev/null and b/docs/Inkomsten/Statiegeld/2025-05-06.SNL-RP19169907.pdf differ diff --git a/docs/Inkomsten/Statiegeld/2025-06-17.SNL-RP19476245.pdf b/docs/Inkomsten/Statiegeld/2025-06-17.SNL-RP19476245.pdf new file mode 100644 index 0000000..5cf385c Binary files /dev/null and b/docs/Inkomsten/Statiegeld/2025-06-17.SNL-RP19476245.pdf differ diff --git a/import/__main__.py b/import/__main__.py index e775f6c..806edb9 100755 --- a/import/__main__.py +++ b/import/__main__.py @@ -41,6 +41,7 @@ if __name__ == "__main__": importers = [ rabobank.Importer("Activa:Betaalrekening", "EUR"), pdf.MollieInvoiceImporter(), + pdf.StatiegeldImporter(), ] hooks = [classify_contra(rabobank.guess_contra, "Activa:Betaalrekening")] main = Ingest(importers, hooks) diff --git a/import/pdf.py b/import/pdf.py index 0418295..051d8fc 100644 --- a/import/pdf.py +++ b/import/pdf.py @@ -84,3 +84,48 @@ class MollieInvoiceImporter(Importer): ], ) return [tx, doc] + + +class StatiegeldImporter(Importer): + def identify(self, filepath): + mimetype, encoding = mimetypes.guess_type(filepath) + if mimetype != "application/pdf": + return False + + lines = pdf_to_text(filepath).split("\n") + return any(line.startswith("Statiegeld Nederland") for line in lines) + + def account(self, filepath): + return "Inkomsten:Statiegeld" + + def tx_ref(self, filepath): + lines = pdf_to_text(filepath).split("\n") + for line in lines: + if m := re.search(r"^Factuurnr : (RP\d+)$", line): + return f"SNL-{m[1]}" + raise Exception("Mollie invoice reference not found") + + def filename(self, filepath): + return f"{self.tx_ref(filepath)}.pdf" + + def date(self, filepath): + lines = pdf_to_text(filepath).split("\n") + for line in lines: + if m := re.search(r"^Datum : (\d{2})/(\d{2})/(\d{4})$", line): + return date(int(m[3]), int(m[2]), int(m[1])) + raise Exception("Date not found") + + def extract(self, filepath, existing): + name = self.filename(filepath) + date = self.date(filepath) + link = self.tx_ref(filepath) + + doc = Document( + meta=data.new_metadata(filepath, 0), + date=date, + account=self.account(filepath), + filename=f"docs/Inkomsten/Statiegeld/{date}.{name}", + tags=set(), + links={link}, + ) + return [doc]