提交
This commit is contained in:
1 parent
afd517ce10
commit
eec61cb5dd
82 files changed
+16585
-9026
No files matched your search
@@ -0,0 +1,44 @@
|
||||
"""分期应缴日:小数月间隔(30 天/月)与提前 10 天规则"""
|
||||
|
||||
import unittest
|
||||
|
||||
from app.services.protocol_payment_installment import calc_fq_installment_due_date
|
||||
|
||||
|
||||
class TestCalcFqInstallmentDueDate(unittest.TestCase):
|
||||
def test_first_period_equals_start_date(self):
|
||||
self.assertEqual(calc_fq_installment_due_date("20260604", 0, 0.5), "20260604")
|
||||
|
||||
def test_fractional_interval_half_month_six_periods(self):
|
||||
start = "20260604"
|
||||
interval = 0.5
|
||||
expected = [
|
||||
"20260604",
|
||||
"20260609",
|
||||
"20260624",
|
||||
"20260709",
|
||||
"20260725",
|
||||
"20260809",
|
||||
]
|
||||
for i, exp in enumerate(expected):
|
||||
self.assertEqual(
|
||||
calc_fq_installment_due_date(start, i, interval),
|
||||
exp,
|
||||
msg=f"period {i + 1}",
|
||||
)
|
||||
|
||||
def test_fractional_interval_0_1_advance_10_days(self):
|
||||
# +3 天 = 20260607,再提前 10 天
|
||||
self.assertEqual(calc_fq_installment_due_date("20260604", 1, 0.1), "20260528")
|
||||
|
||||
def test_integer_interval_six_months(self):
|
||||
# +6 日历月 = 20261204,再提前 10 天
|
||||
self.assertEqual(calc_fq_installment_due_date("20260604", 1, 6), "20261124")
|
||||
|
||||
def test_fractional_interval_0_3(self):
|
||||
# index=2 → 0.6 月 → 18 天 → 20260622,再提前 10 天
|
||||
self.assertEqual(calc_fq_installment_due_date("20260604", 2, 0.3), "20260612")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user