26 lines
861 B
Python
26 lines
861 B
Python
"""转账笔缴费状态规则(正式样本缴费 / 预签约意向金共用)"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from decimal import Decimal
|
|
from typing import Iterable, Optional, Tuple, Union
|
|
|
|
|
|
def can_submit_receipt(pay_status: Optional[str]) -> bool:
|
|
return (pay_status or "").strip() == "dfj"
|
|
|
|
|
|
def can_confirm_receipt(pay_status: Optional[str]) -> bool:
|
|
return (pay_status or "").strip() == "jfqrz"
|
|
|
|
|
|
def schedule_paid_and_arrears(
|
|
*,
|
|
due: Union[Decimal, float, int, str, None],
|
|
confirmed_transfers: Iterable[Union[Decimal, float, int, str, None]],
|
|
) -> Tuple[Decimal, Decimal]:
|
|
"""已缴 = Σ 已确认转账;欠缴 = 应缴 − 已缴(可为负表示超缴)。"""
|
|
due_amt = Decimal(str(due or 0))
|
|
paid = sum((Decimal(str(x or 0)) for x in confirmed_transfers), Decimal("0"))
|
|
return paid, due_amt - paid
|