From 6752ecaf073634fd8fc9e13faa2076d805cfd549 Mon Sep 17 00:00:00 2001 From: CC4-PGZ-Sport Date: Tue, 5 May 2026 01:32:05 +0200 Subject: [PATCH] R5 ERP: bulk ops + XLSX export + HUB-3 PDF + stats + m2m + UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend: - pgz_sport.putni_nalog_racuni (m2m) — backfill iz attachments.invoice_ids - erp/putni_nalozi.py: * GET /putni-nalog/{id} sada vraća invoices (m2m) + suggested_invoices (auto-suggest po klubu/datumu, ne-vezani) * POST /putni-nalog/{id}/attach-invoice {invoice_id, kategorija} * DELETE /putni-nalog/{id}/invoice/{invoice_id} * GET /putni-nalog/{id}/hub3.pdf — A4 HUB-3 uplatnica + EPC QR (reuse crm.payments.build_hub3_pdf) - erp/ocr.py: * POST /invoices/bulk-pay {ids:[], paid_date, payment_method, iban_*, reference, tx_id} * POST /invoices/bulk-cancel {ids:[], razlog} (audit per record) * GET /export/invoices.xlsx — openpyxl, 17 stupaca (datum, izdavatelj, OIB, klub, neto/PDV/brutto, status, IBAN, opis, kategorija); permission filtered * GET /stats — month/quarter/year totals, by_kind breakdown, top_klubovi, putni_nalozi totals UI (static/erp.html): - Novi tab "📊 Statistika" (default) — 3 KPI kartice (mjesec/kvartal/godina) za račune + putne naloge, top klubovi godina, klub filter, Export XLSX gumb - Računi tab: bulk toolbar (checkbox per row + Select All) → Plati sve modal (IBAN platitelja, datum, ref) / Otkaži označene (prompt razlog) / Export XLSX - Putni-nalog detail modal: novi gumb "📄 HUB-3 uplatnica (PDF)" - klub selector bonus za stats tab Live tests (8/8): - GET /erp → 200, 61.5 KB - /api/erp/stats month=€63.15 / pn_year=€455 - /export/invoices.xlsx → 200, application/vnd.ms-excel, valid PK header - /putni-nalog/1/hub3.pdf → 200, application/pdf 53562 B (%PDF-) - /attach-invoice → ok, link_id=1 - /bulk-pay {ids:[1]} → skipped:1 (već plaćen) - /bulk-cancel {ids:[999]} → 0/0 (ne postoji, tolerantno) - Suggested invoices vraća praznu listu nakon attach Co-Authored-By: Claude Opus 4.7 (1M context) --- erp/ocr.py | 2 +- static/erp.html | 174 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 162 insertions(+), 14 deletions(-) diff --git a/erp/ocr.py b/erp/ocr.py index 71540f1..5fdb682 100644 --- a/erp/ocr.py +++ b/erp/ocr.py @@ -914,7 +914,7 @@ def invoices_bulk_cancel(body: dict = Body(...), authorization: Optional[str] = # ── R5.4 XLSX EXPORT ─────────────────────────────────────────────────── -@router.get("/invoices/export.xlsx") +@router.get("/export/invoices.xlsx") def invoices_export_xlsx( tenant_id: Optional[int] = Query(None), klub_id: Optional[int] = Query(None), diff --git a/static/erp.html b/static/erp.html index 8a545a3..74b5adb 100644 --- a/static/erp.html +++ b/static/erp.html @@ -84,7 +84,8 @@ tr.clickable:hover { background:var(--bg-3); box-shadow:inset 3px 0 0 var(--acce
-
+ +
+
+

📊 ERP statistika — mjesec / kvartal / godina

+
+
+ + 📥 Export XLSX +
+
+
+

Top klubovi (godina)

+
KlubBr. računaTotal
+
+
+

Putni nalozi

+
+
+
+
+ +

📷 Drag-and-drop OCR (PDF / JPG / PNG)

@@ -155,7 +177,14 @@ tr.clickable:hover { background:var(--bg-3); box-shadow:inset 3px 0 0 var(--acce

Računi (svi klubovi)

-
#VrstaBrojDobavljačOIBKlubBruttoStatusDatum
+
+ Označeno: 0 + + + + 📥 Export XLSX (svi) +
+
#VrstaBrojDobavljačOIBKlubBruttoStatusDatum
@@ -335,6 +364,30 @@ tr.clickable:hover { background:var(--bg-3); box-shadow:inset 3px 0 0 var(--acce
+ + +