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:
@@ -79,6 +79,11 @@ def _patch_orders_service(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(orders_router.orders_service, "list_orders", fake_list)
|
||||
monkeypatch.setattr(orders_router.orders_service, "delete_order", fake_delete)
|
||||
|
||||
async def fake_cod_in_transit(session: object) -> tuple[int, int]:
|
||||
return 3, 245050
|
||||
|
||||
monkeypatch.setattr(orders_router.orders_service, "cod_in_transit", fake_cod_in_transit)
|
||||
|
||||
async def fake_update(
|
||||
session: object, order_id: str, data: object
|
||||
) -> tuple[Order, list[str]] | None:
|
||||
@@ -238,3 +243,17 @@ class TestUpdateOrder:
|
||||
response = client.patch("/api/v1/orders/1", json={**_UPDATE_BODY, "goods": []})
|
||||
|
||||
assert response.status_code == 422
|
||||
|
||||
|
||||
class TestSummary:
|
||||
@pytest.mark.parametrize("role", [UserRole.ADMIN, UserRole.CASHIER, UserRole.VIEWER])
|
||||
def test_returns_cod_in_transit(self, client: TestClient, role: UserRole) -> None:
|
||||
app.dependency_overrides[get_current_user] = lambda: _user(role)
|
||||
|
||||
response = client.get("/api/v1/orders/summary")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"cod_in_transit_count": 3,
|
||||
"cod_in_transit_amount": "2450.50",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user