19 lines
483 B
Python
19 lines
483 B
Python
"""协议级退费登记金额校验"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from decimal import Decimal
|
|
from typing import Any
|
|
|
|
|
|
def validate_refund_amount(amount: Any) -> Decimal:
|
|
if amount is None or amount == "":
|
|
raise ValueError("请填写退费金额")
|
|
try:
|
|
dec = Decimal(str(amount))
|
|
except Exception as e:
|
|
raise ValueError("退费金额无效") from e
|
|
if dec <= 0:
|
|
raise ValueError("退费金额必须大于 0")
|
|
return dec
|