All checks were successful
Deploy production / deploy (push) Successful in 11m10s
13 lines
454 B
Python
13 lines
454 B
Python
"""Versioned contribution shared by calculation, reconstruction and ledger."""
|
|
|
|
from decimal import Decimal
|
|
|
|
|
|
def carryover_contribution(kind: str, amount: Decimal, *, version: int = 2) -> Decimal:
|
|
if version not in (1, 2):
|
|
raise ValueError("Unsupported payroll balance rules version")
|
|
increases = kind in {"adjustment_debit", "deduction"} or (
|
|
kind == "payment" and version == 1
|
|
)
|
|
return amount if increases else -amount
|