generated from coulomb/repo-seed
Fix cumulative platform cost Stripe double-counting
Split infrastructure vs payment-processing costs. Liquidity burn now uses infrastructure cash out only (€1,155.20 cumulative) because Stripe fees are already deducted from net member payments. Total platform cost (€1,158.24) remains visible for gross-margin economics.
This commit is contained in:
@@ -4,6 +4,8 @@ import json
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
_ZERO = Decimal("0")
|
||||
|
||||
from .models import (
|
||||
Budget,
|
||||
CostEntry,
|
||||
@@ -89,15 +91,25 @@ def load_cost_rate_card(data_dir: Path | None = None) -> tuple[list[CostEntry],
|
||||
|
||||
def load_monthly_platform_costs(data_dir: Path | None = None) -> list[MonthlyPlatformCost]:
|
||||
raw = _read_json((data_dir or default_data_dir()) / "costs.json")
|
||||
return [
|
||||
MonthlyPlatformCost(
|
||||
period=item["period"],
|
||||
platform_cost=_money(item["platform_cost"]),
|
||||
active_members=item["active_members"],
|
||||
gross_revenue=_money(item["gross_revenue"]),
|
||||
rows: list[MonthlyPlatformCost] = []
|
||||
for item in raw.get("monthly_history", []):
|
||||
if "infrastructure_cost" in item:
|
||||
infrastructure = _money(item["infrastructure_cost"])
|
||||
processing = _money(item.get("payment_processing_cost", "0"))
|
||||
else:
|
||||
# Legacy single platform_cost field treated as infrastructure only.
|
||||
infrastructure = _money(item["platform_cost"])
|
||||
processing = _ZERO
|
||||
rows.append(
|
||||
MonthlyPlatformCost(
|
||||
period=item["period"],
|
||||
infrastructure_cost=infrastructure,
|
||||
payment_processing_cost=processing,
|
||||
active_members=item["active_members"],
|
||||
gross_revenue=_money(item["gross_revenue"]),
|
||||
)
|
||||
)
|
||||
for item in raw.get("monthly_history", [])
|
||||
]
|
||||
return rows
|
||||
|
||||
|
||||
def load_revenue(data_dir: Path | None = None) -> list[RevenueEntry]:
|
||||
|
||||
Reference in New Issue
Block a user