fix: null-coalescing for KV fields + PdfTheme brush rename (NegativeRedBrush/PositiveGreenBrush)

This commit is contained in:
2026-03-20 12:28:43 +01:00
parent 8419ac0a78
commit ff2f4ccfe6
2 changed files with 20 additions and 20 deletions

View File

@@ -31,7 +31,7 @@ public static class PdfTheme
public static readonly Color SeparatorLine = Color.FromArgb(255, 221, 221, 221); // #DDDDDD
public static readonly Color TableBorder = Color.FromArgb(255, 187, 187, 187); // #BBBBBB
public static readonly Color TableAltRow = Color.FromArgb(255, 247, 249, 252); // #F7F9FC
public static readonly Color TableHeaderBg = Color.FromArgb(255, 21, 101, 192); // #1565C0
// TableHeaderBg is AccentBlue — use AccentBlueBrush / TableHeaderBrush directly
// ─── Font ──────────────────────────────────────────────────────────
private static readonly PdfStandardFont _fontRegular = new(PdfFontFamily.Helvetica, 8f);
@@ -76,11 +76,11 @@ public static class PdfTheme
public static PdfBrush NegativeBrush => new PdfSolidBrush(NegativeValue);
public static PdfPen BorderPen => new PdfPen(BorderColor, 0.5f);
public static PdfBrush AccentBlueBrush => new PdfSolidBrush(AccentBlue);
public static PdfBrush NegativeBrush2 => new PdfSolidBrush(NegativeRed);
public static PdfBrush PositiveBrush2 => new PdfSolidBrush(PositiveGreen);
public static PdfBrush NegativeRedBrush => new PdfSolidBrush(NegativeRed);
public static PdfBrush PositiveGreenBrush => new PdfSolidBrush(PositiveGreen);
public static PdfBrush FooterTextBrush => new PdfSolidBrush(FooterText);
public static PdfBrush TableAltRowBrush => new PdfSolidBrush(TableAltRow);
public static PdfBrush TableHeaderBrush => new PdfSolidBrush(TableHeaderBg);
public static PdfBrush TableHeaderBrush => AccentBlueBrush;
public static PdfPen SeparatorPen => new PdfPen(SeparatorLine, 0.5f);
public static PdfPen TableBorderPen => new PdfPen(TableBorder, 0.5f);
public static PdfPen AccentBluePen => new PdfPen(AccentBlue, 2.5f);
@@ -89,7 +89,7 @@ public static class PdfTheme
public static PdfBrush ValueBrush(decimal? value)
{
if (value == null) return TextBrush;
return value >= 0 ? PositiveBrush : NegativeBrush;
return value >= 0 ? PositiveGreenBrush : NegativeRedBrush;
}
/// <summary>

View File

@@ -262,25 +262,25 @@ public class AnagraficaSectionRenderer : IPdfSectionRenderer
{
var leftItems = new (string Label, string Value)[]
{
("Importo Cedola (p.a.)", info.NominalAnnualYield),
("Frequenza Cedola", info.FrequenzaCedole),
("Importo Cedola (p.a.)", info.NominalAnnualYield ?? "-"),
("Frequenza Cedola", info.FrequenzaCedole ?? "-"),
("Valore Nominale", info.NominalValue?.ToString("N0") ?? "-"),
("Prezzo Emissione", info.PrezzoEmissione?.ToString("N0") ?? "-"),
("Barriera Capitale", info.LivelloBarriera),
("Tipo Barriera", info.BarrierType),
("Tipo Basket", info.BasketType),
("Barriera Capitale", info.LivelloBarriera ?? "-"),
("Tipo Barriera", info.BarrierType ?? "-"),
("Tipo Basket", info.BasketType ?? "-"),
("Leva", string.IsNullOrWhiteSpace(info.Leva) ? "—" : info.Leva),
};
var rightItems = new (string Label, string Value)[]
{
("Rend. Capitale a Scadenza", info.CapitalReturnAtMaturity),
("IRR", info.IRR),
("Protezione Capitale", info.BufferKProt),
("Protezione Coupon", info.BufferCPNProt),
("Valore Autocall", info.AutocallValue),
("Distanza Autocall", info.TriggerAutocallDistance),
("Rendimento Autocall", info.AutocallReturn),
("Rend. Capitale a Scadenza", info.CapitalReturnAtMaturity ?? "-"),
("IRR", info.IRR ?? "-"),
("Protezione Capitale", info.BufferKProt ?? "-"),
("Protezione Coupon", info.BufferCPNProt ?? "-"),
("Valore Autocall", info.AutocallValue ?? "-"),
("Distanza Autocall", info.TriggerAutocallDistance ?? "-"),
("Rendimento Autocall", info.AutocallReturn ?? "-"),
("Fattore Airbag", string.IsNullOrWhiteSpace(info.FattoreAirbag) ? "—" : info.FattoreAirbag),
("Trigger OneStar", string.IsNullOrWhiteSpace(info.TriggerOneStar) ? "—" : info.TriggerOneStar),
};