32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
"""Application configuration (env-overridable). No third-party data egress."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent # .../backend
|
|
DATA_DIR = Path(os.environ.get("AR_DATA_DIR", str(BASE_DIR / "data")))
|
|
UPLOAD_DIR = DATA_DIR / "uploads"
|
|
EXPORT_DIR = DATA_DIR / "exports"
|
|
DB_PATH = Path(os.environ.get("AR_DB_PATH", str(DATA_DIR / "ar_aging.db")))
|
|
|
|
# Retention: temp uploads/exports older than this are purged (0 = keep forever).
|
|
RETENTION_DAYS = int(os.environ.get("AR_RETENTION_DAYS", "30"))
|
|
|
|
# Defaults
|
|
DEFAULT_CLEARING_LAG_DAYS = int(os.environ.get("AR_CLEARING_LAG_DAYS", "2"))
|
|
DEFAULT_TOLERANCE = float(os.environ.get("AR_TOLERANCE", "0.01"))
|
|
|
|
MAX_UPLOAD_BYTES = int(os.environ.get("AR_MAX_UPLOAD_BYTES", str(2 * 1024 * 1024 * 1024))) # 2 GB
|
|
ALLOWED_EXTENSIONS = {".xlsx", ".xls", ".csv"}
|
|
|
|
# CORS (frontend dev server)
|
|
CORS_ORIGINS = os.environ.get(
|
|
"AR_CORS_ORIGINS", "http://localhost:5173,http://127.0.0.1:5173"
|
|
).split(",")
|
|
|
|
|
|
def ensure_dirs() -> None:
|
|
for d in (DATA_DIR, UPLOAD_DIR, EXPORT_DIR):
|
|
d.mkdir(parents=True, exist_ok=True)
|