8 Commits

Author SHA1 Message Date
083a51023c feat: Add Flush Cache tool page to web UI
Some checks failed
Deploy to K8s / deploy (push) Failing after 7s
Build and Push / build (push) Successful in 6s
Adds a /flush-cache web page with a button to clear all cached Google
Sheets data and reset refresh timers. Link added to Tools nav across
all templates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 17:43:03 +01:00
54762cd421 feat: Change QR payment message separator from "/" to ":"
Some checks failed
Deploy to K8s / deploy (push) Failing after 6s
Build and Push / build (push) Successful in 6s
Format is now "Name: MM/YYYY+MM/YYYY" instead of "Name / MM/YYYY+MM/YYYY"
for clearer readability when multiple months are included.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 17:35:46 +01:00
b2aaca5df9 feat: Add /sync-bank endpoint to trigger bank sync and inference from web UI
Some checks failed
Deploy to K8s / deploy (push) Failing after 6s
Build and Push / build (push) Successful in 6s
Adds a new GET /sync-bank route that runs sync_to_sheets (2026) + infer_payments + flush_cache,
capturing all output and displaying it on a styled results page. Adds "Tools: [Sync Bank Data]"
nav link to all templates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 17:24:41 +01:00
883bc4489e feat: Add per-month rate override for adult fees
Some checks failed
Deploy to K8s / deploy (push) Failing after 5s
Build and Push / build (push) Successful in 6s
Mirror the junior fee override mechanism (JUNIOR_MONTHLY_RATE) for adults
via ADULT_FEE_MONTHLY_RATE. Set 2026-03 override to 350 CZK. Rename
FEE_FULL/FEE_SINGLE to ADULT_FEE_DEFAULT/ADULT_FEE_SINGLE for consistency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 16:54:00 +01:00
3ad4a21f5b feat: Pass build metadata args in Gitea CI pipeline
Some checks failed
Deploy to K8s / deploy (push) Failing after 6s
Build and Push / build (push) Successful in 5s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 16:34:34 +01:00
3c1604c7af feat: Bake build metadata (git tag, commit, date) into OCI image and display in web UI
Some checks failed
Deploy to K8s / deploy (push) Failing after 10s
Build and Push / build (push) Successful in 6s
Store git tag, commit hash, and build date as OCI-standard labels and a
build_meta.json file inside the Docker image. The Flask app reads this at
startup and displays version info in all page footers. Adds /version JSON
endpoint for programmatic access. Falls back to dev@local outside Docker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 16:30:20 +01:00
8b3223f865 feat: Add POST /flush-cache endpoint to clear all cached data and reset timers
Some checks failed
Deploy to K8s / deploy (push) Failing after 7s
Build and Push / build (push) Successful in 6s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 10:45:47 +01:00
276e18a9c8 feat: Show attendance breakdown for single-visit junior fees
All checks were successful
Build and Push / build (push) Successful in 8s
When a junior attended only once in a month (fee = "?"), the dashboard
cells now display the attendance details (e.g., "? (1:1J)") instead of
a bare "?". Applied to both /juniors and /reconcile-juniors routes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 10:41:45 +01:00
15 changed files with 566 additions and 65 deletions

View File

@@ -31,5 +31,9 @@ jobs:
TAG=${{ inputs.tag }}
fi
IMAGE=gitea.home.hrajfrisbee.cz/${{ github.repository }}:$TAG
docker build -f build/Dockerfile -t $IMAGE .
docker build -f build/Dockerfile \
--build-arg GIT_TAG=$TAG \
--build-arg GIT_COMMIT=${{ github.sha }} \
--build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
-t $IMAGE .
docker push $IMAGE

View File

@@ -45,7 +45,11 @@ web-debug: $(PYTHON)
FLASK_DEBUG=1 $(PYTHON) app.py
image:
docker build -t fuj-management:latest -f build/Dockerfile .
docker build -t fuj-management:latest \
--build-arg GIT_TAG=$$(git describe --tags --always 2>/dev/null || echo "untagged") \
--build-arg GIT_COMMIT=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +%Y-%m-%dT%H:%M:%SZ) \
-f build/Dockerfile .
run:
docker run -it --rm -p 5001:5001 -v $(CURDIR)/.secret:/app/.secret:ro fuj-management:latest

154
app.py
View File

@@ -23,7 +23,9 @@ from config import (
)
from attendance import get_members_with_fees, get_junior_members_with_fees, ADULT_MERGED_MONTHS, JUNIOR_MERGED_MONTHS
from match_payments import reconcile, fetch_sheet_data, fetch_exceptions, normalize
from cache_utils import get_sheet_modified_time, read_cache, write_cache, _LAST_CHECKED
from cache_utils import get_sheet_modified_time, read_cache, write_cache, _LAST_CHECKED, flush_cache
from sync_fio_to_sheets import sync_to_sheets
from infer_payments import infer_payments
def get_cached_data(cache_key, sheet_id, fetch_func, *args, serialize=None, deserialize=None, **kwargs):
mod_time = get_sheet_modified_time(cache_key)
@@ -72,6 +74,13 @@ def warmup_cache():
logger.info("Cache warmup complete.")
app = Flask(__name__)
import json as _json
_meta_path = Path(__file__).parent / "build_meta.json"
BUILD_META = _json.loads(_meta_path.read_text()) if _meta_path.exists() else {
"tag": "dev", "commit": "local", "build_date": ""
}
warmup_cache()
@app.before_request
@@ -101,13 +110,53 @@ def inject_render_time():
"total": f"{total:.3f}",
"breakdown": " | ".join(breakdown)
}
return dict(get_render_time=get_render_time)
return dict(get_render_time=get_render_time, build_meta=BUILD_META)
@app.route("/")
def index():
# Redirect root to /adults for convenience while there are no other apps
return '<meta http-equiv="refresh" content="0; url=/adults" />'
@app.route("/flush-cache", methods=["GET", "POST"])
def flush_cache_endpoint():
if request.method == "GET":
return render_template("flush-cache.html")
deleted = flush_cache()
return render_template("flush-cache.html", flushed=True, deleted=deleted)
@app.route("/sync-bank")
def sync_bank():
import contextlib
output = io.StringIO()
success = True
try:
with contextlib.redirect_stdout(output), contextlib.redirect_stderr(output):
# sync_to_sheets: equivalent of make sync-2026
output.write("=== Syncing Fio transactions (2026) ===\n")
sync_to_sheets(
spreadsheet_id=PAYMENTS_SHEET_ID,
credentials_path=CREDENTIALS_PATH,
date_from_str="2026-01-01",
date_to_str="2026-12-31",
sort_by_date=True,
)
output.write("\n=== Inferring payment details ===\n")
infer_payments(PAYMENTS_SHEET_ID, CREDENTIALS_PATH)
output.write("\n=== Flushing cache ===\n")
deleted = flush_cache()
output.write(f"Deleted {deleted} cache files.\n")
output.write("\n=== Done ===\n")
except Exception as e:
import traceback
output.write(f"\n!!! Error: {e}\n")
output.write(traceback.format_exc())
success = False
return render_template("sync.html", output=output.getvalue(), success=success)
@app.route("/version")
def version():
return BUILD_META
@app.route("/fees")
def fees():
attendance_url = f"https://docs.google.com/spreadsheets/d/{ATTENDANCE_SHEET_ID}/edit"
@@ -284,8 +333,9 @@ def adults_view():
formatted_results = []
for name in adult_names:
data = result["members"][name]
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": ""}
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": "", "raw_unpaid_periods": ""}
unpaid_months = []
raw_unpaid_months = []
for m in sorted_months:
mdata = data["months"].get(m, {"expected": 0, "original_expected": 0, "attendance_count": 0, "paid": 0, "exception": None})
expected = mdata.get("expected", 0)
@@ -293,12 +343,12 @@ def adults_view():
count = mdata.get("attendance_count", 0)
paid = int(mdata.get("paid", 0))
exception_info = mdata.get("exception", None)
monthly_totals[m]["expected"] += expected
monthly_totals[m]["paid"] += paid
override_amount = exception_info["amount"] if exception_info else None
if override_amount is not None and override_amount != original_expected:
is_overridden = True
fee_display = f"{override_amount} ({original_expected}) CZK ({count})" if count > 0 else f"{override_amount} ({original_expected}) CZK"
@@ -309,7 +359,7 @@ def adults_view():
status = "empty"
cell_text = "-"
amount_to_pay = 0
if expected > 0:
amount_to_pay = max(0, expected - paid)
if paid >= expected:
@@ -319,32 +369,36 @@ def adults_view():
status = "partial"
cell_text = f"{paid}/{fee_display}"
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
else:
status = "unpaid"
cell_text = f"0/{fee_display}"
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
elif paid > 0:
status = "surplus"
cell_text = f"PAID {paid}"
else:
cell_text = "-"
amount_to_pay = 0
if expected > 0 or paid > 0:
tooltip = f"Received: {paid}, Expected: {expected}"
else:
tooltip = ""
row["months"].append({
"text": cell_text,
"overridden": is_overridden,
"status": status,
"amount": amount_to_pay,
"month": month_labels[m],
"raw_month": m,
"tooltip": tooltip
})
row["unpaid_periods"] = ", ".join(unpaid_months) if unpaid_months else ("Older debt" if data["total_balance"] < 0 else "")
row["raw_unpaid_periods"] = "+".join(raw_unpaid_months)
row["balance"] = data["total_balance"]
formatted_results.append(row)
@@ -423,17 +477,18 @@ def reconcile_view():
formatted_results = []
for name in adult_names:
data = result["members"][name]
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": ""}
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": "", "raw_unpaid_periods": ""}
unpaid_months = []
raw_unpaid_months = []
for m in sorted_months:
mdata = data["months"].get(m, {"expected": 0, "original_expected": 0, "paid": 0})
expected = mdata["expected"]
paid = int(mdata["paid"])
status = "empty"
cell_text = "-"
amount_to_pay = 0
if expected > 0:
if paid >= expected:
status = "ok"
@@ -443,23 +498,27 @@ def reconcile_view():
cell_text = f"{paid}/{expected}"
amount_to_pay = expected - paid
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
else:
status = "unpaid"
cell_text = f"UNPAID {expected}"
amount_to_pay = expected
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
elif paid > 0:
status = "surplus"
cell_text = f"PAID {paid}"
row["months"].append({
"text": cell_text,
"status": status,
"amount": amount_to_pay,
"month": month_labels[m]
"month": month_labels[m],
"raw_month": m
})
row["unpaid_periods"] = ", ".join(unpaid_months) if unpaid_months else ("Older debt" if data["total_balance"] < 0 else "")
row["raw_unpaid_periods"] = "+".join(raw_unpaid_months)
row["balance"] = data["total_balance"] # Updated to use total_balance
formatted_results.append(row)
@@ -536,8 +595,9 @@ def juniors_view():
formatted_results = []
for name in junior_names:
data = result["members"][name]
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": ""}
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": "", "raw_unpaid_periods": ""}
unpaid_months = []
raw_unpaid_months = []
for m in sorted_months:
mdata = data["months"].get(m, {"expected": 0, "original_expected": 0, "attendance_count": 0, "paid": 0, "exception": None})
expected = mdata.get("expected", 0)
@@ -545,11 +605,11 @@ def juniors_view():
count = mdata.get("attendance_count", 0)
paid = int(mdata.get("paid", 0))
exception_info = mdata.get("exception", None)
if expected != "?" and isinstance(expected, int):
monthly_totals[m]["expected"] += expected
monthly_totals[m]["paid"] += paid
orig_fee_data = junior_members_dict.get(name, {}).get(m)
adult_count = 0
junior_count = 0
@@ -565,9 +625,9 @@ def juniors_view():
breakdown = f":{adult_count}A"
count_str = f" ({count}{breakdown})" if count > 0 else ""
override_amount = exception_info["amount"] if exception_info else None
if override_amount is not None and override_amount != original_expected:
is_overridden = True
fee_display = f"{override_amount} ({original_expected}) CZK{count_str}"
@@ -578,11 +638,11 @@ def juniors_view():
status = "empty"
cell_text = "-"
amount_to_pay = 0
if expected == "?" or (isinstance(expected, int) and expected > 0):
if expected == "?":
status = "empty"
cell_text = "?"
cell_text = f"?{count_str}"
elif paid >= expected:
status = "ok"
cell_text = f"{paid}/{fee_display}"
@@ -591,30 +651,34 @@ def juniors_view():
cell_text = f"{paid}/{fee_display}"
amount_to_pay = expected - paid
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
else:
status = "unpaid"
cell_text = f"0/{fee_display}"
amount_to_pay = expected
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
elif paid > 0:
status = "surplus"
cell_text = f"PAID {paid}"
if (isinstance(expected, int) and expected > 0) or paid > 0:
tooltip = f"Received: {paid}, Expected: {expected}"
else:
tooltip = ""
row["months"].append({
"text": cell_text,
"overridden": is_overridden,
"status": status,
"amount": amount_to_pay,
"month": month_labels[m],
"raw_month": m,
"tooltip": tooltip
})
row["unpaid_periods"] = ", ".join(unpaid_months) if unpaid_months else ("Older debt" if data["total_balance"] < 0 else "")
row["raw_unpaid_periods"] = "+".join(raw_unpaid_months)
row["balance"] = data["total_balance"]
formatted_results.append(row)
@@ -705,24 +769,44 @@ def reconcile_juniors_view():
# Filter to juniors for the main table
junior_names = sorted([name for name, tier, _ in adapted_members])
junior_members_dict_rc = {name: fees_dict for name, _, fees_dict in junior_members}
formatted_results = []
for name in junior_names:
data = result["members"][name]
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": ""}
row = {"name": name, "months": [], "balance": data["total_balance"], "unpaid_periods": "", "raw_unpaid_periods": ""}
unpaid_months = []
raw_unpaid_months = []
for m in sorted_months:
mdata = data["months"].get(m, {"expected": 0, "original_expected": 0, "paid": 0})
expected = mdata["expected"]
paid = int(mdata["paid"])
orig_fee_data = junior_members_dict_rc.get(name, {}).get(m)
adult_count = 0
junior_count = 0
att_count = 0
if orig_fee_data and len(orig_fee_data) == 4:
_, att_count, adult_count, junior_count = orig_fee_data
breakdown = ""
if adult_count > 0 and junior_count > 0:
breakdown = f":{junior_count}J,{adult_count}A"
elif junior_count > 0:
breakdown = f":{junior_count}J"
elif adult_count > 0:
breakdown = f":{adult_count}A"
count_str = f" ({att_count}{breakdown})" if att_count > 0 else ""
status = "empty"
cell_text = "-"
amount_to_pay = 0
if expected == "?" or (isinstance(expected, int) and expected > 0):
if expected == "?":
status = "empty"
cell_text = "?"
cell_text = f"?{count_str}"
elif paid >= expected:
status = "ok"
cell_text = "OK"
@@ -731,23 +815,27 @@ def reconcile_juniors_view():
cell_text = f"{paid}/{expected}"
amount_to_pay = expected - paid
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
else:
status = "unpaid"
cell_text = f"UNPAID {expected}"
amount_to_pay = expected
unpaid_months.append(month_labels[m])
raw_unpaid_months.append(datetime.strptime(m, "%Y-%m").strftime("%m/%Y"))
elif paid > 0:
status = "surplus"
cell_text = f"PAID {paid}"
row["months"].append({
"text": cell_text,
"status": status,
"amount": amount_to_pay,
"month": month_labels[m]
"month": month_labels[m],
"raw_month": m
})
row["unpaid_periods"] = ", ".join(unpaid_months) if unpaid_months else ("Older debt" if data["total_balance"] < 0 else "")
row["raw_unpaid_periods"] = "+".join(raw_unpaid_months)
row["balance"] = data["total_balance"]
formatted_results.append(row)

View File

@@ -24,6 +24,17 @@ COPY templates/ ./templates/
COPY build/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ARG GIT_TAG=unknown
ARG GIT_COMMIT=unknown
ARG BUILD_DATE=unknown
LABEL org.opencontainers.image.version="${GIT_TAG}" \
org.opencontainers.image.revision="${GIT_COMMIT}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.title="fuj-management"
RUN echo "{\"tag\": \"${GIT_TAG}\", \"commit\": \"${GIT_COMMIT}\", \"build_date\": \"${BUILD_DATE}\"}" > /app/build_meta.json
EXPOSE 5001
HEALTHCHECK --interval=60s --timeout=5s --start-period=5s \

View File

@@ -10,8 +10,11 @@ from config import ATTENDANCE_SHEET_ID as SHEET_ID, JUNIOR_SHEET_GID
EXPORT_URL = f"https://docs.google.com/spreadsheets/d/{SHEET_ID}/export?format=csv&gid=0"
JUNIOR_EXPORT_URL = f"https://docs.google.com/spreadsheets/d/{SHEET_ID}/export?format=csv&gid={JUNIOR_SHEET_GID}"
FEE_FULL = 750 # CZK, for 2+ practices in a month
FEE_SINGLE = 200 # CZK, for exactly 1 practice in a month
ADULT_FEE_DEFAULT = 750 # CZK, for 2+ practices in a month
ADULT_FEE_SINGLE = 200 # CZK, for exactly 1 practice in a month
ADULT_FEE_MONTHLY_RATE = {
"2026-03": 350
}
JUNIOR_FEE_DEFAULT = 500 # CZK for 2+ practices
JUNIOR_MONTHLY_RATE = {
@@ -76,13 +79,13 @@ def group_by_month(dates: list[tuple[int, datetime]], merged_months: dict[str, s
return months
def calculate_fee(attendance_count: int) -> int:
"""Apply fee rules: 0 → 0, 1 → 200, 2+ → 750."""
def calculate_fee(attendance_count: int, month_key: str) -> int:
"""Apply fee rules: 0 → 0, 1 → 200, 2+ → configured rate (default 750)."""
if attendance_count == 0:
return 0
if attendance_count == 1:
return FEE_SINGLE
return FEE_FULL
return ADULT_FEE_SINGLE
return ADULT_FEE_MONTHLY_RATE.get(month_key, ADULT_FEE_DEFAULT)
def calculate_junior_fee(attendance_count: int, month_key: str) -> str | int:
@@ -186,7 +189,7 @@ def get_members_with_fees() -> tuple[list[tuple[str, str, dict[str, int]]], list
for c in cols
if c < len(row) and row[c].strip().upper() == "TRUE"
)
fee = calculate_fee(count) if tier == "A" else 0
fee = calculate_fee(count, month_key) if tier == "A" else 0
month_fees[month_key] = (fee, count)
members.append((name, tier, month_fees))

View File

@@ -155,3 +155,19 @@ def write_cache(sheet_id: str, modified_time: str, data: list | dict) -> None:
logger.info(f"Wrote cache for {sheet_id}")
except Exception as e:
logger.error(f"Failed to write cache {sheet_id}: {e}")
def flush_cache():
"""Delete all cache files and reset in-memory state. Returns count of deleted files."""
global _DRIVE_SERVICE
_LAST_CHECKED.clear()
_DRIVE_SERVICE = None
deleted = 0
if CACHE_DIR.exists():
for f in CACHE_DIR.glob("*_cache.json"):
f.unlink()
deleted += 1
logger.info(f"Deleted cache file: {f.name}")
logger.info(f"Cache flushed: {deleted} files deleted, timers reset")
return deleted

View File

@@ -464,6 +464,11 @@
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>Adults Dashboard</h1>
@@ -503,7 +508,7 @@
{{ cell.text }}
{% if cell.status == 'unpaid' or cell.status == 'partial' %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}')">Pay</button>
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}', '{{ cell.raw_month }}')">Pay</button>
{% endif %}
</td>
{% endfor %}
@@ -511,7 +516,7 @@
{{ "%+d"|format(row.balance) if row.balance != 0 else "0" }}
{% if row.balance < 0 %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}')">Pay All</button>
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}', '{{ row.raw_unpaid_periods|e }}')">Pay All</button>
{% endif %}
</td>
</tr>
@@ -647,7 +652,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>
@@ -857,9 +862,13 @@
showMemberDetails(nextName);
}
}
function showPayQR(name, amount, month) {
function showPayQR(name, amount, month, rawMonth) {
const account = "{{ bank_account }}";
const message = `${name} / ${month}`;
// Convert YYYY-MM to MM/YYYY for infer_payments.py compatibility
const numericMonth = rawMonth.includes('+')
? rawMonth.split('+').map(p => p.replace(/(\d{4})-(\d{2})/, '$2/$1')).join('+')
: rawMonth.replace(/(\d{4})-(\d{2})/, '$2/$1');
const message = `${name}: ${numericMonth}`;
const qrTitle = document.getElementById('qrTitle');
const qrImg = document.getElementById('qrImg');
const qrAccount = document.getElementById('qrAccount');

View File

@@ -192,6 +192,11 @@
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>FUJ Junior Fees Dashboard</h1>
@@ -238,7 +243,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>

View File

@@ -207,6 +207,11 @@
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>FUJ Fees Dashboard</h1>
@@ -253,7 +258,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>

167
templates/flush-cache.html Normal file
View File

@@ -0,0 +1,167 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FUJ - Flush Cache</title>
<style>
body {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
background-color: #0c0c0c;
color: #cccccc;
padding: 10px;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
font-size: 11px;
line-height: 1.2;
}
h1 {
color: #00ff00;
font-family: inherit;
margin-top: 10px;
margin-bottom: 20px;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 14px;
}
.nav {
margin-bottom: 20px;
font-size: 12px;
color: #555;
display: flex;
flex-direction: column;
gap: 10px;
align-items: center;
}
.nav > div {
display: flex;
gap: 15px;
align-items: center;
}
.nav a {
color: #00ff00;
text-decoration: none;
padding: 2px 8px;
border: 1px solid #333;
}
.nav a.active {
color: #000;
background-color: #00ff00;
border-color: #00ff00;
}
.nav a:hover {
color: #fff;
border-color: #555;
}
.nav-archived a {
font-size: 10px;
color: #666;
border-color: #222;
}
.nav-archived a.active {
color: #ccc;
background-color: #333;
border-color: #555;
}
.nav-archived a:hover {
color: #999;
border-color: #444;
}
.flush-container {
background-color: #111;
border: 1px solid #333;
padding: 30px;
width: 100%;
max-width: 600px;
margin-bottom: 30px;
text-align: center;
}
.flush-btn {
font-family: inherit;
font-size: 12px;
color: #00ff00;
background-color: #1a1a1a;
border: 1px solid #00ff00;
padding: 8px 24px;
cursor: pointer;
text-transform: uppercase;
letter-spacing: 1px;
}
.flush-btn:hover {
background-color: #00ff00;
color: #000;
}
.status {
margin-bottom: 15px;
font-size: 12px;
}
.status-ok { color: #00ff00; }
.footer {
text-align: center;
color: #333;
margin-top: 20px;
font-size: 10px;
}
</style>
</head>
<body>
<div class="nav">
<div>
<a href="/adults">[Adults]</a>
<a href="/juniors">[Juniors]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Archived:</span>
<a href="/fees">[Adult - Attendance/Fees]</a>
<a href="/fees-juniors">[Junior Attendance/Fees]</a>
<a href="/reconcile">[Adult Payment Reconciliation]</a>
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache" class="active">[Flush Cache]</a>
</div>
</div>
<h1>Flush Cache</h1>
{% if flushed %}
<div class="status">
<span class="status-ok">Cache flushed successfully. {{ deleted }} file(s) deleted.</span>
</div>
{% endif %}
<div class="flush-container">
<p style="margin-bottom: 20px; color: #888;">Clears all cached Google Sheets data and resets refresh timers.</p>
<form method="POST" action="/flush-cache">
<button type="submit" class="flush-btn">[Flush Cache]</button>
</form>
</div>
<div class="footer">
{{ build_meta.tag }} | {{ build_meta.commit }} | {{ build_meta.build_date }}
</div>
</body>
</html>

View File

@@ -464,6 +464,11 @@
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>Juniors Dashboard</h1>
@@ -503,7 +508,7 @@
{{ cell.text }}
{% if cell.status == 'unpaid' or cell.status == 'partial' %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}')">Pay</button>
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}', '{{ cell.raw_month }}')">Pay</button>
{% endif %}
</td>
{% endfor %}
@@ -511,7 +516,7 @@
{{ "%+d"|format(row.balance) if row.balance != 0 else "0" }}
{% if row.balance < 0 %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}')">Pay All</button>
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}', '{{ row.raw_unpaid_periods|e }}')">Pay All</button>
{% endif %}
</td>
</tr>
@@ -628,7 +633,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>
@@ -838,9 +843,13 @@
showMemberDetails(nextName);
}
}
function showPayQR(name, amount, month) {
function showPayQR(name, amount, month, rawMonth) {
const account = "{{ bank_account }}";
const message = `${name} / ${month}`;
// Convert YYYY-MM to MM/YYYY for infer_payments.py compatibility
const numericMonth = rawMonth.includes('+')
? rawMonth.split('+').map(p => p.replace(/(\d{4})-(\d{2})/, '$2/$1')).join('+')
: rawMonth.replace(/(\d{4})-(\d{2})/, '$2/$1');
const message = `${name}: ${numericMonth}`;
const qrTitle = document.getElementById('qrTitle');
const qrImg = document.getElementById('qrImg');
const qrAccount = document.getElementById('qrAccount');

View File

@@ -196,6 +196,11 @@
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments" class="active">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>Payments Ledger</h1>
@@ -237,7 +242,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>

View File

@@ -460,6 +460,11 @@
<a href="/reconcile-juniors" class="active">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>Junior Payment Reconciliation</h1>
@@ -499,7 +504,7 @@
{{ cell.text }}
{% if cell.status == 'unpaid' or cell.status == 'partial' %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}')">Pay</button>
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}', '{{ cell.raw_month }}')">Pay</button>
{% endif %}
</td>
{% endfor %}
@@ -507,7 +512,7 @@
{{ "%+d"|format(row.balance) if row.balance != 0 else "0" }}
{% if row.balance < 0 %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}')">Pay All</button>
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}', '{{ row.raw_unpaid_periods|e }}')">Pay All</button>
{% endif %}
</td>
</tr>
@@ -631,7 +636,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>
@@ -841,9 +846,13 @@
showMemberDetails(nextName);
}
}
function showPayQR(name, amount, month) {
function showPayQR(name, amount, month, rawMonth) {
const account = "{{ bank_account }}";
const message = `${name} / ${month}`;
// Convert YYYY-MM to MM/YYYY for infer_payments.py compatibility
const numericMonth = rawMonth.includes('+')
? rawMonth.split('+').map(p => p.replace(/(\d{4})-(\d{2})/, '$2/$1')).join('+')
: rawMonth.replace(/(\d{4})-(\d{2})/, '$2/$1');
const message = `${name}: ${numericMonth}`;
const qrTitle = document.getElementById('qrTitle');
const qrImg = document.getElementById('qrImg');
const qrAccount = document.getElementById('qrAccount');

View File

@@ -460,6 +460,11 @@
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>Payment Reconciliation</h1>
@@ -499,7 +504,7 @@
{{ cell.text }}
{% if cell.status == 'unpaid' or cell.status == 'partial' %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}')">Pay</button>
onclick="showPayQR('{{ row.name|e }}', {{ cell.amount }}, '{{ cell.month|e }}', '{{ cell.raw_month }}')">Pay</button>
{% endif %}
</td>
{% endfor %}
@@ -507,7 +512,7 @@
{{ "%+d"|format(row.balance) if row.balance != 0 else "0" }}
{% if row.balance < 0 %}
<button class="pay-btn"
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}')">Pay All</button>
onclick="showPayQR('{{ row.name|e }}', {{ -row.balance }}, '{{ row.unpaid_periods|e }}', '{{ row.raw_unpaid_periods|e }}')">Pay All</button>
{% endif %}
</td>
</tr>
@@ -631,7 +636,7 @@
{% set rt = get_render_time() %}
<div class="footer"
onclick="document.getElementById('perf-details').style.display = (document.getElementById('perf-details').style.display === 'block' ? 'none' : 'block')">
render time: {{ rt.total }}s
{{ build_meta.tag }}@{{ build_meta.commit }} | render time: {{ rt.total }}s
<div id="perf-details" class="perf-breakdown">
{{ rt.breakdown }}
</div>
@@ -841,9 +846,13 @@
showMemberDetails(nextName);
}
}
function showPayQR(name, amount, month) {
function showPayQR(name, amount, month, rawMonth) {
const account = "{{ bank_account }}";
const message = `${name} / ${month}`;
// Convert YYYY-MM to MM/YYYY for infer_payments.py compatibility
const numericMonth = rawMonth.includes('+')
? rawMonth.split('+').map(p => p.replace(/(\d{4})-(\d{2})/, '$2/$1')).join('+')
: rawMonth.replace(/(\d{4})-(\d{2})/, '$2/$1');
const message = `${name}: ${numericMonth}`;
const qrTitle = document.getElementById('qrTitle');
const qrImg = document.getElementById('qrImg');
const qrAccount = document.getElementById('qrAccount');

157
templates/sync.html Normal file
View File

@@ -0,0 +1,157 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FUJ - Sync Bank Data</title>
<style>
body {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
background-color: #0c0c0c;
color: #cccccc;
padding: 10px;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
font-size: 11px;
line-height: 1.2;
}
h1 {
color: #00ff00;
font-family: inherit;
margin-top: 10px;
margin-bottom: 20px;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 14px;
}
.nav {
margin-bottom: 20px;
font-size: 12px;
color: #555;
display: flex;
flex-direction: column;
gap: 10px;
align-items: center;
}
.nav > div {
display: flex;
gap: 15px;
align-items: center;
}
.nav a {
color: #00ff00;
text-decoration: none;
padding: 2px 8px;
border: 1px solid #333;
}
.nav a.active {
color: #000;
background-color: #00ff00;
border-color: #00ff00;
}
.nav a:hover {
color: #fff;
border-color: #555;
}
.nav-archived a {
font-size: 10px;
color: #666;
border-color: #222;
}
.nav-archived a.active {
color: #ccc;
background-color: #333;
border-color: #555;
}
.nav-archived a:hover {
color: #999;
border-color: #444;
}
.output-container {
background-color: #111;
border: 1px solid #333;
padding: 15px;
width: 100%;
max-width: 1200px;
margin-bottom: 30px;
overflow-x: auto;
}
.output-container pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
color: {% if success %}#cccccc{% else %}#ff6666{% endif %};
}
.status {
margin-bottom: 15px;
font-size: 12px;
}
.status-ok { color: #00ff00; }
.status-error { color: #ff6666; }
.footer {
text-align: center;
color: #333;
margin-top: 20px;
font-size: 10px;
}
</style>
</head>
<body>
<div class="nav">
<div>
<a href="/adults">[Adults]</a>
<a href="/juniors">[Juniors]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Archived:</span>
<a href="/fees">[Adult - Attendance/Fees]</a>
<a href="/fees-juniors">[Junior Attendance/Fees]</a>
<a href="/reconcile">[Adult Payment Reconciliation]</a>
<a href="/reconcile-juniors">[Junior Payment Reconciliation]</a>
<a href="/payments">[Payments Ledger]</a>
</div>
<div class="nav-archived">
<span style="color: #666; margin-right: 5px;">Tools:</span>
<a href="/sync-bank" class="active">[Sync Bank Data]</a>
<a href="/flush-cache">[Flush Cache]</a>
</div>
</div>
<h1>Sync Bank Data</h1>
<div class="status">
{% if success %}
<span class="status-ok">Sync completed successfully.</span>
{% else %}
<span class="status-error">Sync failed - see output below.</span>
{% endif %}
</div>
<div class="output-container">
<pre>{{ output }}</pre>
</div>
<div class="footer">
{{ build_meta.tag }} | {{ build_meta.commit }} | {{ build_meta.build_date }}
</div>
</body>
</html>