Add Nova Poshta tracking: TTN status, COD amount, payment status
Adds NpTrackingClient (Protocol + real/stub impls) and an ARQ worker that polls Nova Poshta every minute for orders without a receipt, writing status, net COD amount (Контроль оплати), and payment status onto the order. Surfaced in the orders table and detail modal. Marks plan stages 3-4 done in README. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Фикстурный клиент Nova Poshta для тестов — не ходит в сеть."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.schemas.tracking import TrackingStatusOut
|
||||
|
||||
_FIXTURE_STATUSES: dict[str, dict] = {
|
||||
"20450123456789": {
|
||||
"Number": "20450123456789",
|
||||
"Status": "Відправлення отримано",
|
||||
"StatusCode": "9",
|
||||
"PaymentMethod": "Cash",
|
||||
"ScheduledDeliveryDate": "22-09-2026 18:00:00",
|
||||
"ActualDeliveryDate": "22-09-2026 15:30:00",
|
||||
"AmountToPay": "1200.00",
|
||||
"AfterpaymentOnGoodsCost": 1200,
|
||||
"PaymentStatus": "Paid",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class StubNovaPoshtaClient:
|
||||
def __init__(self, statuses: dict[str, dict] | None = None) -> None:
|
||||
self._statuses = statuses if statuses is not None else _FIXTURE_STATUSES
|
||||
|
||||
async def get_statuses(self, *, waybill_numbers: list[str]) -> list[TrackingStatusOut]:
|
||||
return [
|
||||
TrackingStatusOut.model_validate(self._statuses[number])
|
||||
for number in waybill_numbers
|
||||
if number in self._statuses
|
||||
]
|
||||
Reference in New Issue
Block a user