Initial version of the E-Invoice solution of JR IT Services

This commit is contained in:
2026-02-16 17:02:03 +01:00
commit e0c15fc7f2
36 changed files with 1407 additions and 0 deletions

27
jr_einvoice/presets.py Normal file
View File

@@ -0,0 +1,27 @@
from __future__ import annotations
from pathlib import Path
import yaml
def load_yaml(path: Path) -> dict:
if not path.exists():
return {}
return yaml.safe_load(path.read_text(encoding="utf-8")) or {}
def deep_merge(a: dict, b: dict) -> dict:
out = dict(a)
for k, v in (b or {}).items():
if isinstance(v, dict) and isinstance(out.get(k), dict):
out[k] = deep_merge(out[k], v)
else:
out[k] = v
return out
def load_customer_preset(repo_root: Path, customer_key: str) -> dict:
key = customer_key.strip().lower()
# Prefer per-customer file
file_preset = repo_root / "presets" / "customers" / f"{key}.yaml"
if file_preset.exists():
return load_yaml(file_preset)
# Fallback to shared customers.yaml
shared = load_yaml(repo_root / "presets" / "customers.yaml").get("customers", {})
return shared.get(key, {})