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

View File

@@ -0,0 +1,30 @@
from __future__ import annotations
import logging
from pathlib import Path
from typing import Optional
def setup_logging(log_level: str, log_file: Optional[Path]) -> logging.Logger:
logger = logging.getLogger("jr_einvoice")
logger.setLevel(logging.DEBUG)
if list(logger.handlers):
return logger
fmt = logging.Formatter(
fmt="%(asctime)s.%(msecs)03d %(levelname)s [%(name)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
ch = logging.StreamHandler()
ch.setLevel(getattr(logging, log_level.upper(), logging.INFO))
ch.setFormatter(fmt)
logger.addHandler(ch)
if log_file is not None:
log_file.parent.mkdir(parents=True, exist_ok=True)
fh = logging.FileHandler(log_file, encoding="utf-8")
fh.setLevel(logging.DEBUG)
fh.setFormatter(fmt)
logger.addHandler(fh)
return logger