36 lines
1.2 KiB
Python
36 lines
1.2 KiB
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 can_withdraw_receipt(pay_status: Optional[str]) -> bool:
|
|
"""仅付款确认中可撤回为已付款。"""
|
|
return (pay_status or "").strip() == "jfqrz"
|
|
|
|
|
|
def can_edit_transfer(pay_status: Optional[str]) -> bool:
|
|
"""财务确认收款(yjf)前可编辑:已付款 / 付款确认中。"""
|
|
return (pay_status or "").strip() in ("dfj", "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
|