feat: create validated ZUGFeRD invoices in one console command
This commit is contained in:
1 parent
e0c15fc7f2
commit
a643cf5227
30 files changed
+1509
-207
No files matched your search
@@ -1,6 +1,8 @@
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
from .paths import presets_root
|
||||
import re
|
||||
|
||||
def load_yaml(path: Path) -> dict:
|
||||
if not path.exists():
|
||||
@@ -18,6 +20,11 @@ def deep_merge(a: dict, b: dict) -> dict:
|
||||
|
||||
def load_customer_preset(repo_root: Path, customer_key: str) -> dict:
|
||||
key = customer_key.strip().lower()
|
||||
if not re.fullmatch(r"[a-z0-9_-]+", key):
|
||||
raise ValueError("Customer key must contain only letters, digits, _ or -")
|
||||
local = presets_root(repo_root)
|
||||
if (local / "customers" / f"{key}.yaml").is_file():
|
||||
return load_yaml(local / "customers" / f"{key}.yaml")
|
||||
# Prefer per-customer file
|
||||
file_preset = repo_root / "presets" / "customers" / f"{key}.yaml"
|
||||
if file_preset.exists():
|
||||
|
||||
Reference in new issue
Block a user