Add configurable locale/display formatting environment variables (`PALLADIUM_CURRENCY_SYMBOL`, `PALLADIUM_THOUSANDS_SEP`, `PALLADIUM_DECIMAL_SEP`) to support regional number formatting in the Streamlit app. Update `.env.example` with documentation for these new variables. Also refresh `00_setup.ipynb` with current execution outputs reflecting a live Athena connection with report templates, a selected client (Global Guardian Insurance, ID=2), and resolved NameError in assumption override cells.
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""Benefits data-entry tab."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import streamlit as st
|
|
|
|
from app.components.tables import df_to_values, value_editor
|
|
from app.utils import icon
|
|
|
|
from app.views._helpers import report_meta, safe
|
|
from core.tei_client import TEIClient
|
|
|
|
|
|
def render(client: TEIClient, tool: dict) -> None:
|
|
st.markdown(
|
|
f"<h2>{icon('graph-up-arrow')} Benefits</h2>",
|
|
unsafe_allow_html=True,
|
|
)
|
|
public_id = tool["id"]
|
|
report = report_meta(client, tool)
|
|
analysis_years = int(report.get("analysis_period_years") or 3)
|
|
|
|
fields = safe(client.list_fields, report.get("id"), "benefits") or []
|
|
values = [v for v in safe(client.get_values, public_id) or [] if v.get("table") == "benefits"]
|
|
|
|
if not fields:
|
|
st.info("This report template has no benefit fields defined.")
|
|
return
|
|
|
|
edited = value_editor(
|
|
"benefits",
|
|
fields,
|
|
values,
|
|
analysis_years=analysis_years,
|
|
key=f"benefits_editor_{public_id}",
|
|
)
|
|
|
|
col1, col2 = st.columns([1, 4])
|
|
with col1:
|
|
if st.button("Save benefits", width="stretch"):
|
|
|
|
payload = df_to_values(edited, "benefits", analysis_years)
|
|
result = safe(client.update_values, public_id, payload)
|
|
if result is not None:
|
|
st.success(f"Saved {len(payload)} benefit values.")
|
|
st.cache_data.clear()
|
|
with col2:
|
|
st.caption(
|
|
"Values are saved as nominal annual amounts. Risk adjustments are "
|
|
"applied at calculate time. Use the Recalculate button in the "
|
|
"sidebar after saving to refresh the summary."
|
|
)
|