Add COD-in-transit summary and received tab to the dashboard

- GET /orders/summary: count and sum of cash-on-delivery for parcels not
  yet picked up (excludes received, refused, deleted/unknown TTNs, paid COD);
  shown as a card above the tabs.
- New «Полученные» tab: orders with NP received codes (9, 10, 11, 106) move
  there automatically, regardless of receipt; 106 is now a final status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 01:23:39 +03:00
co-authored by Claude Opus 5.5
parent 528a869657
commit a6072800b2
11 changed files with 202 additions and 19 deletions
+9 -1
View File
@@ -6,7 +6,7 @@ from fastapi import APIRouter, Depends, HTTPException, Request, status
from app.api.deps import CashierUser, CrmClientDep, SessionDep, require_any
from app.db.models.audit import AuditAction
from app.schemas.orders import OrderRowOut, OrderUpdateIn
from app.schemas.orders import OrderRowOut, OrdersSummaryOut, OrderUpdateIn
from app.services import audit
from app.services import orders as orders_service
from app.services import receipts as receipts_service
@@ -29,6 +29,14 @@ async def list_orders(
return [OrderRowOut.from_order(order, receipts.get(order.id)) for order in orders]
@router.get("/summary", response_model=OrdersSummaryOut)
async def orders_summary(session: SessionDep) -> OrdersSummaryOut:
count, kopecks = await orders_service.cod_in_transit(session)
return OrdersSummaryOut(
cod_in_transit_count=count, cod_in_transit_amount=f"{kopecks / 100:.2f}"
)
@router.patch("/{order_id}", response_model=OrderRowOut, response_model_by_alias=False)
async def update_order(
order_id: str,