"""Entry point for the model generated from 'fpna_month_end.xlsx'. ``compute(book)`` fills in every formula cell of the workbook in dependency order and returns the same Book. Start from ``load_inputs()`` for the workbook's own input values, or build a Book with your own. """ from __future__ import annotations import json from pathlib import Path from .xl import Book from .sheets import ( assumptions, costs, dashboard, orders, p_l, revenue, ) _HERE = Path(__file__).parent def load_inputs(path: str | Path | None = None) -> Book: """Load the workbook's input cells and defined names into a Book.""" return Book.from_json(str(path or _HERE / "inputs.json")) def compute(book: Book) -> Book: """Run every logic block in dependency order.""" assumptions.last_refreshed(book) orders.month(book) orders.region(book) orders.unit_price(book) orders.gross_eur(book) orders.discount_eur(book) orders.net_gbp(book) orders.period(book) orders.range_k151_k301(book) revenue.product(book) revenue.product_c2(book) revenue.p_100(book) revenue.total(book) revenue.total_b12(book) revenue.uk_i(book) revenue.range_n15_n17(book) revenue.orders_in_month(book) costs.month_index(book) costs.headcount(book) costs.salary_cost(book) costs.rent(book) costs.total_costs(book) p_l.month(book) p_l.revenue(book) p_l.costs(book) p_l.gross_margin(book) p_l.margin(book) p_l.tax(book) p_l.net_result(book) p_l.net_ytd(book) p_l.net_ytd_c9(book) p_l.quarter(book) p_l.revenue_b13(book) p_l.net_result_c13(book) dashboard.total_net_revenue(book) dashboard.total_net_result(book) dashboard.best_month(book) dashboard.worst_month(book) dashboard.loss_making_months(book) dashboard.average_margin_profitable_months(book) dashboard.average_headcount(book) dashboard.orders_with_unknown_product(book) dashboard.headline(book) return book