mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-08-24 22:45:18 +02:00
feat: extend inventory and administration workflows
This commit is contained in:
@@ -59,6 +59,49 @@ def test_legacy_claim_becomes_itemized_when_position_is_added(tmp_path) -> None:
|
||||
assert claim_balance(data, claim) == Decimal("90.00")
|
||||
|
||||
|
||||
def test_claim_base_data_can_be_edited(tmp_path) -> None:
|
||||
repository, member = _repository_with_claim(tmp_path)
|
||||
|
||||
repository.update_claim(
|
||||
member.member_id,
|
||||
"claim-1",
|
||||
title="Korrigierter Beitrag",
|
||||
due_date="30.06.2026",
|
||||
base_amount="75,00",
|
||||
description="Beitrag für sechs Monate",
|
||||
)
|
||||
|
||||
_data, claim = repository.get_claim(member.member_id, "claim-1")
|
||||
assert claim["title"] == "Korrigierter Beitrag"
|
||||
assert claim["due_date"] == "2026-06-30"
|
||||
assert claim["amount"] == "75.00"
|
||||
assert claim["items"][0]["description"] == "Beitrag für sechs Monate"
|
||||
assert claim["items"][0]["amount"] == "75.00"
|
||||
assert claim["calculation"]["manual_override"]["actor"] == "Vorstand"
|
||||
assert repository.get_events(member.member_id)[-1].event_type == "claim_changed"
|
||||
|
||||
|
||||
def test_claim_cannot_be_reduced_below_allocated_payment(tmp_path) -> None:
|
||||
repository, member = _repository_with_claim(tmp_path)
|
||||
repository.record_payment(
|
||||
member.member_id,
|
||||
"claim-1",
|
||||
payment_date="2026-06-21",
|
||||
amount="80.00",
|
||||
allocation_amount="80.00",
|
||||
)
|
||||
|
||||
with pytest.raises(RepositoryError, match="bereits zugeordneten Betrag"):
|
||||
repository.update_claim(
|
||||
member.member_id,
|
||||
"claim-1",
|
||||
title="Zu klein",
|
||||
due_date="2026-06-30",
|
||||
base_amount="75.00",
|
||||
description="",
|
||||
)
|
||||
|
||||
|
||||
def test_payment_can_be_split_across_multiple_claims(tmp_path) -> None:
|
||||
repository, member = _repository_with_claim(tmp_path)
|
||||
data = repository.get_contributions(member.member_id)
|
||||
@@ -104,6 +147,77 @@ def test_payment_can_be_split_across_multiple_claims(tmp_path) -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_payment_allocation_cannot_overpay_claim(tmp_path) -> None:
|
||||
repository, member = _repository_with_claim(tmp_path, amount="12.50")
|
||||
|
||||
with pytest.raises(RepositoryError, match="nur noch 12.50 EUR offen"):
|
||||
repository.record_payment(
|
||||
member.member_id,
|
||||
"claim-1",
|
||||
payment_date="2026-06-21",
|
||||
amount="22.50",
|
||||
allocation_amount="22.50",
|
||||
)
|
||||
|
||||
|
||||
def test_payment_can_be_edited_and_reallocated_atomically(tmp_path) -> None:
|
||||
repository, member = _repository_with_claim(tmp_path, amount="12.50")
|
||||
data = repository.get_contributions(member.member_id)
|
||||
data.claims.append(
|
||||
{
|
||||
"claim_id": "admission-fee",
|
||||
"claim_key": "admission-fee",
|
||||
"title": "Aufnahmegebühr",
|
||||
"amount": "10.00",
|
||||
"due_date": "2026-12-31",
|
||||
"status": "open",
|
||||
}
|
||||
)
|
||||
repository.save_contributions(member.member_id, data)
|
||||
payment = repository.record_payment(
|
||||
member.member_id,
|
||||
"claim-1",
|
||||
payment_date="2026-06-21",
|
||||
amount="22.50",
|
||||
allocation_amount="12.50",
|
||||
reference="Vorher",
|
||||
)
|
||||
|
||||
repository.update_payment(
|
||||
member.member_id,
|
||||
payment["payment_id"],
|
||||
payment_date="22.06.2026",
|
||||
amount="22.50",
|
||||
allocations={"claim-1": "12.50", "admission-fee": "10.00"},
|
||||
reference="Korrigiert",
|
||||
)
|
||||
|
||||
changed = repository.get_contributions(member.member_id)
|
||||
assert changed.payments[0]["date"] == "2026-06-22"
|
||||
assert changed.payments[0]["reference"] == "Korrigiert"
|
||||
assert payment_allocated_total(changed, payment["payment_id"]) == Decimal("22.50")
|
||||
assert {item["claim_id"] for item in changed.allocations} == {"claim-1", "admission-fee"}
|
||||
assert repository.get_events(member.member_id)[-1].event_type == "payment_changed"
|
||||
|
||||
|
||||
def test_payment_can_be_deleted_with_its_allocations(tmp_path) -> None:
|
||||
repository, member = _repository_with_claim(tmp_path)
|
||||
payment = repository.record_payment(
|
||||
member.member_id,
|
||||
"claim-1",
|
||||
payment_date="2026-06-21",
|
||||
amount="10.00",
|
||||
allocation_amount="10.00",
|
||||
)
|
||||
|
||||
repository.delete_payment(member.member_id, payment["payment_id"])
|
||||
|
||||
data = repository.get_contributions(member.member_id)
|
||||
assert data.payments == []
|
||||
assert data.allocations == []
|
||||
assert repository.get_events(member.member_id)[-1].event_type == "payment_deleted"
|
||||
|
||||
|
||||
def test_credit_claim_settlement_is_displayed_as_positive_amount() -> None:
|
||||
claim = {"claim_id": "claim-1", "title": "Kautionsrückzahlung", "amount": "-25.00"}
|
||||
data = ContributionData(
|
||||
|
||||
Reference in New Issue
Block a user