Files
bin/finance/tests/test_projection.py
wlfb 877cba4964 test: Absolute-Modifier und Stichtag-Semantik der Projektion
Ergänzte Tests für Lückenschluss:
1. test_absolute_modifier_reduces_outflow: Absolute Modifier reduziert Ausgaben (-200 - 50 = -150)
2. test_absolute_modifier_clamps_to_zero: Absolute Modifier klemmt auf 0 (nie Vorzeichenflip: -200 + 300 = 0)
3. test_cashflow_on_start_date_excluded: Cashflows am start_date werden ausgeschlossen (Teil des Startsaldos)

Alle 18 Tests grün (15 existierend + 3 neu).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 17:27:41 +02:00

31 lines
1.2 KiB
Python

from datetime import date
from decimal import Decimal
from app.engine.projection import project
def test_low_point_and_threshold():
flows = [(date(2026, 8, 1), Decimal("-150")), (date(2026, 8, 10), Decimal("200"))]
p = project(Decimal("100"), date(2026, 7, 31), flows, horizon_days=15,
threshold=Decimal("60"))
assert p.low_point == (date(2026, 8, 1), Decimal("-50"))
assert p.first_below_zero == date(2026, 8, 1)
assert p.first_below_threshold == date(2026, 8, 1)
assert p.series[-1][1] == Decimal("150")
def test_no_crossing():
p = project(Decimal("100"), date(2026, 7, 31), [], horizon_days=5)
assert p.first_below_zero is None
assert p.low_point[1] == Decimal("100")
def test_cashflow_on_start_date_excluded():
"""Cashflows dated exactly on start_date are excluded (part of starting balance)"""
p = project(Decimal("100"), date(2026, 8, 1), [(date(2026, 8, 1), Decimal("-999"))],
horizon_days=5)
# All balances remain 100 because the -999 flow on start_date is ignored
assert all(bal == Decimal("100") for _, bal in p.series)
assert p.first_below_zero is None
assert p.low_point[1] == Decimal("100")