Add importer for Statiegeld Nederland
This commit is contained in:
parent
3351e2d0d4
commit
d48a4dfd87
10 changed files with 67 additions and 0 deletions
20
Inkomsten.beancount
Normal file
20
Inkomsten.beancount
Normal file
|
@ -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
|
||||
|
||||
|
|
@ -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"
|
||||
|
|
BIN
docs/Inkomsten/Statiegeld/2025-01-20.SNL-RP18513300.pdf
Normal file
BIN
docs/Inkomsten/Statiegeld/2025-01-20.SNL-RP18513300.pdf
Normal file
Binary file not shown.
BIN
docs/Inkomsten/Statiegeld/2025-02-24.SNL-RP18714447.pdf
Normal file
BIN
docs/Inkomsten/Statiegeld/2025-02-24.SNL-RP18714447.pdf
Normal file
Binary file not shown.
BIN
docs/Inkomsten/Statiegeld/2025-03-03.SNL-RP18760713.pdf
Normal file
BIN
docs/Inkomsten/Statiegeld/2025-03-03.SNL-RP18760713.pdf
Normal file
Binary file not shown.
BIN
docs/Inkomsten/Statiegeld/2025-03-17.SNL-RP18845689.pdf
Normal file
BIN
docs/Inkomsten/Statiegeld/2025-03-17.SNL-RP18845689.pdf
Normal file
Binary file not shown.
BIN
docs/Inkomsten/Statiegeld/2025-05-06.SNL-RP19169907.pdf
Normal file
BIN
docs/Inkomsten/Statiegeld/2025-05-06.SNL-RP19169907.pdf
Normal file
Binary file not shown.
BIN
docs/Inkomsten/Statiegeld/2025-06-17.SNL-RP19476245.pdf
Normal file
BIN
docs/Inkomsten/Statiegeld/2025-06-17.SNL-RP19476245.pdf
Normal file
Binary file not shown.
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue