From 7916cbc93bd26c0ae36c681752fab092268c35a1 Mon Sep 17 00:00:00 2001 From: SmartRootsSrl Date: Sat, 21 Mar 2026 11:38:07 +0100 Subject: [PATCH] fix: align Analisi section left, always show KV labels, update expired events table columns --- .../Implementations/EventiSectionRenderer.cs | 82 ++++++++++++++----- .../ExpiredAnagraficaSectionRenderer.cs | 20 +++-- 2 files changed, 72 insertions(+), 30 deletions(-) diff --git a/CertReports.Syncfusion/Services/Implementations/EventiSectionRenderer.cs b/CertReports.Syncfusion/Services/Implementations/EventiSectionRenderer.cs index fb5ba9c..8a4aec0 100644 --- a/CertReports.Syncfusion/Services/Implementations/EventiSectionRenderer.cs +++ b/CertReports.Syncfusion/Services/Implementations/EventiSectionRenderer.cs @@ -38,13 +38,39 @@ public class EventiSectionRenderer : IPdfSectionRenderer var grid = new PdfGrid(); grid.Style.CellPadding = new PdfPaddings(3, 3, 2, 2); - // Colonne mappate sui campi della SP rpt_Events_CFT_ISIN - string[] headers = + bool isExpired = !string.IsNullOrEmpty(data.Info.Stato) && data.Info.Stato != "Quotazione"; + + // Colonne e larghezze dipendono dal tipo di certificato + string[] headers; + float[] cw; + int paidColIndex; + + if (isExpired) { - "Osservazione", "Ex Date", "Record", "Pagamento", - "Trigger Cedola", "Cedola %", "Pagato", "Memoria", - "Importo Pagato", "Trigger Autocall", "Valore Autocall" - }; + // Certificati non in quotazione: senza Ex Date e Record, + // rinominati Trigger Cedola→Barriera Cedola e Trigger Autocall→Soglia Rimborso, + // aggiunte Barriera Capitale e Rimborso Capitale + headers = new[] + { + "Osservazione", "Pagamento", + "Barriera Cedola", "Cedola %", "Pagato", "Memoria", + "Importo Pagato", "Soglia Rimborso", "Valore Autocall", + "Barriera Capitale", "Rimborso Capitale" + }; + cw = new float[] { 62, 58, 52, 46, 36, 46, 52, 58, 52, 58, 58 }; + paidColIndex = 4; + } + else + { + headers = new[] + { + "Osservazione", "Ex Date", "Record", "Pagamento", + "Trigger Cedola", "Cedola %", "Pagato", "Memoria", + "Importo Pagato", "Trigger Autocall", "Valore Autocall" + }; + cw = new float[] { 62, 52, 52, 58, 52, 46, 36, 46, 52, 58, 52 }; + paidColIndex = 6; + } foreach (var _ in headers) grid.Columns.Add(); @@ -65,19 +91,34 @@ public class EventiSectionRenderer : IPdfSectionRenderer var evt = data.Eventi[i]; var row = grid.Rows.Add(); - row.Cells[0].Value = evt.ObservationDate; - row.Cells[1].Value = evt.ExDate; - row.Cells[2].Value = evt.RecordDate; - row.Cells[3].Value = evt.PaymentDate; - row.Cells[4].Value = evt.CouponTrigger; - row.Cells[5].Value = evt.CouponValue; - row.Cells[6].Value = evt.Paid; - row.Cells[7].Value = evt.Memory; - row.Cells[8].Value = evt.AmountPaid; - //row.Cells[9].Value = evt.CapitalTrigger; - //row.Cells[10].Value = evt.CapitalValue; - row.Cells[9].Value = evt.AutocallTrigger; - row.Cells[10].Value = evt.AutocallValue; + if (isExpired) + { + row.Cells[0].Value = evt.ObservationDate; + row.Cells[1].Value = evt.PaymentDate; + row.Cells[2].Value = evt.CouponTrigger; + row.Cells[3].Value = evt.CouponValue; + row.Cells[4].Value = evt.Paid; + row.Cells[5].Value = evt.Memory; + row.Cells[6].Value = evt.AmountPaid; + row.Cells[7].Value = evt.AutocallTrigger; + row.Cells[8].Value = evt.AutocallValue; + row.Cells[9].Value = evt.CapitalTrigger; + row.Cells[10].Value = evt.CapitalValue; + } + else + { + row.Cells[0].Value = evt.ObservationDate; + row.Cells[1].Value = evt.ExDate; + row.Cells[2].Value = evt.RecordDate; + row.Cells[3].Value = evt.PaymentDate; + row.Cells[4].Value = evt.CouponTrigger; + row.Cells[5].Value = evt.CouponValue; + row.Cells[6].Value = evt.Paid; + row.Cells[7].Value = evt.Memory; + row.Cells[8].Value = evt.AmountPaid; + row.Cells[9].Value = evt.AutocallTrigger; + row.Cells[10].Value = evt.AutocallValue; + } foreach (var cell in row.Cells.OfType()) { @@ -92,11 +133,10 @@ public class EventiSectionRenderer : IPdfSectionRenderer // Evidenzia "SI" nella colonna Pagato if (evt.Paid == "SI") - row.Cells[6].Style.TextBrush = PdfTheme.PositiveBrush as PdfBrush; + row.Cells[paidColIndex].Style.TextBrush = PdfTheme.PositiveBrush as PdfBrush; } // Larghezze colonne (landscape A4 ~ 757 punti utili) - float[] cw = { 62, 52, 52, 58, 52, 46, 36, 46, 52, 58, 52 }; float total = cw.Sum(); float scale = w / total; for (int i = 0; i < cw.Length; i++) diff --git a/CertReports.Syncfusion/Services/Implementations/ExpiredAnagraficaSectionRenderer.cs b/CertReports.Syncfusion/Services/Implementations/ExpiredAnagraficaSectionRenderer.cs index 000509c..ea04a46 100644 --- a/CertReports.Syncfusion/Services/Implementations/ExpiredAnagraficaSectionRenderer.cs +++ b/CertReports.Syncfusion/Services/Implementations/ExpiredAnagraficaSectionRenderer.cs @@ -180,7 +180,8 @@ public class ExpiredAnagraficaSectionRenderer : IPdfSectionRenderer } // ═══════════════════════════════════════════════════════════════ - // SEZIONE B: ANALISI — KV list colonna destra + // SEZIONE B: ANALISI — KV list allineata a sinistra, larghezza piena + // Le etichette sono sempre visibili; valore "-" se assente dal DB. // ═══════════════════════════════════════════════════════════════ private float DrawAnalisi(PdfGraphics g, CertificateInfo info, float y) @@ -196,25 +197,27 @@ public class ExpiredAnagraficaSectionRenderer : IPdfSectionRenderer ("Rendimento Totale", info.RendimentoTotale), }; - return DrawKVList(g, items, ColW + ColGap, ColW, y); + // Posizione x=0, larghezza intera pagina — allineato a sinistra come Caratteristiche + return DrawKVList(g, items, 0, PageW, y); } private float DrawKVList(PdfGraphics g, (string Label, string Value)[] items, float x, float w, float y) { float rh = PdfTheme.RowHeight; float pad = PdfTheme.CellPadding; - float labelW = w * 0.58f; - float valueW = w * 0.42f; + float labelW = w * 0.35f; + float valueW = w * 0.65f; - foreach (var (label, value) in items) + foreach (var (label, rawValue) in items) { - if (string.IsNullOrWhiteSpace(value)) continue; + // L'etichetta è sempre visibile; se il valore è assente mostro "-" + var value = string.IsNullOrWhiteSpace(rawValue) ? "-" : rawValue; g.DrawString(label, PdfTheme.TableFont, new PdfSolidBrush(PdfTheme.TextSecondary), new RectangleF(x + pad, y + 1f, labelW, rh)); - bool isNeg = value.TrimStart().StartsWith('-'); + bool isNeg = value.TrimStart().StartsWith('-') && value != "-"; bool isKey = label == "Rendimento Totale"; var brush = isNeg ? new PdfSolidBrush(PdfTheme.NegativeRed) @@ -222,8 +225,7 @@ public class ExpiredAnagraficaSectionRenderer : IPdfSectionRenderer : new PdfSolidBrush(PdfTheme.TextPrimary); g.DrawString(value, PdfTheme.TableBold, brush, - new RectangleF(x + labelW, y + 1f, valueW - pad, rh), - new PdfStringFormat(PdfTextAlignment.Right)); + new RectangleF(x + labelW, y + 1f, valueW - pad, rh)); g.DrawLine(new PdfPen(PdfTheme.SeparatorLine, 0.3f), x, y + rh, x + w, y + rh);