diff --git a/main.py b/main.py index 4529eaa..e14fdd1 100644 --- a/main.py +++ b/main.py @@ -88,6 +88,8 @@ CONFIG = { "receipt_footer_cashier": "", # Timezone for display (IANA name); defaults to server local timezone "timezone": _server_timezone(), + # Default paper size for receipts and statements + "paper_size": "A4", } DB_PATH = "clubledger.db" @@ -499,6 +501,8 @@ class AppSettingsUpdate(BaseModel): receipt_footer_cashier: Optional[str] = None # Timezone timezone: Optional[str] = None + # Default paper size + paper_size: Optional[str] = None # --------------------------------------------------------------------------- # Page routes @@ -737,20 +741,24 @@ def transactions(member_id: int, limit: int = 50, offset: int = 0, # Print views (no auth – opened as new-tab popups) # --------------------------------------------------------------------------- -def _print_size_script(): - return """""" -def _print_controls(): - return """
+def _print_controls(s: dict): + size = "A5" if (s.get("paper_size") or "A4").upper() == "A5" else "A4" + a4_chk = ' checked' if size == "A4" else '' + a5_chk = ' checked' if size == "A5" else '' + return f"""
Paper: - - + +
""" @@ -905,7 +913,7 @@ def statement(member_id: int): return f""" Statement — {member['name']} -{_print_controls()} +{_print_controls(s)} {_biz_header_html(s)}

Account Statement

@@ -919,7 +927,7 @@ def statement(member_id: int): {rows_html}
Current Balance: {fmt(bal)}
{('') if footer else ''} -{_print_size_script()}""" +{_print_size_script(s)}""" @app.get("/receipt/{entry_id}", response_class=HTMLResponse) def receipt(entry_id: int): @@ -1008,14 +1016,14 @@ def receipt(entry_id: int): return f""" Receipt — {member['name']} -{_print_controls()} +{_print_controls(s)} {_biz_header_html(s)}
{title}
{body_html}
{('') if footer else ''} -{_print_size_script()}""" +{_print_size_script(s)}""" # --------------------------------------------------------------------------- # Products diff --git a/static/app.js b/static/app.js index 5f6fc66..b8f1e62 100644 --- a/static/app.js +++ b/static/app.js @@ -439,6 +439,7 @@ async function loadAdminSettings() { document.getElementById('s-max-charge').value = ((s.max_charge || 0) / div).toFixed(2); document.getElementById('s-overdraft-policy').value = s.overdraft_policy || 'never'; document.getElementById('s-timezone').value = s.timezone || ''; + document.getElementById('s-paper-size').value = s.paper_size || 'A4'; document.getElementById('s-min-hint').textContent = `in ${majorUnit}`; document.getElementById('s-max-hint').textContent = `in ${majorUnit}`; document.getElementById('s-charge-hint').textContent= `in ${majorUnit}`; @@ -502,6 +503,7 @@ async function saveSettings() { max_charge: Math.round(parseFloat(_sv('s-max-charge')) * div), overdraft_policy: _sv('s-overdraft-policy'), timezone: _svt('s-timezone'), + paper_size: _sv('s-paper-size'), // Business address biz_address1: _svt('s-biz-address1'), biz_address2: _svt('s-biz-address2'), diff --git a/static/index.html b/static/index.html index b0dfa45..4463b3c 100644 --- a/static/index.html +++ b/static/index.html @@ -218,6 +218,13 @@
+
+ + +

Business Address