Contracts, surroundings and balance sheet as pages of the notebook
Contracts: club and wage bill, the squad as a table, the negotiation as a note on the dimmed book. Surroundings: six cards with their stars, pictures and costs, the monthly sum in the page's title. Balance: figures, income against costs, the plan for the coming year, and the what-if calculation in the notebook's inks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac455eabfe
commit
1a1f43ddf7
9 files changed
+204
-454
No files matched your search
@@ -1,25 +1,30 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The balance sheet as a page of the notebook: the season's sums as figures, income against
|
||||
// costs as one bar, then every position with its share of its side. "Zukunft" plans the
|
||||
// coming year's costs; the simulation is a what-if calculation of its own.
|
||||
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_sim_) out += render_balance_simulation();
|
||||
else if (balance_future_) {
|
||||
out += "<section class=\"balance-plan\"><h2>Ausgabenplanung</h2><div class=\"balance-plan-rows\">";
|
||||
std::string out = "<div class=\"pg-page balance-native\">", status;
|
||||
if (balance_sim_) {
|
||||
out += render_balance_simulation();
|
||||
status = "Reine Rechnung – nichts wird gespeichert.";
|
||||
} else if (balance_future_) {
|
||||
out += "<div class=\"pg-body\"><section class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:4px;") + "\"><h2 class=\"pg-h\">Ausgabenplanung</h2><span class=\"pg-mut\" style=\"display:block;margin-bottom:" + pg(6) +
|
||||
";\">Geplante Ausgaben für die nächsten zwölf Monate. Ein Betrag öffnet das Zahlenfeld.</span><div class=\"pg-tbody\">";
|
||||
int i = 0;
|
||||
for (const auto &row : rows.at("plan")) {
|
||||
const auto name = row.at("name").get<std::string>();
|
||||
out += "<div class=\"balance-plan-row\"><span>" + esc(name) + "</span>" +
|
||||
btn("balance-plan", esc(number(row.at("amount").get<int64_t>() / (engine_mode_?100:finance_currency_factor(*world_)))),
|
||||
"balance-plan-value amount-trigger", "id=\"balance-plan-" + std::to_string(i) +
|
||||
"\" data-id=\"" + std::to_string(i) + "\" aria-label=\"" + esc(name + " in " + (engine_mode_?"Euro":money_unit() == "€" ? "Euro" : money_unit())) + "\" " + std::string(engine_mode_&&row.at("editable")!=true?"disabled":"")) + "</div>";
|
||||
out += "<div class=\"pg-tr\" style=\"height:" + pg(44) + ";justify-content:space-between;\"><span style=\"display:block;font-size:" + pg(15) + ";\">" + esc(name) + "</span>" +
|
||||
pg_button("balance-plan", esc(number(row.at("amount").get<int64_t>() / (engine_mode_?100:finance_currency_factor(*world_)))) + " " + esc(engine_mode_ ? "€" : money_unit()),
|
||||
"amount-trigger", "id=\"balance-plan-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\" aria-label=\"" + esc(name + " in " + (engine_mode_?"Euro":money_unit() == "€" ? "Euro" : money_unit())) + "\" " +
|
||||
std::string(engine_mode_&&row.at("editable")!=true?"disabled":"")) + "</div>";
|
||||
++i;
|
||||
}
|
||||
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>";
|
||||
out += "</div></section><div class=\"pg-col\" style=\"width:" + pg(400) + ";\"><div style=\"display:flex;\">" + pg_stat("Geplante Ausgaben", esc(balance_cash(rows.at("plan_total").get<int64_t>())), "Summe für zwölf Monate") +
|
||||
"</div><div style=\"display:flex;\">" + pg_stat("Kontostand", esc(balance_cash(rows.at("cash").get<int64_t>())), "heute") + "</div></div></div>";
|
||||
status = "Planung für zwölf Monate.";
|
||||
} 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;
|
||||
@@ -29,50 +34,43 @@ std::string App::render_balance() {
|
||||
}
|
||||
}
|
||||
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>";
|
||||
out += "<div class=\"pg-row\" style=\"" + pg_css("gap:8px;align-items:stretch;") + "\">" + pg_stat("Einnahmen", esc(balance_cash(sums[0]))) + pg_stat("Ausgaben", esc(balance_cash(sums[1]))) +
|
||||
pg_stat("Saldo der Saison", "<span class=\"" + std::string(net < 0 ? "balance-loss" : "balance-gain") + "\">" + esc(balance_cash(net)) + "</span>") + pg_stat("Kontostand", esc(balance_cash(rows.at("cash").get<int64_t>()))) +
|
||||
pg_stat("Zuschauerschnitt", esc(number(rows.at("attendance_average").get<int64_t>())), "je Heimspiel") + "</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>";
|
||||
out += "<div class=\"balance-scale\"><div class=\"in\" style=\"width:" + scalar(sums[0] * 100.0 / whole) + "%;\"><span>Einnahmen " + scalar(std::round(sums[0] * 100.0 / whole)) +
|
||||
" %</span></div><div class=\"out\" style=\"width:" + scalar(sums[1] * 100.0 / whole) + "%;\"><span>Ausgaben " + scalar(std::round(sums[1] * 100.0 / whole)) + " %</span></div></div><div class=\"pg-body\">";
|
||||
int index = 0;
|
||||
for (const auto &kind : {std::string("income"), std::string("costs")}) {
|
||||
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())));
|
||||
out += "<section class=\"pg-panel pg-col pg-grow " + kind + "\" style=\"" + pg_css("gap:4px;padding:10px 14px;") + "\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><h2 class=\"pg-h\">" +
|
||||
(kind == "income" ? "Einnahmen" : "Ausgaben") + "</h2><strong class=\"pg-h\">" + esc(balance_cash(sums[index])) + "</strong></div>";
|
||||
for (const auto &row : rows.at(kind)) {
|
||||
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 class=\"pg-row balance-row" + std::string(amount ? "" : " none") + "\" style=\"" + pg_css("gap:10px;min-height:30px;") + "\"><span class=\"pg-grow pg-nowrap\" style=\"display:block;\">" + esc(row.at("name").get<std::string>()) +
|
||||
"</span><span style=\"display:block;flex:none;width:" + pg(110) + ";\">" + pg_bar(part, kind == "income" ? "sage" : "") + "</span><span class=\"pg-mut pg-r\" style=\"display:block;flex:none;width:" + pg(44) + ";\">" +
|
||||
scalar(std::round(part)) + " %</span><strong class=\"pg-r\" style=\"display:block;flex:none;width:" + pg(150) + ";\">" + esc(balance_cash(amount)) + "</strong></div>";
|
||||
}
|
||||
out += "</div></section>";
|
||||
out += "</section>";
|
||||
++index;
|
||||
}
|
||||
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",
|
||||
"Zuschauerschnitt: " + number(rows.at("attendance_average").get<int64_t>()),
|
||||
"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 < 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 += "</div><span class=\"pg-mut\" style=\"display:block;flex:none;\">" + 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>())) + "</span>";
|
||||
status = "Gebuchte Saisonwerte.";
|
||||
}
|
||||
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>";
|
||||
// the foot: the two views, the simulation, what the engine last said
|
||||
out += "<nav class=\"pg-foot\">";
|
||||
if (!balance_sim_)
|
||||
// the view that is shown is marked; the other one switches
|
||||
for (int view = 0; view < 2; ++view) {
|
||||
const bool shown = (view == 1) == balance_future_;
|
||||
out += std::string(view ? "" : "<div class=\"pg-seg\">") + btn("balance-toggle", "<span>" + std::string(view ? "Zukunft" : "Aktuell") + "</span>", std::string(view ? "" : "first ") + (shown ? "on" : ""),
|
||||
shown ? std::string("style=\"pointer-events:none;\" aria-pressed=\"true\"") : std::string("id=\"balance-toggle\" aria-pressed=\"false\" aria-label=\"Zwischen aktueller Bilanz und Zukunftsplanung wechseln\"")) + (view ? "</div>" : "");
|
||||
}
|
||||
out += pg_button("balance-sim", balance_sim_ ? "Zurück zur Bilanz" : "Simulation", balance_sim_ ? "primary" : "", "id=\"balance-sim\"") + "<span class=\"pg-sp\"></span>";
|
||||
if (engine_mode_) out += "<span class=\"pg-status\" id=\"balance-engine-feedback\">" + esc(engine_busy_ ? engine_operation_ : !engine_balance_feedback_.empty() ? engine_balance_feedback_ : status) + "</span>";
|
||||
else out += pg_status(status);
|
||||
return out + "</nav></div>";
|
||||
}
|
||||
Reference in new issue
Block a user