feat(pl): 增加百链充值类型,并保留计划产品与证件上传时间。
充值单号按类型使用 ETC、YK、SX、BL 前缀;更换装货客户清空产品时不抹掉已有计划产品;运输证件列表展示上传时间。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
af8d4d90fa
commit
cc5cf78bcd
21 files changed
+274
-97
No files matched your search
@@ -110,7 +110,45 @@ def _patch_scope(monkeypatch, *modules) -> None:
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia"])
|
||||
@pytest.mark.parametrize(
|
||||
"recharge_type,prefix",
|
||||
[("etc", "ETC"), ("fuel", "YK"), ("shanxia", "SX"), ("bailian", "BL")],
|
||||
)
|
||||
def test_apply_no_prefix_follows_recharge_type(recharge_type, prefix):
|
||||
from app.services.pl_vehicle_recharge_service import generate_apply_no
|
||||
|
||||
db = _make_session()
|
||||
day = date.today().strftime("%Y%m%d")
|
||||
assert generate_apply_no(db, recharge_type) == f"{prefix}{day}01"
|
||||
|
||||
|
||||
def test_apply_no_sequences_are_independent_per_type():
|
||||
from app.services.pl_vehicle_recharge_service import generate_apply_no
|
||||
|
||||
db = _make_session()
|
||||
day = date.today().strftime("%Y%m%d")
|
||||
db.add(
|
||||
PlVehicleRechargeApply(
|
||||
id="apply-etc-1",
|
||||
apply_no=f"ETC{day}01",
|
||||
license_plate="鄂A00001",
|
||||
recharge_type="etc",
|
||||
apply_date=date.today(),
|
||||
applicant_id="u-applicant",
|
||||
status="draft",
|
||||
tenant_no="t1",
|
||||
create_dept_id="d1",
|
||||
)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
assert generate_apply_no(db, "etc") == f"ETC{day}02"
|
||||
assert generate_apply_no(db, "fuel") == f"YK{day}01"
|
||||
assert generate_apply_no(db, "shanxia") == f"SX{day}01"
|
||||
assert generate_apply_no(db, "bailian") == f"BL{day}01"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia", "bailian"])
|
||||
def test_submit_sets_in_approval_and_first_node(monkeypatch, recharge_type):
|
||||
from app.services import pl_vehicle_recharge_service as svc
|
||||
from app.schemas.pl.vehicle_recharge import VehicleRechargeApplyCreate
|
||||
@@ -136,6 +174,8 @@ def test_submit_sets_in_approval_and_first_node(monkeypatch, recharge_type):
|
||||
),
|
||||
)
|
||||
assert created.recharge_type == recharge_type
|
||||
prefix = {"etc": "ETC", "fuel": "YK", "shanxia": "SX", "bailian": "BL"}[recharge_type]
|
||||
assert created.apply_no.startswith(f"{prefix}{date.today():%Y%m%d}")
|
||||
assert created.status == "draft"
|
||||
assert created.approval_round == 0
|
||||
|
||||
@@ -280,7 +320,7 @@ def test_reject_sets_rejected_and_appends_history(monkeypatch):
|
||||
assert result.approvals[-1].approval_status == "rejected"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia"])
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia", "bailian"])
|
||||
def test_disburse_writes_record_and_disbursed(monkeypatch, recharge_type):
|
||||
from app.services import pl_vehicle_recharge_approval_service as approval_svc
|
||||
from app.services import pl_vehicle_recharge_service as svc
|
||||
|
||||
@@ -14,11 +14,11 @@ from app.schemas.pl.vehicle_recharge import (
|
||||
|
||||
|
||||
def test_recharge_types_include_all_supported_types():
|
||||
assert RECHARGE_TYPES == {"etc", "fuel", "shanxia"}
|
||||
assert RECHARGE_TYPES == {"etc", "fuel", "shanxia", "bailian"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("schema", [VehicleRechargeApplyCreate, VehicleRechargeApplyUpdate])
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia"])
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia", "bailian"])
|
||||
def test_apply_accepts_supported_types(schema, recharge_type):
|
||||
obj = schema.model_validate({
|
||||
"licensePlate": "鄂A12345",
|
||||
@@ -50,7 +50,7 @@ def test_recharge_rejects_unknown_type(schema):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("schema", [VehicleRechargeRecordCreate, VehicleRechargeRecordUpdate])
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia"])
|
||||
@pytest.mark.parametrize("recharge_type", ["etc", "fuel", "shanxia", "bailian"])
|
||||
def test_record_accepts_supported_types(schema, recharge_type):
|
||||
obj = schema.model_validate({
|
||||
"rechargeDate": "2026-10-25",
|
||||
@@ -62,7 +62,7 @@ def test_record_accepts_supported_types(schema, recharge_type):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("recharge_type,label", [
|
||||
("etc", "ETC"), ("fuel", "油卡"), ("shanxia", "山峡"),
|
||||
("etc", "ETC"), ("fuel", "油卡"), ("shanxia", "山峡"), ("bailian", "百链"),
|
||||
])
|
||||
def test_export_recharge_type_labels(recharge_type, label):
|
||||
from app.api.pl.vehicle_recharge import RECHARGE_TYPE_LABELS
|
||||
|
||||
Reference in new issue
Block a user