|
|
@@ -39,3 +39,15 @@ def test_release_idempotent_guard():
|
|
|
assert should_skip_release(has_debit=True, has_release=True) is True
|
|
|
assert should_skip_release(has_debit=True, has_release=False) is False
|
|
|
assert should_skip_release(has_debit=False, has_release=False) is True
|
|
|
+
|
|
|
+
|
|
|
+def test_summarize_allows_negative_balance():
|
|
|
+ """提交占用可超过已上传总额,余额可为负(补票后再回升)。"""
|
|
|
+ rows = [
|
|
|
+ {"entry_type": ENTRY_CREDIT_UPLOAD, "amount": Decimal("100")},
|
|
|
+ {"entry_type": ENTRY_DEBIT_REIMBURSE, "amount": Decimal("300")},
|
|
|
+ ]
|
|
|
+ s = summarize_entries(rows)
|
|
|
+ assert s["total_amount"] == Decimal("100")
|
|
|
+ assert s["used_amount"] == Decimal("300")
|
|
|
+ assert s["balance"] == Decimal("-200")
|