diff --git a/README.md b/README.md
index 20eccb1..0fb612f 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,16 @@ In a Security Operations Center (SOC), analysts must often parse through massive
- **Automated ingestion:** reads the active sheet of an `.xlsx` workbook with openpyxl, matching columns by header name, so the column order doesn't matter.
- **Row-level validation:** bad rows are skipped and listed with their Excel row number, ticket ID and reason.
- **Exact money math:** prices, discounts and revenue use `Decimal`, rounded to cents.
-- **HTML dashboard report (default):** one self-contained file such as `reports/booking_summary_20261031_140211.html` that opens in any browser, offline. It shows the headline numbers first (net revenue, confirmed tickets, cancellation rate, loyalty share), a warning when rows were skipped, bookings by route and by class, net revenue by week, and a table of every booking you can filter by status and search. It has Export CSV and Print / Save PDF buttons, follows the system's light or dark mode, and works on a phone.
+- **HTML dashboard report (default):** one self-contained file such as `reports/booking_summary_20261031_140211.html` that opens in any browser. It contains:
+ - filters for period (all weeks, or the last few weeks), route and class;
+ - headline numbers (net revenue, confirmed tickets, cancellation rate, loyalty share), each showing its change against the previous period;
+ - a line saying whether every row was used;
+ - weekly net revenue, with the compared weeks shaded and the high and low weeks labelled;
+ - cancellation rate by route, measured against the average;
+ - bookings by route and by class;
+ - a bookings table you can sort, search and page through.
+
+ It has Export CSV and Print / Save PDF buttons and a light/dark switch, uses the Space Mono font (falling back to the system monospace font offline), and works on a phone.
- **Text report:** `--format txt` (or `both`) writes the same figures as plain text.
- **Skipped rows:** listed in the report and saved next to it as `..._skipped_rows.csv`.
- **Privacy by default:** passenger names are masked (`Maria Gonzalez` becomes `M. G•••••••`) and full names are never written to the file unless you pass `--show-names`. Spreadsheet text is HTML-escaped, and CSV cells that could run as spreadsheet formulas are neutralised.
@@ -54,7 +63,7 @@ python samples/make_sample.py # regenerate the sample workbook
`Project.ipynb` is the original notebook version, kept for reference. The maintained code is in `report_tool/`.
### Web app (Vercel)
-`app.py` is a small Flask app: upload an `.xlsx` (up to 4 MB) and it returns the HTML dashboard, or open `/sample` to see the sample report. Uploads are processed in a temporary file that is deleted straight away; nothing is stored. Passenger names stay masked unless the "Show full passenger names" box is ticked.
+`app.py` is a small Flask app. The landing page explains the tool, shows a preview built from the sample file, and takes an `.xlsx` upload (up to 4 MB, drag and drop or browse) that returns the HTML dashboard. `/sample` shows the sample report and `/template.xlsx` downloads a blank workbook with the right headers. Upload problems (wrong file type, missing columns, no usable rows) are explained in plain words with how to fix them. The page uses the Space Mono font and has a light/dark switch that remembers your choice. Uploads are processed in a temporary file that is deleted straight away; nothing is stored. Passenger names stay masked unless the "Show full passenger names" box is ticked.
```bash
flask --app app run # http://127.0.0.1:5000
diff --git a/app.py b/app.py
index 55210ba..458a5dd 100644
--- a/app.py
+++ b/app.py
@@ -7,26 +7,135 @@
from __future__ import annotations
import datetime as dt
+import functools
import hashlib
+import io
import tempfile
from pathlib import Path
-from flask import Flask, Response, render_template, request
+from flask import Flask, Response, render_template, request, send_file
+from openpyxl import Workbook
from werkzeug.exceptions import RequestEntityTooLarge
+from report_tool.charts import weekly_revenue
from report_tool.html_report import render_html
-from report_tool.loader import LoadResult, WorkbookError, load_bookings
+from report_tool.loader import (
+ LoadResult,
+ MissingColumnsError,
+ NotAWorkbookError,
+ WorkbookError,
+ load_bookings,
+)
from report_tool.summary import summarize
SAMPLE = Path(__file__).parent / "samples" / "bookings_sample.xlsx"
MAX_UPLOAD_MB = 4 # Vercel functions accept request bodies up to 4.5 MB
-app = Flask(__name__)
+# (header, required, example) shown on the landing page and used for the template download.
+COLUMNS = [
+ ("TicketID", True, "TB-1042"),
+ ("PassengerName", True, "Maria Gonzalez"),
+ ("Route", True, "Toronto–Montréal"),
+ ("Class", True, "Economy"),
+ ("Price", True, "85.50 or $85.50"),
+ ("Status", True, "Confirmed / Cancelled"),
+ ("Date", False, "2026-09-08"),
+ ("DiscountApplied", False, "10 or 10%"),
+ ("LoyaltyMember", False, "Yes / No"),
+]
+TEMPLATE_ROWS = [
+ [
+ "TB-1042",
+ "Maria Gonzalez",
+ "Toronto–Montréal",
+ "Economy",
+ 85.5,
+ "Confirmed",
+ dt.date(2026, 9, 8),
+ 10,
+ "Yes",
+ ],
+ [
+ "TB-1043",
+ "Sam Patel",
+ "Ottawa–Québec City",
+ "Business",
+ 142,
+ "Cancelled",
+ dt.date(2026, 9, 9),
+ 0,
+ "No",
+ ],
+]
+
+app = Flask(__name__, template_folder="report_tool/templates")
app.config["MAX_CONTENT_LENGTH"] = MAX_UPLOAD_MB * 1024 * 1024
-def upload_page(error: str | None = None, status: int = 200) -> tuple[str, int]:
- return render_template("upload.html", error=error, max_mb=MAX_UPLOAD_MB), status
+@functools.cache
+def sample_preview() -> dict:
+ """Figures from the sample workbook for the small dashboard preview on the landing page."""
+ summary = summarize(load_bookings(SAMPLE).bookings)
+ top = summary.routes_by_volume()[:3]
+ widest = max((counts.total for _, counts in top), default=1)
+ routes = [
+ {
+ "name": name,
+ "confirmed_pct": round(100 * counts.confirmed / widest, 1),
+ "cancelled_pct": round(100 * counts.cancelled / widest, 1),
+ "cancelled": counts.cancelled,
+ }
+ for name, counts in top
+ ]
+ series = weekly_revenue(summary.confirmed)
+ spark = ""
+ if len(series) > 1:
+ peak = float(max(value for _, value in series)) or 1
+ step = 300 / (len(series) - 1)
+ spark = " ".join(
+ f"{round(i * step, 1)},{round(64 - 58 * float(value) / peak, 1)}"
+ for i, (_, value) in enumerate(series)
+ )
+ return {
+ "source": SAMPLE.name,
+ "revenue": f"${summary.net_revenue:,.2f}",
+ "cancel_rate": f"{summary.cancellation_rate:.1%}",
+ "routes": routes,
+ "spark": spark,
+ }
+
+
+def landing_page(error: dict | None = None, status: int = 200) -> tuple[str, int]:
+ page = render_template(
+ "landing.html",
+ error=error,
+ max_mb=MAX_UPLOAD_MB,
+ preview=sample_preview(),
+ columns=COLUMNS,
+ )
+ return page, status
+
+
+def problem(title: str, text: str, template_link: bool = False) -> dict:
+ return {"title": title, "text": text, "template_link": template_link}
+
+
+def explain(exc: WorkbookError, name: str) -> dict:
+ """Turn a loader error into a message that says what's wrong and how to fix it."""
+ if isinstance(exc, NotAWorkbookError):
+ return problem(
+ f"{name} isn't a readable Excel file.",
+ "Open it in Excel and choose Save As › Excel Workbook (.xlsx), then upload it again.",
+ )
+ if isinstance(exc, MissingColumnsError):
+ plural = "s" if len(exc.missing) > 1 else ""
+ return problem(
+ f"{name} is missing the {', '.join(exc.missing)} column{plural}.",
+ f"Its first row has: {', '.join(exc.found) or 'nothing'}. "
+ "Add the missing header, or start from the template.",
+ template_link=True,
+ )
+ return problem(f"{name} couldn't be read.", str(exc))
def report_response(result: LoadResult, source: str, data: bytes, show_names: bool) -> Response:
@@ -37,6 +146,7 @@ def report_response(result: LoadResult, source: str, data: bytes, show_names: bo
source_sha256=hashlib.sha256(data).hexdigest(),
generated_at=dt.datetime.now(dt.UTC).replace(tzinfo=None),
show_names=show_names,
+ upload_url="/",
)
response = Response(html, mimetype="text/html")
response.headers["Cache-Control"] = "no-store"
@@ -51,26 +161,39 @@ def build_report(data: bytes, source: str, show_names: bool) -> Response | tuple
try:
result = load_bookings(handle.name)
except WorkbookError as exc:
- message = str(exc).replace(handle.name, source)
- return upload_page(message, 400)
+ exc.args = (str(exc).replace(handle.name, source),)
+ return landing_page(explain(exc, source), 400)
if not result.bookings:
- return upload_page(f"No valid bookings found in {source}. Check the columns and try again.", 400)
+ return landing_page(
+ problem(
+ f"None of the rows in {source} could be used.",
+ "Check that Price is a number and Status is Confirmed or Cancelled.",
+ template_link=True,
+ ),
+ 400,
+ )
return report_response(result, source, data, show_names)
@app.get("/")
def index():
- return upload_page()
+ return landing_page()
@app.post("/report")
def report():
upload = request.files.get("workbook")
if upload is None or not upload.filename:
- return upload_page("Choose an .xlsx file to upload.", 400)
+ return landing_page(problem("No file chosen.", "Choose an .xlsx file to upload."), 400)
name = Path(upload.filename).name
if not name.lower().endswith(".xlsx"):
- return upload_page("Only Excel .xlsx files are supported.", 400)
+ return landing_page(
+ problem(
+ f"{name} isn't an .xlsx file.",
+ "Only Excel .xlsx files are supported. In Excel, choose Save As › Excel Workbook (.xlsx).",
+ ),
+ 400,
+ )
return build_report(upload.read(), name, show_names=request.form.get("show_names") == "on")
@@ -80,6 +203,33 @@ def sample():
return report_response(load_bookings(SAMPLE), SAMPLE.name, data, show_names=False)
+@app.get("/template.xlsx")
+def template():
+ workbook = Workbook()
+ sheet = workbook.active
+ sheet.title = "Bookings"
+ sheet.append([name for name, _, _ in COLUMNS])
+ for row in TEMPLATE_ROWS:
+ sheet.append(row)
+ for cell in sheet["G"][1:]:
+ cell.number_format = "yyyy-mm-dd"
+ buffer = io.BytesIO()
+ workbook.save(buffer)
+ buffer.seek(0)
+ return send_file(
+ buffer,
+ mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ as_attachment=True,
+ download_name="railstat_template.xlsx",
+ )
+
+
@app.errorhandler(RequestEntityTooLarge)
def too_large(_error):
- return upload_page(f"That file is larger than {MAX_UPLOAD_MB} MB.", 413)
+ return landing_page(
+ problem(
+ f"That file is larger than {MAX_UPLOAD_MB} MB.",
+ "Remove unused sheets or rows and try again.",
+ ),
+ 413,
+ )
diff --git a/pyproject.toml b/pyproject.toml
index 202c5a9..ce6ac7a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "report-tool"
-version = "1.1.0"
+version = "1.2.0"
description = "Turn a train bookings Excel workbook into a validated HTML or text report."
readme = "README.md"
requires-python = ">=3.11"
@@ -20,7 +20,7 @@ report-tool = "report_tool.cli:main"
packages = ["report_tool"]
[tool.setuptools.package-data]
-report_tool = ["templates/*.j2"]
+report_tool = ["templates/*.j2", "templates/*.html"]
[tool.pytest.ini_options]
testpaths = ["tests"]
diff --git a/report_tool/__init__.py b/report_tool/__init__.py
index 6a85f71..b923da0 100644
--- a/report_tool/__init__.py
+++ b/report_tool/__init__.py
@@ -1,3 +1,3 @@
"""Turn a train bookings Excel workbook into a summary report."""
-__version__ = "1.1.0"
+__version__ = "1.2.0"
diff --git a/report_tool/charts.py b/report_tool/charts.py
index c9598ad..5399240 100644
--- a/report_tool/charts.py
+++ b/report_tool/charts.py
@@ -1,80 +1,14 @@
-"""Chart geometry computed in Python so the HTML report needs no charting library."""
+"""Series helpers shared by the web app's preview chart."""
from __future__ import annotations
import datetime as dt
-import math
from collections import defaultdict
-from dataclasses import dataclass
from decimal import Decimal
from report_tool.loader import Booking
-def nice_max(value: float) -> float:
- """Round up to 1, 2, 2.5, 5 or 10 times a power of ten, so axis ticks read cleanly."""
- if value <= 0:
- return 1
- magnitude = 10 ** math.floor(math.log10(value))
- for step in (1, 2, 2.5, 5, 10):
- if value <= step * magnitude:
- return step * magnitude
- return 10 * magnitude
-
-
-def nice_axis(value: float, count: int = 4, integer: bool = False) -> float:
- """Axis maximum whose `count` equal steps are round numbers (whole numbers when `integer`)."""
- step = nice_max(value / count) if value > 0 else 1
- if integer:
- step = max(1, math.ceil(step))
- return step * count
-
-
-def ticks(maximum: float, count: int = 4) -> list[float]:
- return [maximum * i / count for i in range(count + 1)]
-
-
-def percent(value: float, maximum: float) -> float:
- return round(100 * value / maximum, 2) if maximum else 0.0
-
-
-@dataclass(frozen=True)
-class WeekPoint:
- week_start: dt.date
- revenue: Decimal
- x: float
- y: float
- labelled: bool = True
-
-
-@dataclass(frozen=True)
-class LineChart:
- points: list[WeekPoint]
- y_ticks: list[tuple[float, float]] # (value, y position)
- width: int
- height: int
- left: int
- top: int
- bottom: int
-
- @property
- def polyline(self) -> str:
- return " ".join(f"{p.x},{p.y}" for p in self.points)
-
- @property
- def area_path(self) -> str:
- first, last = self.points[0], self.points[-1]
- return (
- f"M{first.x} {self.bottom} L"
- + " L".join(f"{p.x} {p.y}" for p in self.points)
- + (f" L{last.x} {self.bottom} Z")
- )
-
- @property
- def peak(self) -> WeekPoint:
- return max(self.points, key=lambda p: p.revenue)
-
-
def weekly_revenue(bookings: list[Booking]) -> list[tuple[dt.date, Decimal]]:
"""Net revenue of confirmed, dated bookings per week (weeks start Monday), gaps filled with zero."""
totals: dict[dt.date, Decimal] = defaultdict(lambda: Decimal("0.00"))
@@ -89,31 +23,3 @@ def weekly_revenue(bookings: list[Booking]) -> list[tuple[dt.date, Decimal]]:
series.append((week, totals.get(week, Decimal("0.00"))))
week += dt.timedelta(weeks=1)
return series
-
-
-def line_chart(
- series: list[tuple[dt.date, Decimal]], width: int = 640, height: int = 240
-) -> LineChart | None:
- if len(series) < 2:
- return None
- left, right, top, bottom = 72, width - 24, 16, height - 44
- y_max = nice_axis(float(max(value for _, value in series)))
- step = (right - left) / (len(series) - 1)
-
- def y_of(value: float) -> float:
- return round(bottom - (bottom - top) * value / y_max, 1)
-
- every = math.ceil(len(series) / 8) # at most 8 date labels on the axis
- points = [
- WeekPoint(week, value, round(left + i * step, 1), y_of(float(value)), labelled=i % every == 0)
- for i, (week, value) in enumerate(series)
- ]
- return LineChart(
- points=points,
- y_ticks=[(value, y_of(value)) for value in ticks(y_max)],
- width=width,
- height=height,
- left=left,
- top=top,
- bottom=bottom,
- )
diff --git a/report_tool/html_report.py b/report_tool/html_report.py
index aef2c09..0ed522a 100644
--- a/report_tool/html_report.py
+++ b/report_tool/html_report.py
@@ -1,15 +1,18 @@
-"""Render a BookingSummary as one self-contained HTML file (no server, no external assets)."""
+"""Render a BookingSummary as one self-contained HTML dashboard.
+
+The headline numbers are rendered here. The bookings are also embedded as JSON (names already
+masked unless asked otherwise) so the page can re-compute figures, charts and the table in the
+browser when the reader filters by period, route or class.
+"""
from __future__ import annotations
import datetime as dt
-from dataclasses import dataclass
from decimal import Decimal
from jinja2 import Environment, PackageLoader, select_autoescape
from report_tool import __version__
-from report_tool.charts import line_chart, nice_axis, percent, ticks, weekly_revenue
from report_tool.loader import Booking, SkippedRow
from report_tool.privacy import display_name
from report_tool.render import money
@@ -28,46 +31,55 @@ def _number(value: float) -> str:
return f"{value:,.0f}" if float(value).is_integer() else f"{value:,.1f}"
-def _short_money(value: float) -> str:
- if value >= 1000:
- return f"${value / 1000:,.1f}k".replace(".0k", "k")
- return f"${value:,.0f}"
+_env.filters["number"] = _number
-def _day(value: dt.date) -> str:
- return f"{value.day} {value:%b}"
+def week_start(day: dt.date) -> dt.date:
+ """Monday of the week containing `day`."""
+ return day - dt.timedelta(days=day.weekday())
-_env.filters["number"] = _number
-_env.filters["day"] = _day
-_env.filters["short_money"] = _short_money
+def all_weeks(bookings: list[Booking]) -> list[dt.date]:
+ """Every week (Monday) from the first dated booking to the last, gaps included."""
+ dated = [week_start(b.date) for b in bookings if b.date]
+ if not dated:
+ return []
+ week, last = min(dated), max(dated)
+ weeks = []
+ while week <= last:
+ weeks.append(week)
+ week += dt.timedelta(weeks=1)
+ return weeks
-@dataclass(frozen=True)
-class Row:
- ticket_id: str
- passenger: str
- route: str
- ticket_class: str
- net_price: Decimal | None
- date: dt.date | None
- status: str
+def _cents(amount: Decimal) -> int:
+ return int((amount * 100).to_integral_value())
-def _rows(bookings: list[Booking], show_names: bool) -> list[Row]:
+def dashboard_data(bookings: list[Booking], show_names: bool) -> dict:
+ """The bookings in the compact shape the page's script reads. Money is in whole cents."""
+ weeks = all_weeks(bookings)
+ index = {week: i for i, week in enumerate(weeks)}
ordered = sorted(bookings, key=lambda b: (b.date or dt.date.max, b.row))
- return [
- Row(
- ticket_id=b.ticket_id,
- passenger=display_name(b.passenger, show_names),
- route=b.route,
- ticket_class=b.ticket_class,
- net_price=b.net_price if b.status == "confirmed" else None,
- date=b.date,
- status=b.status,
- )
- for b in ordered
- ]
+ return {
+ "weeks": [week.isoformat() for week in weeks],
+ "bookings": [
+ {
+ "t": b.ticket_id,
+ "p": display_name(b.passenger, show_names),
+ "r": b.route,
+ "c": b.ticket_class,
+ "s": b.status,
+ "d": b.date.isoformat() if b.date else None,
+ "w": index[week_start(b.date)] if b.date else None,
+ "price": _cents(b.price),
+ "disc": float(b.discount_pct),
+ "net": _cents(b.net_price),
+ "loy": b.loyalty,
+ }
+ for b in ordered
+ ],
+ }
def render_html(
@@ -78,23 +90,9 @@ def render_html(
generated_at: dt.datetime,
show_names: bool = False,
skipped_csv_name: str | None = None,
+ upload_url: str | None = None,
) -> str:
- routes = summary.routes_by_volume()
- route_max = nice_axis(max((counts.total for _, counts in routes), default=0), integer=True)
- route_bars = [
- {
- "name": name,
- "confirmed": counts.confirmed,
- "cancelled": counts.cancelled,
- "confirmed_pct": percent(counts.confirmed, route_max),
- "cancelled_pct": percent(counts.cancelled, route_max),
- }
- for name, counts in routes
- ]
- classes = summary.by_class.most_common()
- class_max = nice_axis(max((count for _, count in classes), default=0), integer=True)
- class_bars = [{"name": name, "count": count, "pct": percent(count, class_max)} for name, count in classes]
-
+ """`upload_url` is set by the web app to show an "Upload another file" link."""
loyalty_known = summary.loyalty_members + summary.non_loyalty_members
template = _env.get_template("report.html.j2")
return template.render(
@@ -106,15 +104,11 @@ def render_html(
source_hash=f"{source_sha256[:4]}…{source_sha256[-4:]}",
generated_at=generated_at,
rows_read=summary.valid_bookings + len(skipped),
- loyalty_pct=percent(summary.loyalty_members, loyalty_known),
+ loyalty_pct=100 * summary.loyalty_members / loyalty_known if loyalty_known else 0,
loyalty_known=loyalty_known,
- route_bars=route_bars,
- route_ticks=ticks(route_max),
- class_bars=class_bars,
- class_ticks=ticks(class_max),
- line=line_chart(weekly_revenue(summary.confirmed)),
- rows=_rows(summary.confirmed + summary.cancelled, show_names),
+ data=dashboard_data(summary.confirmed + summary.cancelled, show_names),
show_names=show_names,
+ upload_url=upload_url,
version=__version__,
)
diff --git a/report_tool/loader.py b/report_tool/loader.py
index 27fbd85..d20ebea 100644
--- a/report_tool/loader.py
+++ b/report_tool/loader.py
@@ -24,6 +24,14 @@
"loyalty": ("loyaltymember", "loyalty member", "loyalty"),
}
REQUIRED = ("ticket_id", "passenger", "route", "ticket_class", "price", "status")
+LABELS = {
+ "ticket_id": "TicketID",
+ "passenger": "PassengerName",
+ "route": "Route",
+ "ticket_class": "Class",
+ "price": "Price",
+ "status": "Status",
+}
STATUSES = {"confirmed": "confirmed", "cancelled": "cancelled", "canceled": "cancelled"}
YES = {"yes", "y", "true", "1"}
@@ -34,6 +42,19 @@ class WorkbookError(Exception):
"""The workbook can't be read, or it's missing required columns."""
+class NotAWorkbookError(WorkbookError):
+ """The file isn't a readable .xlsx workbook."""
+
+
+class MissingColumnsError(WorkbookError):
+ """The header row lacks one or more required columns."""
+
+ def __init__(self, message: str, missing: list[str], found: list[str]):
+ super().__init__(message)
+ self.missing = missing
+ self.found = found
+
+
@dataclass(frozen=True)
class Booking:
row: int
@@ -87,10 +108,15 @@ def map_headers(header_row: tuple[object, ...]) -> dict[str, int]:
if spelling in found:
mapping[name] = found[spelling]
break
- missing = [COLUMNS[name][0] for name in REQUIRED if name not in mapping]
+ missing = [LABELS[name] for name in REQUIRED if name not in mapping]
if missing:
- raise WorkbookError(
- "Missing required column(s): " + ", ".join(missing) + ". Check the first row of the sheet."
+ present = [str(cell).strip() for cell in header_row if cell is not None and str(cell).strip()]
+ found = ", ".join(present) if present else "nothing"
+ raise MissingColumnsError(
+ f"Missing required column{'s' if len(missing) > 1 else ''}: {', '.join(missing)}. "
+ f"The first row has: {found}.",
+ missing=missing,
+ found=present,
)
return mapping
@@ -212,7 +238,7 @@ def load_bookings(path: str | Path) -> LoadResult:
try:
workbook = openpyxl.load_workbook(path, read_only=True, data_only=True)
except (InvalidFileException, zipfile.BadZipFile, KeyError, OSError) as exc:
- raise WorkbookError(f"Could not open {path} as an Excel .xlsx workbook ({exc}).") from exc
+ raise NotAWorkbookError(f"Could not open {path} as an Excel .xlsx workbook ({exc}).") from exc
try:
rows = workbook.active.iter_rows(values_only=True)
diff --git a/report_tool/templates/_theme.html b/report_tool/templates/_theme.html
new file mode 100644
index 0000000..4969e32
--- /dev/null
+++ b/report_tool/templates/_theme.html
@@ -0,0 +1,62 @@
+{# Shared look: Space Mono, light/dark tokens, and the theme switcher. Included in
. #}
+
+
+
+
+
diff --git a/report_tool/templates/_theme_button.html b/report_tool/templates/_theme_button.html
new file mode 100644
index 0000000..3bbc487
--- /dev/null
+++ b/report_tool/templates/_theme_button.html
@@ -0,0 +1,28 @@
+
+
+
+ Theme
+
+
diff --git a/report_tool/templates/landing.html b/report_tool/templates/landing.html
new file mode 100644
index 0000000..6b115af
--- /dev/null
+++ b/report_tool/templates/landing.html
@@ -0,0 +1,379 @@
+
+
+
+
+
+Railstat · Turn a bookings spreadsheet into a dashboard
+
+{% include "_theme.html" %}
+
+
+
+
+
+
+
+
+
Turn a bookings spreadsheet into a dashboard in seconds
+
Upload an Excel export. Railstat checks every row, flags the ones it can't read, and builds a report of revenue, cancellations and routes you can filter, print or share.
+
+
+
+
+ Nothing is stored
+ Names masked by default
+ Open source
+
+
+
+
+
What you get · from the sample file
+
+
Train bookings report {{ preview.source }}
+
+
Net revenue {{ preview.revenue }}
+
Cancellation rate {{ preview.cancel_rate }}
+
+
+ {% for r in preview.routes %}
+
{{ r.name }}
+
{% if r.cancelled %}
{% endif %}
+ {% endfor %}
+
+ {% if preview.spark %}
+
+ {% endif %}
+
Confirmed Cancelled
+
+
Open the full sample report
+
+
+
+
+ How it works
+
+
1 Export your bookings Save the sheet from your booking system or Excel as .xlsx. Column order doesn't matter.
+
2 Upload it Every row is checked. Rows Railstat can't read are set aside and listed, never silently dropped.
+
3 Read, filter, share See revenue, cancellations, routes and weekly trends. Print it, save a PDF or export CSV.
+
+
+
+
+ What's in the report
+
+
Headline numbers first Net revenue, confirmed tickets, cancellation rate and loyalty share at the top.
+
A skipped-rows report Each unreadable row with its Excel row number and the reason.
+
Charts that compare Routes busiest first, tickets by class, revenue week by week.
+
A table you can search Filter by status, search any field, export what you see.
+
+
+
+
+
+
+
What your file needs
+
One sheet with a header row. Headers are matched without caring about case, spaces or order, so “Ticket ID” and “ticketid” both work.
+
+
+
+
+ Column Needed Example
+
+ {% for name, required, example in columns %}
+ {{ name }} {{ "Required" if required else "Optional" }} {{ example }}
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/report_tool/templates/report.html.j2 b/report_tool/templates/report.html.j2
index bd4027d..e218566 100644
--- a/report_tool/templates/report.html.j2
+++ b/report_tool/templates/report.html.j2
@@ -5,163 +5,250 @@
Train bookings report · {{ source }}
+{% include "_theme.html" %}
-