feat: wire contract PDF context and align MechanicAuto with AutoEvaluation

- contract PDF: map report/customer/owner/contract from AutoEvaluationModel
  fields, accept inspection via POST serializer, fetch CBU.uz currency rates
- MechanicAutoEvaluation: add distance_covered, object_owner_residence and
  car_position/body_type/fuel_type/state_car/assessment_task_type FKs; drop
  car_type and single tex_passport_file in favour of multi-file FK model

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xoliqberdiyev
2026-05-05 18:51:24 +05:00
parent 25e92623fd
commit 80a1f5ff17
10 changed files with 560 additions and 164 deletions

View File

@@ -0,0 +1,33 @@
from datetime import date
import requests
CBU_URL = "https://cbu.uz/oz/arkhiv-kursov-valyut/json/{code}/{date}/"
TIMEOUT_SECONDS = 5
CURRENCY_CODES = ("USD", "EUR", "RUB")
def fetch_rates(target_date):
"""CBU.uz dan berilgan sanaga oid USD, EUR, RUB kurslarini olish.
Tarmoq xatosi yoki notogri javob bolsa bosh dict qaytadi.
"""
if target_date is None:
target_date = date.today()
date_str = target_date.strftime("%Y-%m-%d")
rates = {}
for code in CURRENCY_CODES:
try:
resp = requests.get(
CBU_URL.format(code=code, date=date_str),
timeout=TIMEOUT_SECONDS,
)
resp.raise_for_status()
data = resp.json()
if isinstance(data, list) and data:
rate_value = data[0].get("Rate")
if rate_value:
rates[code] = rate_value
except (requests.RequestException, ValueError):
continue
return rates