取消承运商营业执照/许可证/运输协议的必填校验,附件组件支持拖拽与区域粘贴上传,并同步知识图谱。 Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
"""运输计划 - 承运商资质与运输资格"""
|
|
from __future__ import annotations
|
|
|
|
from datetime import date
|
|
from typing import Optional
|
|
|
|
from app.models.pl_models import PlCarrier
|
|
|
|
|
|
def _urls_nonempty(value: Optional[str]) -> bool:
|
|
return bool(value and str(value).strip())
|
|
|
|
|
|
def carrier_qualification_complete(carrier: PlCarrier) -> bool:
|
|
return (
|
|
_urls_nonempty(carrier.business_license_urls)
|
|
and _urls_nonempty(carrier.road_transport_license_urls)
|
|
and _urls_nonempty(carrier.transport_agreement_urls)
|
|
)
|
|
|
|
|
|
def carrier_agreement_expired(carrier: PlCarrier, today: Optional[date] = None) -> bool:
|
|
if not carrier_qualification_complete(carrier):
|
|
return False
|
|
ref = today or date.today()
|
|
expire = carrier.transport_agreement_expire_date
|
|
return expire is not None and expire < ref
|
|
|
|
|
|
def carrier_audit_approved(carrier: PlCarrier) -> bool:
|
|
return getattr(carrier, "audit_status", None) == "approved"
|
|
|
|
|
|
def carrier_eligible_for_transport(carrier: PlCarrier, today: Optional[date] = None) -> bool:
|
|
return True
|
|
|
|
|
|
def assert_carrier_eligible_for_transport(
|
|
carrier: PlCarrier,
|
|
*,
|
|
rearrange: bool = False,
|
|
) -> None:
|
|
return
|
|
|
|
|
|
def normalize_carrier_urls(value: Optional[str]) -> Optional[str]:
|
|
if value is None:
|
|
return None
|
|
trimmed = str(value).strip()
|
|
return trimmed or None
|
|
|
|
|
|
def validate_carrier_qualification_fields(
|
|
*,
|
|
business_license_urls: Optional[str],
|
|
road_transport_license_urls: Optional[str],
|
|
transport_agreement_urls: Optional[str],
|
|
transport_agreement_expire_date: Optional[date],
|
|
require_all: bool,
|
|
) -> None:
|
|
"""资质附件均为选填,保留函数签名供兼容调用。"""
|
|
return
|