fix(backend): count period paid amount as yjf only
Align displayPaidAmount/arrears with business rule: 已缴费 excludes 已付款 and 付款确认中 transfers. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a1be31c694
commit
b8b20dcebe
4 files changed
+15
-19
No files matched your search
@@ -20,11 +20,7 @@ def chase_period_money(
|
||||
due_amount: Any,
|
||||
transfers: Iterable[Mapping[str, Any]],
|
||||
) -> Tuple[Decimal, Decimal]:
|
||||
"""
|
||||
与缴费信息期次口径一致:
|
||||
已缴 = dfj + jfqrz + yjf;欠缴 = max(应缴 − 已缴, 0)。
|
||||
返回 (paidAmount, arrearsAmount)。
|
||||
"""
|
||||
"""已缴 = 仅 yjf;欠缴 = max(应缴 − 已缴, 0)。"""
|
||||
summary: Dict[str, Any] = summarize_period(
|
||||
due_amount=due_amount, transfers=transfers
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ def _status(row: Mapping[str, Any], *keys: str) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
_DISPLAY_PAID_STATUSES = ("dfj", "jfqrz", "yjf")
|
||||
_DISPLAY_PAID_STATUSES = ("yjf",)
|
||||
|
||||
|
||||
def summarize_period(
|
||||
@@ -26,7 +26,7 @@ def summarize_period(
|
||||
transfers: Iterable[Mapping[str, Any]],
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
displayPaidAmount: dfj + jfqrz + yjf 合计(列表「已缴费金额」)
|
||||
displayPaidAmount: 已缴费金额仅计付款完成(yjf)
|
||||
arrearsAmount: max(due - displayPaidAmount, 0)
|
||||
financeAudit: jfqrz > (confirmed>=due 且无确认中 → yjf) > (0<confirmed → partial) > dfj
|
||||
payDate: 首笔 transferTime 的日期部分(调用方应按 create_time ASC 传入)
|
||||
|
||||
@@ -12,8 +12,8 @@ from app.services.payment_chase import (
|
||||
|
||||
|
||||
class TestChase(unittest.TestCase):
|
||||
def test_chase_paid_includes_dfj_jfqrz_yjf(self):
|
||||
"""与缴费信息期次一致:已缴 = dfj + jfqrz + yjf"""
|
||||
def test_chase_paid_only_counts_yjf(self):
|
||||
"""已缴 = 仅 yjf;欠缴 = 应缴 − 已缴"""
|
||||
paid, arrears = chase_period_money(
|
||||
due_amount=Decimal("1000"),
|
||||
transfers=[
|
||||
@@ -34,10 +34,10 @@ class TestChase(unittest.TestCase):
|
||||
},
|
||||
],
|
||||
)
|
||||
self.assertEqual(paid, Decimal("600"))
|
||||
self.assertEqual(arrears, Decimal("400"))
|
||||
self.assertEqual(paid, Decimal("100"))
|
||||
self.assertEqual(arrears, Decimal("900"))
|
||||
|
||||
def test_chase_full_display_paid_not_candidate(self):
|
||||
def test_chase_dfj_only_still_has_arrears(self):
|
||||
paid, arrears = chase_period_money(
|
||||
due_amount=Decimal("500"),
|
||||
transfers=[
|
||||
@@ -48,9 +48,9 @@ class TestChase(unittest.TestCase):
|
||||
}
|
||||
],
|
||||
)
|
||||
self.assertEqual(paid, Decimal("500"))
|
||||
self.assertEqual(arrears, Decimal("0"))
|
||||
self.assertFalse(
|
||||
self.assertEqual(paid, Decimal("0"))
|
||||
self.assertEqual(arrears, Decimal("500"))
|
||||
self.assertTrue(
|
||||
is_chase_candidate(
|
||||
due_date=date(2026, 9, 1),
|
||||
today=date(2026, 10, 9),
|
||||
|
||||
@@ -18,7 +18,7 @@ class TestPeriodSummary(unittest.TestCase):
|
||||
self.assertEqual(r["payTypeSummary"], "")
|
||||
self.assertEqual(r["financeAudit"], "dfj")
|
||||
|
||||
def test_dfj_counts_as_display_paid(self):
|
||||
def test_dfj_does_not_count_as_display_paid(self):
|
||||
r = summarize_period(
|
||||
due_amount=Decimal("1000"),
|
||||
transfers=[
|
||||
@@ -30,8 +30,8 @@ class TestPeriodSummary(unittest.TestCase):
|
||||
}
|
||||
],
|
||||
)
|
||||
self.assertEqual(r["displayPaidAmount"], Decimal("400"))
|
||||
self.assertEqual(r["arrearsAmount"], Decimal("600"))
|
||||
self.assertEqual(r["displayPaidAmount"], Decimal("0"))
|
||||
self.assertEqual(r["arrearsAmount"], Decimal("1000"))
|
||||
self.assertEqual(r["payDate"], "2026-04-19")
|
||||
|
||||
def test_multi_transfer_summary(self):
|
||||
@@ -90,5 +90,5 @@ class TestPeriodSummary(unittest.TestCase):
|
||||
}
|
||||
],
|
||||
)
|
||||
self.assertEqual(r["displayPaidAmount"], Decimal("2000"))
|
||||
self.assertEqual(r["displayPaidAmount"], Decimal("0"))
|
||||
self.assertEqual(r["financeAudit"], "jfqrz")
|
||||
Reference in new issue
Block a user