The balance sheet with shares and a what-if calculation; season counts in the line-up

The balance shows its sums as numerals and every position with its share. A
calculation with sliders for ticket price, crowd and home matches ahead draws where
the cash goes; it is arithmetic on the booked figures, not a forecast. The squad read
carries goals, assists and matches of the running season from the almanac, and the
line-up shows them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-15 00:00:42 +01:00
1 parent c560268373
commit d75617052f
11 files changed
+246 -11

No files matched your search

+40 -9
View File
@@ -3,7 +3,8 @@ std::string App::render_balance() {
const auto rows = balance_rows();
if (!rows.value("ok", false)) throw editor::Error("Die Bilanzdaten sind ungültig.");
std::string out = "<div class=\"balance-native\">";
if (balance_future_) {
if (balance_sim_) out += render_balance_simulation();
else if (balance_future_) {
out += "<section class=\"balance-plan\"><h2>Ausgabenplanung</h2><div class=\"balance-plan-rows\">";
int i = 0;
for (const auto &row : rows.at("plan")) {
@@ -17,18 +18,47 @@ std::string App::render_balance() {
out += "</div></section><p class=\"balance-plan-total\"><span>Geplante Ausgaben</span><span>" +
esc(balance_cash(rows.at("plan_total").get<int64_t>())) + "</span></p>";
} else {
// the season's money at a glance: the sums as numerals, then every position with its
// share of its side as a bar
int64_t sums[2] = {0, 0};
{
int side = 0;
for (const auto &kind : {std::string("income"), std::string("costs")}) {
for (const auto &row : rows.at(kind)) sums[side] += std::max<int64_t>(0, row.at("amount").get<int64_t>());
++side;
}
}
const int64_t net = rows.at("balance").get<int64_t>();
const std::array<std::array<std::string, 3>, 5> tiles{{
{balance_cash(sums[0]), "Einnahmen", ""}, {balance_cash(sums[1]), "Ausgaben", ""},
{balance_cash(net), "Saldo der Saison", net < 0 ? "loss" : "gain"},
{balance_cash(rows.at("cash").get<int64_t>()), "Kontostand", ""},
{number(rows.at("attendance_average").get<int64_t>()), "Zuschauerschnitt",
""}}};
for (size_t i = 0; i < tiles.size(); ++i)
out += "<div class=\"balance-tile " + tiles[i][2] + "\" style=\"" + rect(double(i) * 526.4, 0, 506.4, 200) + "\"><strong>" + esc(tiles[i][0]) + "</strong><span>" + tiles[i][1] + "</span></div>";
// income against costs as one bar
const double whole = double(std::max<int64_t>(1, sums[0] + sums[1]));
out += "<div class=\"balance-scale\"><div class=\"in\" style=\"width:" + scalar(sums[0] * 100.0 / whole) + "%;\"><span>Einnahmen " + scalar(std::round(sums[0] * 1000.0 / whole) / 10) +
" %</span></div><div class=\"out\" style=\"width:" + scalar(sums[1] * 100.0 / whole) + "%;\"><span>Ausgaben " + scalar(std::round(sums[1] * 1000.0 / whole) / 10) + " %</span></div></div>";
int index = 0;
for (const auto &kind : {std::string("income"), std::string("costs")}) {
out += "<section class=\"balance-panel\" style=\"left:" + std::to_string(index++ * 1322) +
"dp;\"><h2>" + (kind == "income" ? "Einnahmen" : "Ausgaben") + "</h2><div class=\"balance-table\">"
"<div class=\"balance-row balance-head\"><span>Position</span><span>Betrag</span></div>";
int n = 0;
const int64_t sum = std::max<int64_t>(1, sums[index]);
out += "<section class=\"balance-panel " + kind + "\" style=\"left:" + std::to_string(index++ * 1322) +
"dp;\"><h2>" + (kind == "income" ? "Einnahmen" : "Ausgaben") + "</h2><div class=\"balance-table\">";
// the rows share the panel's height
const double row_height = std::min(170.0, 1206.0 / double(std::max<size_t>(1, rows.at(kind).size())));
for (const auto &row : rows.at(kind)) {
out += "<div class=\"balance-row" + std::string(n++ % 2 == 0 ? " striped" : "") + "\"><span>" +
esc(row.at("name").get<std::string>()) + "</span><span>" + esc(balance_cash(row.at("amount").get<int64_t>())) + "</span></div>";
const int64_t amount = row.at("amount").get<int64_t>();
const double part = std::clamp(double(std::max<int64_t>(0, amount)) * 100.0 / double(sum), 0.0, 100.0);
out += "<div class=\"balance-row" + std::string(amount ? "" : " none") + "\" style=\"height:" + scalar(row_height) + "dp;\"><span class=\"name\">" + esc(row.at("name").get<std::string>()) +
"</span><div class=\"balance-bar\"><div style=\"width:" + scalar(part) + "%;\"></div></div><span class=\"share\">" + (amount ? scalar(std::round(part)) + " %" : std::string()) +
"</span><span class=\"sum\">" + esc(balance_cash(amount)) + "</span></div>";
}
out += "</div></section>";
}
out += "<p class=\"balance-games\">" + esc(number(rows.at("league_home_games").get<int64_t>()) + " Liga-Heimspiele · " + number(rows.at("other_home_games").get<int64_t>()) +
" sonstige Heimspiele · Eintrittspreis " + balance_cash(rows.at("ticket").get<int64_t>())) + "</p>";
const std::array<std::string, 6> values = {
number(rows.at("league_home_games").get<int64_t>()) + " Liga-Heimspiele",
number(rows.at("other_home_games").get<int64_t>()) + " sonstige Heimspiele",
@@ -36,11 +66,12 @@ std::string App::render_balance() {
"Eintrittspreis: " + balance_cash(rows.at("ticket").get<int64_t>()),
"Kontostand: " + balance_cash(rows.at("cash").get<int64_t>()),
"Saldo: " + balance_cash(rows.at("balance").get<int64_t>())};
for (int i = 0; i < 6; ++i)
for (int i = 0; i < 0; ++i)
out += "<p class=\"balance-summary-item" + std::string(i == 5 ? " balance-net" : "") + (engine_mode_&&(i==4||i==5)?" "+money_classes(rows.at(i==4?"cash":"balance").get<int64_t>()):std::string()) + "\" style=\"" +
rect(26 + (i % 2) * 1310, 1526 + (i / 2) * 68, 1250, 38) + "\">" + esc(values[size_t(i)]) + "</p>";
}
out += btn("balance-toggle", "<span>" + std::string(balance_future_ ? "Zukunft" : "Aktuell") +
out += btn("balance-sim", balance_sim_ ? "Zurück zur Bilanz" : "Simulation", "balance-sim-button report-reset", "id=\"balance-sim\"");
if (!balance_sim_) out += btn("balance-toggle", "<span>" + std::string(balance_future_ ? "Zukunft" : "Aktuell") +
"</span><span class=\"balance-cycle\" aria-hidden=\"true\"><span class=\"cycle-line cycle-top\"></span><span class=\"cycle-line cycle-bottom\"></span><span class=\"cycle-head cycle-right\"></span><span class=\"cycle-head cycle-left\"></span></span>", "balance-toggle report-reset",
"id=\"balance-toggle\" aria-label=\"Zwischen aktueller Bilanz und Zukunftsplanung wechseln\"");
return out + (engine_mode_?"<p id=\"balance-engine-feedback\" style=\"position:absolute;left:0;right:0;bottom:106dp;font-size:28dp;line-height:28dp;\">"+esc(engine_busy_?engine_operation_:engine_balance_feedback_)+"</p>":"") + "</div>";