F6: finanza completa, correzioni della revisione

Corregge i rilievi della revisione della finanza completa (ADR 0019).

- Rating: il margine resta neutro finché la finestra non è piena e ha meno
  di finance.ratingMinRevenueMonths (3) mesi con ricavi, così il primo
  incasso piccolo dopo mesi di soli costi non fa perdere tre o quattro
  gradini (e non fissa uno spread pessimo per dieci anni); senza ricavi e
  in perdita il margine è il minimo. Corretta l'affermazione dell'ADR.
- Avvisi di cassa negativa dopo finance.negativeCashNoticeDays (3) giorni
  di fila e notizia di rientro solo dopo quel primo avviso: una cassa che
  oscilla intorno a zero non riempie le notizie.
- Spiegazione del rating: se il punteggio vale già il gradino sopra lo dice
  (NextAlreadyMet, ScoreRating) senza obiettivi negativi né leve infinite
  sul filo; il rimborso indicato è segnato come non possibile oggi se
  supera la cassa o il residuo dei prestiti (RepayAffordable).
- Nuovi concorrenti: la quota dei trasporti usa Company.TransportRevenue
  (tariffe, noli, contratti), non dividendi incassati né commercio.
- Client: barra del conto alla rovescia solo con lo scoperto, frasi intere
  con segnaposto in strings.csv, testo distinto per bancarotta e
  amministrazione controllata; ClimbOutlook.LoansAllowed allineato.
- PROTOCOL.md: tabella dei valori di LedgerEntry e campi nuovi di
  FinanceReport; ServerTests non dipende più dal cambio di mese.

Refs #39.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-08 13:25:06 +01:00
1 parent 9bf64b9286
commit 1f8830337a
20 files changed
+354 -97

No files matched your search

@@ -609,11 +609,6 @@ Anni,,Years
patrimonio netto,,net worth
Bancarotta dichiarata,,Bankruptcy declared
La compagnia non ha riportato la cassa sopra zero entro il limite della difficoltà.,,The company did not bring its cash back above zero within the difficulty limit.
Cassa negativa da,,Cash negative for
bancarotta tra,,bankruptcy in
Scoperto,,Overdraft
Il limite della difficoltà è di,,The difficulty limit is
"riporta la cassa sopra zero con un prestito, vendendo treni o riducendo i costi.",,"bring cash back above zero with a loan, by selling trains or by cutting costs."
in corso,,in progress
finora,,so far
Voce,,Item
@@ -654,13 +649,8 @@ patrimonio non positivo,,non-positive equity
Leva (debiti / patrimonio netto),,Leverage (debt / net worth)
In bancarotta il rating è D finché la situazione non si risolve.,,While bankrupt the rating is D until the situation is resolved.
È il rating più alto: i prestiti costano il minimo.,,This is the highest rating: loans cost the least.
un margine di almeno,,a margin of at least
rimborsando,,by repaying
una leva non oltre,,leverage no higher than
serve migliorare insieme margine e leva,,margin and leverage must improve together
oppure,,or
Per salire a,,To rise to
serve un punteggio di,,a score of
Punteggio da,,Score from
Tasso,,Rate
componente,,component
@@ -672,6 +662,18 @@ Rata mensile,,Monthly payment
interessi,,interest
scadenza,,maturity
Estingui,,Pay off
Un nuovo prestito costa il,,A new loan costs
base,,base
rating,,rating
La cassa è tornata positiva,,Cash is back above zero
"Dopo {0} di cassa negativa il conto alla rovescia della bancarotta si azzera domani.",,"After {0} of negative cash, the bankruptcy countdown resets tomorrow."
Cassa negativa da oggi: bancarotta tra {0},,Cash negative since today: bankruptcy in {0}
Cassa negativa da {0}: bancarotta tra {1},,Cash negative for {0}: bankruptcy in {1}
"Scoperto {0}. Il limite della difficoltà è di {1}; riporta la cassa sopra zero con un prestito, vendendo treni o riducendo i costi.",,"Overdraft {0}. The difficulty limit is {1}; bring cash back above zero with a loan, by selling trains or by cutting costs."
neutro,,neutral
"Il margine conta da quando ci sono almeno {0} mesi chiusi con ricavi (ora {1}): fino ad allora vale 0, così i primi incassi non fanno crollare il rating.",,"The margin counts once there are at least {0} closed months with revenue (now {1}): until then it is 0, so the first takings do not sink the rating."
"Il punteggio {0} vale già {1}: il rating si aggiorna al prossimo calcolo mensile, a inizio mese.",,"The score {0} is already worth {1}: the rating is updated at the next monthly calculation, at the start of the month."
un margine di almeno {0},,a margin of at least {0}
una leva non oltre {0},,leverage no higher than {0}
una leva non oltre {0} (rimborsando {1}),,leverage no higher than {0} (by repaying {1})
"una leva non oltre {0} (servirebbe rimborsare {1}, più di quanto la cassa consenta oggi)",,"leverage no higher than {0} (it would take repaying {1}, more than cash allows today)"
Per il gradino {0} serve un punteggio di {1}: {2}.,,To reach {0} you need a score of {1}: {2}.
In bancarotta non si possono chiedere prestiti,,Loans cannot be requested while bankrupt
Fido disponibile {0} su {1}. Tasso di un nuovo prestito: {2} fisso (base {3} + rating {4} {5}) per {6} anni.,,Available credit {0} of {1}. Rate of a new loan: {2} fixed (base {3} + rating {4} {5}) for {6} years.
1 keys it en
609 patrimonio netto net worth
610 Bancarotta dichiarata Bankruptcy declared
611 La compagnia non ha riportato la cassa sopra zero entro il limite della difficoltà. The company did not bring its cash back above zero within the difficulty limit.
Cassa negativa da Cash negative for
bancarotta tra bankruptcy in
Scoperto Overdraft
Il limite della difficoltà è di The difficulty limit is
riporta la cassa sopra zero con un prestito, vendendo treni o riducendo i costi. bring cash back above zero with a loan, by selling trains or by cutting costs.
612 in corso in progress
613 finora so far
614 Voce Item
649 Leva (debiti / patrimonio netto) Leverage (debt / net worth)
650 In bancarotta il rating è D finché la situazione non si risolve. While bankrupt the rating is D until the situation is resolved.
651 È il rating più alto: i prestiti costano il minimo. This is the highest rating: loans cost the least.
un margine di almeno a margin of at least
rimborsando by repaying
una leva non oltre leverage no higher than
652 serve migliorare insieme margine e leva margin and leverage must improve together
653 oppure or
Per salire a To rise to
serve un punteggio di a score of
654 Punteggio da Score from
655 Tasso Rate
656 componente component
662 interessi interest
663 scadenza maturity
664 Estingui Pay off
665 Un nuovo prestito costa il La cassa è tornata positiva A new loan costs Cash is back above zero
666 base Dopo {0} di cassa negativa il conto alla rovescia della bancarotta si azzera domani. base After {0} of negative cash, the bankruptcy countdown resets tomorrow.
667 rating Cassa negativa da oggi: bancarotta tra {0} rating Cash negative since today: bankruptcy in {0}
668 Cassa negativa da {0}: bancarotta tra {1} Cash negative for {0}: bankruptcy in {1}
669 Scoperto {0}. Il limite della difficoltà è di {1}; riporta la cassa sopra zero con un prestito, vendendo treni o riducendo i costi. Overdraft {0}. The difficulty limit is {1}; bring cash back above zero with a loan, by selling trains or by cutting costs.
670 neutro neutral
671 Il margine conta da quando ci sono almeno {0} mesi chiusi con ricavi (ora {1}): fino ad allora vale 0, così i primi incassi non fanno crollare il rating. The margin counts once there are at least {0} closed months with revenue (now {1}): until then it is 0, so the first takings do not sink the rating.
672 Il punteggio {0} vale già {1}: il rating si aggiorna al prossimo calcolo mensile, a inizio mese. The score {0} is already worth {1}: the rating is updated at the next monthly calculation, at the start of the month.
673 un margine di almeno {0} a margin of at least {0}
674 una leva non oltre {0} leverage no higher than {0}
675 una leva non oltre {0} (rimborsando {1}) leverage no higher than {0} (by repaying {1})
676 una leva non oltre {0} (servirebbe rimborsare {1}, più di quanto la cassa consenta oggi) leverage no higher than {0} (it would take repaying {1}, more than cash allows today)
677 Per il gradino {0} serve un punteggio di {1}: {2}. To reach {0} you need a score of {1}: {2}.
678 In bancarotta non si possono chiedere prestiti Loans cannot be requested while bankrupt
679 Fido disponibile {0} su {1}. Tasso di un nuovo prestito: {2} fisso (base {3} + rating {4} {5}) per {6} anni. Available credit {0} of {1}. Rate of a new loan: {2} fixed (base {3} + rating {4} {5}) for {6} years.
@@ -363,9 +363,10 @@ public partial class ClimbPanel : VBoxContainer
_repay.Text = $"{T("Rimborsa")} {repay}";
_repay.Disabled = loan is null;
_borrow.Disabled = report is null || !report.LoansAllowed;
bool bankrupt = report is not null && _session.World.Companies.TryGetValue(report.Company, out var me) && me.Bankrupt;
_borrow.TooltipText = report is null ? "" : report.LoansAllowed
? $"{T("Fido disponibile")} {report.LoanAvailable} {T("su")} {report.MaxLoan}, {T("al")} {Fmt.Pct(report.NewLoanRate, 1)}"
: T("In amministrazione controllata non si possono chiedere prestiti");
: bankrupt ? T("In bancarotta non si possono chiedere prestiti") : T("In amministrazione controllata non si possono chiedere prestiti");
}
private void Borrow() =>
@@ -187,12 +187,18 @@ public partial class FinancePanel : VBoxContainer
RefreshLoans(report);
}
/// <summary>
/// Barra della cassa negativa. Il motore conta i giorni una volta al giorno, quindi dopo un prestito il
/// contatore può restare indietro di un giorno rispetto alla cassa: il conto alla rovescia si mostra solo
/// con la cassa davvero negativa (scoperto) o in bancarotta.
/// </summary>
private void RefreshDanger(FinanceReport r)
{
bool negative = r.NegativeCashDays > 0 || r.Overdraft.Cents > 0 || r.Bankrupt;
_danger.Visible = negative;
if (!negative) return;
int left = Math.Max(0, r.BankruptcyDays - r.NegativeCashDays);
bool overdraft = r.Overdraft.Cents > 0;
bool recovering = !overdraft && !r.Bankrupt && r.NegativeCashDays > 0;
_danger.Visible = overdraft || r.Bankrupt || recovering;
_dangerBar.Visible = overdraft || r.Bankrupt;
if (!_danger.Visible) return;
_dangerBar.Value = r.BankruptcyDays > 0 ? Math.Clamp((double)r.NegativeCashDays / r.BankruptcyDays, 0, 1) : 1;
if (r.Bankrupt)
{
@@ -200,9 +206,18 @@ public partial class FinancePanel : VBoxContainer
_dangerDetail.Text = T("La compagnia non ha riportato la cassa sopra zero entro il limite della difficoltà.");
return;
}
_dangerText.Text = $"{T("Cassa negativa da")} {Days(r.NegativeCashDays)}: {T("bancarotta tra")} {Days(left)}";
_dangerDetail.Text = $"{T("Scoperto")} {r.Overdraft}. {T("Il limite della difficoltà è di")} {Days(r.BankruptcyDays)}; "
+ T("riporta la cassa sopra zero con un prestito, vendendo treni o riducendo i costi.");
if (recovering)
{
_dangerText.Text = T("La cassa è tornata positiva");
_dangerDetail.Text = string.Format(T("Dopo {0} di cassa negativa il conto alla rovescia della bancarotta si azzera domani."), Days(r.NegativeCashDays));
return;
}
int left = Math.Max(0, r.BankruptcyDays - r.NegativeCashDays);
_dangerText.Text = r.NegativeCashDays == 0
? string.Format(T("Cassa negativa da oggi: bancarotta tra {0}"), Days(r.BankruptcyDays))
: string.Format(T("Cassa negativa da {0}: bancarotta tra {1}"), Days(r.NegativeCashDays), Days(left));
_dangerDetail.Text = string.Format(T("Scoperto {0}. Il limite della difficoltà è di {1}; riporta la cassa sopra zero con un prestito, vendendo treni o riducendo i costi."),
r.Overdraft, Days(r.BankruptcyDays));
}
private static string Days(int n) => n == 1 ? $"1 {T("giorno")}" : $"{n} {T("giorni")}";
@@ -335,7 +350,10 @@ public partial class FinancePanel : VBoxContainer
+ $"{T("Punteggio")} {Ratio(r.Score)}.";
foreach (var c in _ratingBody.GetChildren()) c.QueueFree();
_ratingBody.AddChild(Measure(T("Margine (utile / ricavi)"), Fmt.Pct(r.Margin, 1), r.MarginWeight, r.MarginComponent));
_ratingBody.AddChild(Measure(T("Margine (utile / ricavi)"), r.MarginNeutral ? T("neutro") : Fmt.Pct(r.Margin, 1), r.MarginWeight, r.MarginComponent));
if (r.MarginNeutral)
_ratingBody.AddChild(Note(string.Format(T("Il margine conta da quando ci sono almeno {0} mesi chiusi con ricavi (ora {1}): fino ad allora vale 0, così i primi incassi non fanno crollare il rating."),
r.MinRevenueMonths, r.RevenueMonths)));
string leverage = r.LeverageUnbounded ? T("patrimonio non positivo") : Ratio(r.Leverage);
_ratingBody.AddChild(Measure(T("Leva (debiti / patrimonio netto)"), leverage, r.LeverageWeight, r.LeverageComponent));
@@ -347,17 +365,24 @@ public partial class FinancePanel : VBoxContainer
{
_ratingBody.AddChild(Note(T("È il rating più alto: i prestiti costano il minimo.")));
}
else if (r.NextAlreadyMet)
{
_ratingBody.AddChild(Note(string.Format(T("Il punteggio {0} vale già {1}: il rating si aggiorna al prossimo calcolo mensile, a inizio mese."),
Ratio(r.Score), r.ScoreRating)));
}
else
{
var ways = new List<string>();
if (r.MarginReachable) ways.Add($"{T("un margine di almeno")} {Fmt.Pct(r.MarginNeeded, 1)}");
if (r.MarginReachable) ways.Add(string.Format(T("un margine di almeno {0}"), Fmt.Pct(r.MarginNeeded, 1)));
if (r.LeverageReachable)
{
string repay = r.DebtToRepay.Cents > 0 ? $" ({T("rimborsando")} {r.DebtToRepay})" : "";
ways.Add($"{T("una leva non oltre")} {Ratio(r.LeverageMax)}{repay}");
string way = r.DebtToRepay.Cents <= 0 ? T("una leva non oltre {0}")
: r.RepayAffordable ? T("una leva non oltre {0} (rimborsando {1})")
: T("una leva non oltre {0} (servirebbe rimborsare {1}, più di quanto la cassa consenta oggi)");
ways.Add(string.Format(way, Ratio(r.LeverageMax), r.DebtToRepay));
}
string how = ways.Count == 0 ? T("serve migliorare insieme margine e leva") : string.Join($" {T("oppure")} ", ways);
_ratingBody.AddChild(Note($"{T("Per salire a")} {r.NextRating} {T("serve un punteggio di")} {Ratio(r.NextThreshold)}: {how}."));
_ratingBody.AddChild(Note(string.Format(T("Per il gradino {0} serve un punteggio di {1}: {2}."), r.NextRating, Ratio(r.NextThreshold), how)));
}
// soglie e tassi per rating
@@ -442,10 +467,10 @@ public partial class FinancePanel : VBoxContainer
}
_borrow.Disabled = !r.LoansAllowed || r.LoanAvailable.Cents <= 0;
_credit.Text = !r.LoansAllowed
? T("In amministrazione controllata non si possono chiedere prestiti")
: $"{T("Fido disponibile")} {r.LoanAvailable} {T("su")} {r.MaxLoan}. {T("Un nuovo prestito costa il")} {Fmt.Pct(r.NewLoanRate, 1)} "
+ $"{T("fisso")} ({T("base")} {Fmt.Pct(r.BaseRate, 1)} + {T("rating")} {r.Rating} {Fmt.Pct(r.Spread, 1)}) {T("per")} {r.LoanTermMonths / 12} {T("anni")}.";
_credit.Text = r.Bankrupt ? T("In bancarotta non si possono chiedere prestiti")
: r.Receivership ? T("In amministrazione controllata non si possono chiedere prestiti")
: string.Format(T("Fido disponibile {0} su {1}. Tasso di un nuovo prestito: {2} fisso (base {3} + rating {4} {5}) per {6} anni."),
r.LoanAvailable, r.MaxLoan, Fmt.Pct(r.NewLoanRate, 1), Fmt.Pct(r.BaseRate, 1), r.Rating, Fmt.Pct(r.Spread, 1), r.LoanTermMonths / 12);
}
private void Borrow() =>