Align displayPaidAmount/arrears with business rule: 已缴费 excludes 已付款 and 付款确认中 transfers. Co-authored-by: Cursor <cursoragent@cursor.com>
95 lines
3.3 KiB
Python
95 lines
3.3 KiB
Python
"""单期展示摘要:已缴合计、首笔日期、欠缴、方式、财务审核码"""
|
|
|
|
from decimal import Decimal
|
|
import unittest
|
|
|
|
from app.services.sample_payment_period_summary import summarize_period
|
|
|
|
|
|
class TestPeriodSummary(unittest.TestCase):
|
|
def test_empty_transfers(self):
|
|
r = summarize_period(
|
|
due_amount=Decimal("1000"),
|
|
transfers=[],
|
|
)
|
|
self.assertEqual(r["displayPaidAmount"], Decimal("0"))
|
|
self.assertEqual(r["arrearsAmount"], Decimal("1000"))
|
|
self.assertEqual(r["payDate"], "")
|
|
self.assertEqual(r["payTypeSummary"], "")
|
|
self.assertEqual(r["financeAudit"], "dfj")
|
|
|
|
def test_dfj_does_not_count_as_display_paid(self):
|
|
r = summarize_period(
|
|
due_amount=Decimal("1000"),
|
|
transfers=[
|
|
{
|
|
"transferAmount": Decimal("400"),
|
|
"transferType": "wxzz",
|
|
"transferTime": "2026-04-19 10:00:00",
|
|
"payStatus": "dfj",
|
|
}
|
|
],
|
|
)
|
|
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):
|
|
r = summarize_period(
|
|
due_amount=Decimal("5000"),
|
|
transfers=[
|
|
{
|
|
"transferAmount": Decimal("3000"),
|
|
"transferType": "wxzz",
|
|
"transferTime": "2026-04-19 10:11:00",
|
|
"payStatus": "yjf",
|
|
},
|
|
{
|
|
"transferAmount": Decimal("2000"),
|
|
"transferType": "yhkzz",
|
|
"transferTime": "2026-04-20 09:40:00",
|
|
"payStatus": "yjf",
|
|
},
|
|
],
|
|
)
|
|
self.assertEqual(r["displayPaidAmount"], Decimal("5000"))
|
|
self.assertEqual(r["payDate"], "2026-04-19")
|
|
self.assertEqual(r["arrearsAmount"], Decimal("0"))
|
|
self.assertEqual(r["payTypeSummary"], "多笔")
|
|
self.assertEqual(r["financeAudit"], "yjf")
|
|
|
|
def test_pay_date_is_first_transfer_not_latest(self):
|
|
r = summarize_period(
|
|
due_amount=Decimal("5000"),
|
|
transfers=[
|
|
{
|
|
"transferAmount": Decimal("3000"),
|
|
"transferType": "wxzz",
|
|
"transferTime": "2026-04-19 10:11:00",
|
|
"payStatus": "yjf",
|
|
},
|
|
{
|
|
"transferAmount": Decimal("2000"),
|
|
"transferType": "yhkzz",
|
|
"transferTime": "2026-04-20 09:40:00",
|
|
"payStatus": "yjf",
|
|
},
|
|
],
|
|
)
|
|
self.assertEqual(r["payDate"], "2026-04-19")
|
|
|
|
def test_confirming_wins(self):
|
|
r = summarize_period(
|
|
due_amount=Decimal("4960"),
|
|
transfers=[
|
|
{
|
|
"transferAmount": Decimal("2000"),
|
|
"transferType": "pos",
|
|
"transferTime": "2026-06-18 15:20:00",
|
|
"payStatus": "jfqrz",
|
|
}
|
|
],
|
|
)
|
|
self.assertEqual(r["displayPaidAmount"], Decimal("0"))
|
|
self.assertEqual(r["financeAudit"], "jfqrz")
|