fix: align Analisi section left, always show KV labels, update expired events table columns
This commit is contained in:
@@ -38,13 +38,39 @@ public class EventiSectionRenderer : IPdfSectionRenderer
|
|||||||
var grid = new PdfGrid();
|
var grid = new PdfGrid();
|
||||||
grid.Style.CellPadding = new PdfPaddings(3, 3, 2, 2);
|
grid.Style.CellPadding = new PdfPaddings(3, 3, 2, 2);
|
||||||
|
|
||||||
// Colonne mappate sui campi della SP rpt_Events_CFT_ISIN
|
bool isExpired = !string.IsNullOrEmpty(data.Info.Stato) && data.Info.Stato != "Quotazione";
|
||||||
string[] headers =
|
|
||||||
|
// Colonne e larghezze dipendono dal tipo di certificato
|
||||||
|
string[] headers;
|
||||||
|
float[] cw;
|
||||||
|
int paidColIndex;
|
||||||
|
|
||||||
|
if (isExpired)
|
||||||
{
|
{
|
||||||
"Osservazione", "Ex Date", "Record", "Pagamento",
|
// Certificati non in quotazione: senza Ex Date e Record,
|
||||||
"Trigger Cedola", "Cedola %", "Pagato", "Memoria",
|
// rinominati Trigger Cedola→Barriera Cedola e Trigger Autocall→Soglia Rimborso,
|
||||||
"Importo Pagato", "Trigger Autocall", "Valore Autocall"
|
// 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();
|
foreach (var _ in headers) grid.Columns.Add();
|
||||||
|
|
||||||
@@ -65,19 +91,34 @@ public class EventiSectionRenderer : IPdfSectionRenderer
|
|||||||
var evt = data.Eventi[i];
|
var evt = data.Eventi[i];
|
||||||
var row = grid.Rows.Add();
|
var row = grid.Rows.Add();
|
||||||
|
|
||||||
row.Cells[0].Value = evt.ObservationDate;
|
if (isExpired)
|
||||||
row.Cells[1].Value = evt.ExDate;
|
{
|
||||||
row.Cells[2].Value = evt.RecordDate;
|
row.Cells[0].Value = evt.ObservationDate;
|
||||||
row.Cells[3].Value = evt.PaymentDate;
|
row.Cells[1].Value = evt.PaymentDate;
|
||||||
row.Cells[4].Value = evt.CouponTrigger;
|
row.Cells[2].Value = evt.CouponTrigger;
|
||||||
row.Cells[5].Value = evt.CouponValue;
|
row.Cells[3].Value = evt.CouponValue;
|
||||||
row.Cells[6].Value = evt.Paid;
|
row.Cells[4].Value = evt.Paid;
|
||||||
row.Cells[7].Value = evt.Memory;
|
row.Cells[5].Value = evt.Memory;
|
||||||
row.Cells[8].Value = evt.AmountPaid;
|
row.Cells[6].Value = evt.AmountPaid;
|
||||||
//row.Cells[9].Value = evt.CapitalTrigger;
|
row.Cells[7].Value = evt.AutocallTrigger;
|
||||||
//row.Cells[10].Value = evt.CapitalValue;
|
row.Cells[8].Value = evt.AutocallValue;
|
||||||
row.Cells[9].Value = evt.AutocallTrigger;
|
row.Cells[9].Value = evt.CapitalTrigger;
|
||||||
row.Cells[10].Value = evt.AutocallValue;
|
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<PdfGridCell>())
|
foreach (var cell in row.Cells.OfType<PdfGridCell>())
|
||||||
{
|
{
|
||||||
@@ -92,11 +133,10 @@ public class EventiSectionRenderer : IPdfSectionRenderer
|
|||||||
|
|
||||||
// Evidenzia "SI" nella colonna Pagato
|
// Evidenzia "SI" nella colonna Pagato
|
||||||
if (evt.Paid == "SI")
|
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)
|
// 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 total = cw.Sum();
|
||||||
float scale = w / total;
|
float scale = w / total;
|
||||||
for (int i = 0; i < cw.Length; i++)
|
for (int i = 0; i < cw.Length; i++)
|
||||||
|
|||||||
@@ -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)
|
private float DrawAnalisi(PdfGraphics g, CertificateInfo info, float y)
|
||||||
@@ -196,25 +197,27 @@ public class ExpiredAnagraficaSectionRenderer : IPdfSectionRenderer
|
|||||||
("Rendimento Totale", info.RendimentoTotale),
|
("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)
|
private float DrawKVList(PdfGraphics g, (string Label, string Value)[] items, float x, float w, float y)
|
||||||
{
|
{
|
||||||
float rh = PdfTheme.RowHeight;
|
float rh = PdfTheme.RowHeight;
|
||||||
float pad = PdfTheme.CellPadding;
|
float pad = PdfTheme.CellPadding;
|
||||||
float labelW = w * 0.58f;
|
float labelW = w * 0.35f;
|
||||||
float valueW = w * 0.42f;
|
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,
|
g.DrawString(label, PdfTheme.TableFont,
|
||||||
new PdfSolidBrush(PdfTheme.TextSecondary),
|
new PdfSolidBrush(PdfTheme.TextSecondary),
|
||||||
new RectangleF(x + pad, y + 1f, labelW, rh));
|
new RectangleF(x + pad, y + 1f, labelW, rh));
|
||||||
|
|
||||||
bool isNeg = value.TrimStart().StartsWith('-');
|
bool isNeg = value.TrimStart().StartsWith('-') && value != "-";
|
||||||
bool isKey = label == "Rendimento Totale";
|
bool isKey = label == "Rendimento Totale";
|
||||||
|
|
||||||
var brush = isNeg ? new PdfSolidBrush(PdfTheme.NegativeRed)
|
var brush = isNeg ? new PdfSolidBrush(PdfTheme.NegativeRed)
|
||||||
@@ -222,8 +225,7 @@ public class ExpiredAnagraficaSectionRenderer : IPdfSectionRenderer
|
|||||||
: new PdfSolidBrush(PdfTheme.TextPrimary);
|
: new PdfSolidBrush(PdfTheme.TextPrimary);
|
||||||
|
|
||||||
g.DrawString(value, PdfTheme.TableBold, brush,
|
g.DrawString(value, PdfTheme.TableBold, brush,
|
||||||
new RectangleF(x + labelW, y + 1f, valueW - pad, rh),
|
new RectangleF(x + labelW, y + 1f, valueW - pad, rh));
|
||||||
new PdfStringFormat(PdfTextAlignment.Right));
|
|
||||||
|
|
||||||
g.DrawLine(new PdfPen(PdfTheme.SeparatorLine, 0.3f),
|
g.DrawLine(new PdfPen(PdfTheme.SeparatorLine, 0.3f),
|
||||||
x, y + rh, x + w, y + rh);
|
x, y + rh, x + w, y + rh);
|
||||||
|
|||||||
Reference in New Issue
Block a user