feat: UI/UX cleanup V1 with header, import requisites, and status fixes

This commit is contained in:
Арсентьев Александр
2026-09-27 20:22:13 +03:00
parent 79d802d536
commit 94571f9684
31 changed files with 2842 additions and 73 deletions
+24 -4
View File
@@ -161,13 +161,32 @@ def preview_excel_data(file_path: str, sheet_name: str, header_row: int, start_r
return parsed
def import_excel_data(db: Session, file_path: str, sheet_name: str, header_row: int, start_row: int, project_id: int) -> Dict[str, Any]:
def import_excel_data(
db: Session,
file_path: str,
sheet_name: str,
header_row: int,
start_row: int,
project_id: int,
document_name: Optional[str] = None,
document_number: Optional[str] = None,
document_date: Optional[Any] = None,
contract: Optional[str] = None,
) -> Dict[str, Any]:
parsed = parse_excel_data(file_path, sheet_name, header_row, start_row)
if parsed["errors"]:
raise ValueError("\n".join(parsed["errors"]))
name = (document_name or "").strip() or f"Импорт ведомости — {sheet_name}"
try:
doc = boq.BoqDocument(project_id=project_id, name=f"Импорт ведомости — {sheet_name}",
source_file=Path(file_path).name, version="1.0")
doc = boq.BoqDocument(
project_id=project_id,
name=name,
source_file=Path(file_path).name,
version="1.0",
document_number=(document_number or "").strip() or None,
document_date=document_date,
contract=(contract or "").strip() or None,
)
db.add(doc)
db.flush()
systems: Dict[str, boq.System] = {}
@@ -202,7 +221,8 @@ def import_excel_data(db: Session, file_path: str, sheet_name: str, header_row:
).scalar()
db_total_display = Decimal(str(db_total or 0)).quantize(Decimal("0.01"))
excel_total_display = parsed["excel_total"].quantize(Decimal("0.01"))
return {"status": "success", "document_id": doc.id, "systems": len(systems), "sections": len(sections),
return {"status": "success", "document_id": doc.id, "document_name": doc.display_name,
"systems": len(systems), "sections": len(sections),
"work_items": parsed["work_items_count"], "total_amount": db_total_display,
"db_total": db_total_display, "excel_total": excel_total_display,
"difference": db_total_display - excel_total_display}