release: publish saldo 0.1.0
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
from app.extensions import db
|
||||
from app.models import Month
|
||||
|
||||
|
||||
def test_auto_creates_missing_month(app):
|
||||
service = app.extensions["saldo.month_service"]
|
||||
month = service.ensure_month(date(2026, 5, 1))
|
||||
assert month.label == "2026-05"
|
||||
assert month.auto_created is True
|
||||
|
||||
|
||||
def test_copy_previous_month_keeps_values(app):
|
||||
service = app.extensions["saldo.month_service"]
|
||||
april = Month.query.filter_by(label="2026-04").first()
|
||||
copied = service.copy_month(april, 2026, 6, auto_created=False)
|
||||
db.session.commit()
|
||||
assert copied.label == "2026-06"
|
||||
assert len(copied.entry_values) == len(april.entry_values)
|
||||
assert copied.incomes[0].amount == april.incomes[0].amount
|
||||
|
||||
|
||||
def test_remainder_calculation(app):
|
||||
service = app.extensions["saldo.month_service"]
|
||||
month = Month.query.filter_by(label="2026-04").first()
|
||||
summary = service.compute_summary(month)
|
||||
assert summary.total_income == Decimal("5550.00")
|
||||
assert summary.remainder == summary.total_income - summary.total_costs
|
||||
Reference in New Issue
Block a user