feat(reports): stabilize on-demand generation, live presence and 1C fallback

This commit is contained in:
2026-09-25 13:00:11 +03:00
parent 2f8cc1bffd
commit 90656944c5
42 changed files with 13410 additions and 6778 deletions
+22 -14
View File
@@ -176,23 +176,31 @@ def delete_manual_absence(item_id: int) -> bool:
def get_manual_absences_list(absence_type: Optional[str] = None) -> List[Dict[str, Any]]:
init_manual_absences_table()
today_str = datetime.now().strftime("%Y-%m-%d")
# ⭐️ Обязательно row_factory=True для преобразования строк SQLite в dict
with get_connection(row_factory=True) as conn:
cursor = conn.cursor()
# 1. Автоочистка просроченных командировок и отсутствий
cursor.execute("""
DELETE FROM manual_absences
WHERE date_end IS NOT NULL
AND date_end != ''
AND date_end < ?
""", (today_str,))
conn.commit()
# 2. Выборка активных записей
query = "SELECT id, absence_type, fio, department, position, reason, date_start, date_end, comment FROM manual_absences"
params = []
if absence_type:
cursor.execute("""
SELECT id, absence_type, fio, fio_clean, department, position, date_start, date_end, reason, comment, created_at
FROM manual_absences
WHERE absence_type = ?
ORDER BY id DESC
""", (absence_type.upper(),))
else:
cursor.execute("""
SELECT id, absence_type, fio, fio_clean, department, position, date_start, date_end, reason, comment, created_at
FROM manual_absences
ORDER BY id DESC
""")
return [dict(r) for r in cursor.fetchall()]
query += " WHERE absence_type = ?"
params.append(absence_type)
query += " ORDER BY id DESC"
cursor.execute(query, params)
rows = cursor.fetchall()
return [dict(r) for r in rows]
def get_active_manual_absences_for_date(date_str: str) -> List[Dict[str, Any]]: