mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-07-01 11:14:52 +02:00
feat: add scriptable housekeeper rule engine
This commit is contained in:
@@ -34,11 +34,14 @@ DEFAULT_CONFIGURATION = {
|
||||
"rule_id": "standard-2022",
|
||||
"name": "Regulärer Beitrag ab 2022",
|
||||
"valid_from": "2022-01-01",
|
||||
"valid_until": None,
|
||||
"annual_amount": "150.00",
|
||||
"admission_fee": "10.00",
|
||||
"annual_due": "01-31",
|
||||
"semiannual_due": ["01-31", "07-31"],
|
||||
"entry_proration": {"mode": "monthly", "started_month": "included"},
|
||||
"first_payment_due_days_after_acceptance": 28,
|
||||
"issue_days_before_due": 30,
|
||||
"reminder_fee": "5.00",
|
||||
"failed_debit_fee": "5.00",
|
||||
}
|
||||
@@ -53,6 +56,7 @@ class MemberRepository:
|
||||
|
||||
def initialize(self) -> None:
|
||||
self.members_root.mkdir(parents=True, exist_ok=True)
|
||||
(self.root / "rules").mkdir(parents=True, exist_ok=True)
|
||||
config_path = self.root / "repository.json"
|
||||
if not config_path.exists():
|
||||
write_json_atomic(config_path, DEFAULT_CONFIGURATION)
|
||||
@@ -272,6 +276,15 @@ class MemberRepository:
|
||||
def member_count(self) -> int:
|
||||
return sum(1 for _ in self._member_directories())
|
||||
|
||||
def get_configuration(self) -> dict:
|
||||
try:
|
||||
configuration = read_json(self.root / "repository.json")
|
||||
except (OSError, ValueError, TypeError, json.JSONDecodeError) as exc:
|
||||
raise RepositoryError(f"repository.json konnte nicht gelesen werden: {exc}") from exc
|
||||
if not isinstance(configuration, dict):
|
||||
raise RepositoryError("repository.json enthält keine gültige Konfiguration.")
|
||||
return configuration
|
||||
|
||||
def get_member_number_policy(self) -> dict[str, str]:
|
||||
try:
|
||||
config = read_json(self.root / "repository.json")
|
||||
|
||||
Reference in New Issue
Block a user