Implement canonical pricing core and close WP-0003

This commit is contained in:
codex
2026-07-02 20:48:16 +02:00
parent ab700caa4b
commit 6c6f3d40ae
10 changed files with 705 additions and 41 deletions

View File

@@ -4,6 +4,10 @@ import json
from decimal import Decimal
from pathlib import Path
from ._repo_root import ensure_repo_root_on_syspath
ensure_repo_root_on_syspath()
from adaptive_pricing_core.pricing_models import load_pricing_models as load_canonical_pricing_models
from .ledger import build_monthly_ledger
from .models import (
Budget,
@@ -50,20 +54,7 @@ def load_budget(data_dir: Path | None = None) -> Budget:
def load_pricing_models(data_dir: Path | None = None) -> list[PricingModel]:
raw = _read_json((data_dir or default_data_dir()) / "pricing-models.json")
return [
PricingModel(
id=item["id"],
name=item["name"],
model_type=item["model_type"],
lifecycle_phase=item["lifecycle_phase"],
currency=item["currency"],
access_fee_amount=_money(item["access_fee_amount"]),
access_fee_cadence=item["access_fee_cadence"],
status=item["status"],
)
for item in raw["models"]
]
return load_canonical_pricing_models((data_dir or default_data_dir()) / "pricing-models.json")
def load_fx_rates(data_dir: Path | None = None) -> dict[str, Decimal]:
@@ -150,4 +141,4 @@ def load_monthly_ledger(data_dir: Path | None = None) -> list[MonthlyPlatformCos
def latest_period(monthly_costs: list[MonthlyPlatformCost]) -> str:
return max(item.period for item in monthly_costs)
return max(item.period for item in monthly_costs)