Initial version of the E-Invoice solution of JR IT Services
This commit is contained in:
16
jr_einvoice/folder_naming.py
Normal file
16
jr_einvoice/folder_naming.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from __future__ import annotations
|
||||
import re
|
||||
|
||||
def slugify(value: str, max_len: int = 40) -> str:
|
||||
v = value.strip()
|
||||
v = re.sub(r"\s+", "_", v)
|
||||
v = re.sub(r"[^A-Za-z0-9_\-]+", "", v)
|
||||
v = v.strip("_-")
|
||||
if len(v) > max_len:
|
||||
v = v[:max_len].rstrip("_-")
|
||||
return v or "Kunde"
|
||||
|
||||
def default_invoice_folder_name(invoice_number: str, customer: str | None = None) -> str:
|
||||
cust = slugify(customer or "Kunde")
|
||||
inv = slugify(invoice_number, max_len=32)
|
||||
return f"Rechnung_{inv}_{cust}"
|
||||
Reference in New Issue
Block a user