bmc_hub/app/modules/invoice_error_finder/frontend/views.py
Christian 128a2b83d0 feat(invoice_error_finder): add invoice error finder module
- Detect missing invoice lines, open orders not invoiced, quantity drops, price changes
- Import e-conomic invoices and Simply CRM sales orders
- Dashboard and issues UI with sag/ordre-draft actions
- Scheduled daily sync job at 05:00
- Add invoice_error_finder permissions
2026-07-10 07:08:49 +02:00

61 lines
1.4 KiB
Python

"""
Invoice Error Finder frontend views.
"""
import logging
from typing import Any, Dict
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from app.core.database import execute_query
logger = logging.getLogger(__name__)
router = APIRouter()
templates = Jinja2Templates(directory="app")
def _fetch_assignment_users() -> list:
return execute_query(
"""
SELECT user_id, COALESCE(full_name, username) AS display_name
FROM users
ORDER BY display_name
""",
(),
) or []
def _fetch_customers() -> list:
return execute_query(
"""
SELECT id, name
FROM customers
WHERE deleted_at IS NULL
ORDER BY name
""",
(),
) or []
@router.get("/invoice-error-finder", response_class=HTMLResponse)
async def dashboard(request: Request):
return templates.TemplateResponse(
"modules/invoice_error_finder/templates/dashboard.html",
{
"request": request,
},
)
@router.get("/invoice-error-finder/issues", response_class=HTMLResponse)
async def issues_list(request: Request):
return templates.TemplateResponse(
"modules/invoice_error_finder/templates/issues.html",
{
"request": request,
"users": _fetch_assignment_users(),
"customers": _fetch_customers(),
},
)