fix: align total costs with visible budgets
This commit is contained in:
@@ -180,3 +180,18 @@ def test_personal_account_names_fill_with_admin_if_only_one_editor_is_active(app
|
||||
|
||||
assert personal_labels["persoenlich-flo"] == "Person A"
|
||||
assert personal_labels["persoenlich-desi"] == "Admin"
|
||||
|
||||
|
||||
def test_compute_summary_ignores_inactive_budget_entries(app):
|
||||
service = app.extensions["saldo.month_service"]
|
||||
month = Month.query.filter_by(label="2026-04").first()
|
||||
value = next(item for item in month.entry_values if item.entry.name == "Miete")
|
||||
|
||||
baseline = service.compute_summary(month)
|
||||
value.entry.is_active = False
|
||||
db.session.commit()
|
||||
|
||||
summary = service.compute_summary(month)
|
||||
|
||||
assert summary.fixed_costs == baseline.fixed_costs - Decimal("920.00")
|
||||
assert summary.total_costs == baseline.total_costs - Decimal("920.00")
|
||||
|
||||
@@ -72,6 +72,33 @@ def test_admin_can_access_admin_route(logged_in_client):
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_admin_route_shows_inactive_cleanup_section(logged_in_client, app):
|
||||
entry = Entry.query.filter_by(name="Lebensmittel").first()
|
||||
entry.is_active = False
|
||||
db.session.commit()
|
||||
|
||||
response = logged_in_client.get("/admin/")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Inaktive Elemente" in response.get_data(as_text=True)
|
||||
assert "Endgültig löschen" in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_admin_can_hard_delete_inactive_entry(logged_in_client, app):
|
||||
entry = Entry.query.filter_by(name="Lebensmittel").first()
|
||||
entry.is_active = False
|
||||
entry_id = entry.id
|
||||
db.session.commit()
|
||||
|
||||
response = logged_in_client.post(
|
||||
f"/admin/entries/{entry_id}/delete",
|
||||
follow_redirects=True,
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert Entry.query.get(entry_id) is None
|
||||
|
||||
|
||||
def test_admin_can_create_entry_and_backfill_existing_month(logged_in_client, app):
|
||||
from app.models import Category, Entry, Month, MonthlyEntryValue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user