Verified Commit 470d11fb authored by Jakob Moser's avatar Jakob Moser
Browse files

Do away with BudgetPlanLoader syntax

parent dcb3b598
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@ from ..amount.AmountParser import format_as_euro_de
from ..budget_plan.BudgetPlan import BudgetPlan
from ..payment_order.PaymentOrder import PaymentOrder

from ..budget_plan.BudgetPlanLoader import load_pdf
from ..payment_order.PaymentOrderCollection import PaymentOrderCollection


@@ -86,5 +85,5 @@ class CashFlowAnalysis:

    @classmethod
    def from_files(cls, payment_orders_path: Path, budget_plan_path: Path) -> Self:
        budget_plan = load_pdf(budget_plan_path)
        budget_plan = BudgetPlan.from_file(budget_plan_path)
        return cls(budget_plan, PaymentOrderCollection(payment_orders_path))
+15 −0
Original line number Diff line number Diff line
@@ -2,8 +2,11 @@ from dataclasses import dataclass
from typing import Self, Any, Optional
from collections.abc import Iterable, Sequence

from ..integration.schwalbe.studienfachschaften import Studienfachschaft

from .BudgetaryItem import BudgetaryItem
from .BudgetaryGroup import BudgetaryGroup
from .loader import load_pdf


@dataclass(frozen=True, eq=False)
@@ -11,6 +14,18 @@ class BudgetPlan:

    _groups: dict[str, BudgetaryGroup]

    @classmethod
    def get(cls, studienfachschaft: Studienfachschaft, year: int) -> Self:
        instance_dir = Path(__file__).parent.parent.parent / "instance"

        return cls.from_file(
            instance_dir / "budget_plans" / studienfachschaft.uuid / str(year)
        )

    @classmethod
    def from_file(cls, path_or_str: Path | str) -> Self:
        return load_pdf(path_or_str)

    @classmethod
    def from_groups(cls, groups: Iterable[BudgetaryGroup]) -> Self:
        return cls({group.id: group for group in groups})
+2 −2
Original line number Diff line number Diff line
from argparse import ArgumentParser
from pathlib import Path

from ..budget_plan.BudgetPlanLoader import load_pdf
from ..budget_plan.BudgetPlan import BudgetPlan
from ..payment_order.PaymentOrderCollection import PaymentOrderCollection
from ..analysis.CashFlowAnalysis import CashFlowAnalysis
from ..report.svg import save_badges
@@ -16,7 +16,7 @@ def start() -> None:

    args = parser.parse_args()

    budget_plan = load_pdf(Path(args.budget_plan))
    budget_plan = BudgetPlan.from_file(Path(args.budget_plan))
    payment_orders = PaymentOrderCollection(Path(args.payment_orders))
    analysis = CashFlowAnalysis(budget_plan, payment_orders)