Show credit settlements as positive amounts

This commit is contained in:
Marcel Peterkau
2026-06-27 15:39:52 +02:00
parent d897dd5f6e
commit d8900d9767
5 changed files with 54 additions and 3 deletions
+7
View File
@@ -76,6 +76,13 @@ def allocated_total(data: ContributionData, claim_id: str) -> Decimal:
)
def claim_settled_total(data: ContributionData, claim: dict[str, Any]) -> Decimal:
allocated = allocated_total(data, str(claim.get("claim_id", "")))
if claim_total(claim) < 0:
return abs(allocated).quantize(CENT)
return allocated.quantize(CENT)
def payment_allocated_total(data: ContributionData, payment_id: str) -> Decimal:
return sum(
(
+2 -2
View File
@@ -15,9 +15,9 @@ from xml.etree import ElementTree
from ccma.domain.contributions import (
CLAIM_STATUS_LABELS,
allocated_total,
claim_balance,
claim_items,
claim_settled_total,
claim_status,
claim_total,
money_text,
@@ -257,7 +257,7 @@ def _template_values(
),
"claim.created_at": _display_timestamp(str(claim.get("created_at", ""))),
"claim.total": f"{money_text(claim_total(claim))} EUR",
"claim.paid": f"{money_text(allocated_total(data, claim_id))} EUR",
"claim.paid": f"{money_text(claim_settled_total(data, claim))} EUR",
"claim.balance": f"{money_text(claim_balance(data, claim))} EUR",
"claim.status": CLAIM_STATUS_LABELS.get(status, status),
"claim.items": "; ".join(item_lines),
+2 -1
View File
@@ -12,6 +12,7 @@ from ccma.domain.contributions import (
allocated_total,
claim_balance,
claim_items,
claim_settled_total,
claim_status,
claim_total,
credit_allocated_total,
@@ -166,7 +167,7 @@ class ClaimTab(ttk.Frame):
messagebox.showerror("Forderung konnte nicht geladen werden", str(exc), parent=self)
return
total = claim_total(self.claim)
paid = allocated_total(self.data, self.claim_id)
paid = claim_settled_total(self.data, self.claim)
balance = claim_balance(self.data, self.claim)
status = claim_status(self.data, self.claim)
self.title_var.set(str(self.claim.get("title") or "Forderung"))