SPB Git

spb/uqo-chat

Public
2.0 KB · 45 lines python
1"""Template: two-way sensitivity of cost-approach value (unit cost × effective age)."""23from __future__ import annotations45from typing import Any678def build(p: dict[str, Any]) -> dict[str, Any]:9    superficie = float(p.get("superficie_m2", 210))10    base_cu = float(p.get("cout_unitaire_m2", 2450))11    dve = float(p.get("duree_vie_economique", 60))12    terrain = float(p.get("valeur_terrain", 185000))13    ages = p.get("ages", [5, 10, 15, 20, 25])14    variations = p.get("variations", [-0.10, -0.05, 0.0, 0.05, 0.10])15    inputs = [16        {"cell": "B4", "label": "Superficie (m²)", "value": superficie, "format": "area"},17        {"cell": "B5", "label": "Coût unitaire de base ($/m²)", "value": base_cu, "format": "currency"},18        {"cell": "B6", "label": "Durée de vie économique (ans)", "value": dve, "format": "number"},19        {"cell": "B7", "label": "Valeur du terrain ($)", "value": terrain, "format": "currency"},20    ]21    header = [{"header": "Variation coût ↓ / Âge effectif →", "type": "text"}] + [22        {"header": f"{a} ans", "type": "currency"} for a in ages]23    rows = []24    for i, v in enumerate(variations):25        r = 11 + i26        row: list[Any] = [float(v)]27        for j, a in enumerate(ages):28            col = chr(ord("B") + j)29            row.append(f"=$B$7+$B$4*$B$5*(1+$A{r})*(1-{a}/$B$6)")30            _ = col31        rows.append(row)32    table = {"anchor": "A10", "columns": header, "rows": rows, "first_col_format": "percent"}33    return {34        "filename": p.get("filename", "analyse_sensibilite.xlsx"),35        "style": "uqo",36        "sheets": [{37            "name": "Sensibilité",38            "title": "Analyse de sensibilité — valeur par la méthode du coût",39            "inputs": inputs,40            "tables": [table],41            "notes": ["Valeur = V_T + S × c_u × (1 + variation) × (1 − âge / DVE).",42                      "Lire l'écart entre les cases extrêmes : il mesure le risque d'estimation."],43        }],44    }45
Files · cd08d441f7c277e8fedd6f3d3be82f02b44553ba
Menu

Theme