626 lines
34 KiB
C#
626 lines
34 KiB
C#
using System;
|
|
using Consulenza.ReportWriter.Business;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using System.Data;
|
|
using Consulenza.ReportWriter.Business.CHART_PDF;
|
|
using Consulenza.ReportCommon;
|
|
using Consulenza.ReportWriter.Business.Entity;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// S27.RiservaPortafoglioModelloVSAttuale idSezione = 70
|
|
/// </summary>
|
|
public class S27 : Entity.Section
|
|
{
|
|
public S27(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S27", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
protected override sealed void Draw()
|
|
{
|
|
var dati = GetDataSet();
|
|
|
|
#region Testo Introduttivo
|
|
AddElement(new SpacePDF(20));
|
|
if (getTesto1().Length > 0)
|
|
{
|
|
AddElement(new FormattedTextAreaPDF(getTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
|
AddElement(new SpacePDF(15));
|
|
}
|
|
#endregion
|
|
|
|
#region Label
|
|
var tabellaCtv = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["patrimonio"])
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = false,
|
|
Footer = false,
|
|
AlternateRow = false,
|
|
RowHeight = 28,
|
|
ShowSeparationLines = false,
|
|
WhiteSpacesHorizontalSeparator = true,
|
|
HideLastSeparationLine = true
|
|
};
|
|
|
|
tabellaCtv.Columns.Add(new ColumnPDF("ControvaloreattualeString", 130, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "ControvaloreattualeString", "") { FontSize = 7, DeltaYContent = -1 });
|
|
tabellaCtv.Columns.Add(new ColumnPDF("Controvaloreattuale", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Controvaloreattuale", "") { HeaderFontSize = 7, FontBold = false, PaddingRight = 10, DeltaYContent = -1 });
|
|
|
|
tabellaCtv.Columns.Add(new ColumnPDF("AderenzaportafogliomodelloString", 130, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "AderenzaportafogliomodelloString", "") { FontSize = 7, PaddingLeft = 5, DeltaYContent = -1 });
|
|
tabellaCtv.Columns.Add(new ColumnPDF("Aderenzaportafogliomodello", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Aderenzaportafogliomodello", "") { HeaderFontSize = 7, FontBold = false, DeltaYContent = -1 });
|
|
|
|
|
|
//FormattedTextAreaPDF captionCtvAttuale = new FormattedTextAreaPDF("Controvalore attuale (€)", EnvironmentFacade.RendererFacade.XLeftLimit, 130) { FontSize = 7, BackGroundMarginLeft = 5, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, AutoIncrementYWritable = false };
|
|
//AddElement(captionCtvAttuale);
|
|
//FormattedTextAreaPDF controvalore = new FormattedTextAreaPDF(dati.Tables["patrimonio"].Rows[0]["ControvaloreAttuale"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit + 150) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = false };
|
|
//AddElement(controvalore);
|
|
|
|
//FormattedTextAreaPDF captionAderenzaModello = new FormattedTextAreaPDF("Aderenza al portafoglio modello (%)", EnvironmentFacade.RendererFacade.XLeftLimit + 280, 140) { FontSize = 7, BackGroundMarginLeft = 5, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, TextVerticalAlign = ceTe.DynamicPDF.VAlign.Top, AutoIncrementYWritable = false };
|
|
//AddElement(captionAderenzaModello);
|
|
//FormattedTextAreaPDF aderenza = new FormattedTextAreaPDF(dati.Tables["patrimonio"].Rows[0]["AderenzaPortafoglioModello"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit + 480) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = true };
|
|
//AddElement(aderenza);
|
|
//AddElement(new SpacePDF(13));
|
|
|
|
//FormattedTextAreaPDF captionVarAttuale = new FormattedTextAreaPDF("VaR attuale (%)", EnvironmentFacade.RendererFacade.XLeftLimit, 130) { FontSize = 7, BackGroundMarginLeft = 5, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, AutoIncrementYWritable = false };
|
|
//AddElement(captionVarAttuale);
|
|
//FormattedTextAreaPDF varAttuale = new FormattedTextAreaPDF(dati.Tables["patrimonio"].Rows[0]["VarAttuale"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit + 150) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = false };
|
|
//AddElement(varAttuale);
|
|
|
|
//FormattedTextAreaPDF captionVarModello = new FormattedTextAreaPDF("VaR portafoglio modello (%)", EnvironmentFacade.RendererFacade.XLeftLimit + 280, 140) { FontSize = 7, BackGroundMarginLeft = 5, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, AutoIncrementYWritable = false };
|
|
//AddElement(captionVarModello);
|
|
//FormattedTextAreaPDF varModello = new FormattedTextAreaPDF(dati.Tables["patrimonio"].Rows[0]["VarPortafoglioModello"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit + 480) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = true };
|
|
//AddElement(varModello);
|
|
#endregion
|
|
|
|
AddElement(tabellaCtv);
|
|
AddElement(new SpacePDF(20));
|
|
|
|
#region Portafoglio
|
|
|
|
string simbolo = isControvalore() ? "(€)" : "(%)";
|
|
//AddElement(new FormattedTextAreaPDF(!isAssetClass() ? "Macro asset class" : "Asset class", EnvironmentFacade.RendererFacade.XLeftLimit, 140) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
|
|
//AddElement(new FormattedTextAreaPDF("Portafoglio modello " + simbolo, EnvironmentFacade.RendererFacade.XLeftLimit + 145, 190) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
|
|
//AddElement(new FormattedTextAreaPDF("Portafoglio attuale " + simbolo, EnvironmentFacade.RendererFacade.XLeftLimit + 340, 190) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize =7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 }); //340 = + 145 + 195
|
|
|
|
DataTable dtOrdinamento = dati.Tables["portafoglio"].AsEnumerable().OrderBy(l => l.Field<int>("Ordinamento")).CopyToDataTable();
|
|
var tabellaAsset = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dtOrdinamento)
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = true,
|
|
Footer = false,
|
|
AlternateRow = false,
|
|
RowHeight = 28,
|
|
ShowSeparationLines = false,
|
|
ShowBorderHeader = true
|
|
|
|
};
|
|
tabellaAsset.Columns.Add(new ColumnPDF("descrizione", 150, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", !isAssetClass() ? "Macro asset class" : "Asset class") { HeaderFontSize = 7 });
|
|
tabellaAsset.Columns.Add(new ColumnPDF("portafogliomodello", 185, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "PercentualeControvaloreModello", "Portafoglio modello " + simbolo) { HeaderPaddingRight = 80, PaddingRight = 20, HeaderFontSize = 7, DeltaYContent = 2, FontSize = 7 });
|
|
tabellaAsset.Columns.Add(new ColumnPDF("portafoglioattuale", 185, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "PercentualeControvaloreAttuale", "Portafoglio attuale " + simbolo) { HeaderFontSize = 7, HeaderPaddingLeft = 10, PaddingLeft = 3.5f, DeltaYContent = 2, FontSize = 7 });
|
|
int o = 0;
|
|
var list = new List<double>();
|
|
list.Add(Convert.ToDouble(dati.Tables["portafoglio"].AsEnumerable().Max(x => x["PercentualeControvaloreModello"])));
|
|
list.Add(Convert.ToDouble(dati.Tables["portafoglio"].AsEnumerable().Max(x => x["PercentualeControvaloreAttuale"])));
|
|
var max = (float)Helper.Round(list.Max());
|
|
//float larghezzaSpazioTestoPercentuale = 0;
|
|
//float larghezzaBarra = 0;
|
|
//float deltaXBarra = 0;
|
|
//var width = 0;
|
|
foreach (DataRow row in dtOrdinamento.Rows)
|
|
{
|
|
|
|
var colore = new ColorPDF(Convert.ToInt32(row["Red"]), Convert.ToInt32(row["Green"]), Convert.ToInt32(row["Blue"]));
|
|
|
|
#region barra colonna PortafoglioModello
|
|
|
|
int columnWidth = tabellaAsset.Columns[1].Width;
|
|
string text = isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreModello"].ToString()) : Helper.FormatDecimal(row["PercentualeControvaloreModello"].ToString(), 2);
|
|
int textWidth = GetNumericStringWidth(text);
|
|
float barWidth = Helper.GetWidthProportional((float)Convert.ToDouble(row["PercentualeControvaloreModello"]), max, columnWidth);
|
|
float additionalWhiteSpace = barWidth == 0 ? 0 : 4;
|
|
|
|
tabellaAsset.Cells[1, o].ValueObjectList = new List<Business.Entity.ObjectPDF>();
|
|
tabellaAsset.Cells[1, o].ValueObjectList.Add(new FormattedTextAreaPDF(text, 0, textWidth)
|
|
{
|
|
DeltaY = 4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
|
|
DeltaX = (barWidth + additionalWhiteSpace) * -1,
|
|
FontSize = 7
|
|
});
|
|
if (barWidth != 0)
|
|
{
|
|
tabellaAsset.Cells[1, o].ValueObjectList.Add(new RectanglePDF(12, barWidth, colore) { DeltaY = 4 });
|
|
}
|
|
#endregion
|
|
|
|
#region barra colonna PortafoglioAttuale
|
|
|
|
columnWidth = tabellaAsset.Columns[2].Width;
|
|
text = isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreAttuale"].ToString()) : Helper.FormatDecimal(row["PercentualeControvaloreAttuale"].ToString(), 2);
|
|
textWidth = GetNumericStringWidth(text);
|
|
barWidth = Helper.GetWidthProportional((float)Convert.ToDouble(row["PercentualeControvaloreAttuale"]), max, columnWidth);
|
|
additionalWhiteSpace = barWidth == 0 ? 0 : 4;
|
|
|
|
tabellaAsset.Cells[2, o].ValueObjectList = new List<Business.Entity.ObjectPDF>();
|
|
if (barWidth != 0)
|
|
{
|
|
tabellaAsset.Cells[2, o].ValueObjectList.Add(new RectanglePDF(12, barWidth, colore) { DeltaY = 4 });
|
|
}
|
|
tabellaAsset.Cells[2, o].ValueObjectList.Add(new FormattedTextAreaPDF(text, 0, textWidth)
|
|
{
|
|
DeltaY = 4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
DeltaX = barWidth + additionalWhiteSpace,
|
|
FontSize = 7
|
|
});
|
|
#endregion
|
|
o++;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Nota
|
|
string nota1 = getNota1();
|
|
string nota2 = getNota2();
|
|
if (nota1 != "")
|
|
{
|
|
|
|
tabellaAsset.Notes.Add(
|
|
new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella,
|
|
nota1,
|
|
new[] { "" },
|
|
string.Empty,
|
|
TableNotePDF.TableNoteAsteriskPositionType.CorpoTabella)
|
|
{ FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }
|
|
);
|
|
//captionAderenzaModello.Text += note;
|
|
//captionCtvAttuale.Text += nota1.Contains("Grado") ? note : "";
|
|
//note += "*";
|
|
}
|
|
if (nota2 != "")
|
|
{
|
|
|
|
tabellaAsset.Notes.Add(
|
|
new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella,
|
|
nota2,
|
|
new[] { "" },
|
|
string.Empty,
|
|
TableNotePDF.TableNoteAsteriskPositionType.CorpoTabella)
|
|
{ FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }
|
|
);
|
|
//varAttuale.Text += note;
|
|
|
|
//note += "*";
|
|
}
|
|
#endregion
|
|
|
|
AddElement(tabellaAsset);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataTable.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected sealed override DataTable GetDataTable()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected override DataSet GetDataSet()
|
|
{
|
|
#region Estrazione Chiave PB + Servizi
|
|
|
|
|
|
var _pianificazioneOrizzontale = datiSeiUnico.all().pianificazioneUnit.pianificazioneOrizzontale.FirstOrDefault(l => l.portafoglioModello.area.Equals("Ris"));
|
|
|
|
var patrimoniocasa = isAssetClass() ?
|
|
datiSeiUnico.all().patrimonioUnit.patrimonioCasa.assetClass.distribuzioneAree.Where(o => o.area.Equals("Ris")).ToList() :
|
|
datiSeiUnico.all().patrimonioUnit.patrimonioCasa.macroAssetClass.distribuzioneAree.Where(o => o.area.Equals("Ris")).ToList();
|
|
|
|
var totaleControvaloreAttuale = patrimoniocasa.FirstOrDefault().distribuzione.totaleCtv;
|
|
var aderenzaPortafogliomodello = _pianificazioneOrizzontale.aderenza.valoreAderenza; //datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale.FirstOrDefault(l => l.portafoglioModello.area.Equals("Ris")).aderenza.portafoglioConsiderato;
|
|
var displayInfoM = datiSeiUnico.displayInfos().macroAssetDisplayInfos;
|
|
var displayInfoA = datiSeiUnico.displayInfos().assetDisplayInfos;
|
|
var varAttuale = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.Where(l => l.area.Equals("Ris")).FirstOrDefault().progetti.FirstOrDefault().progettoVarInfos != null ? datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.Where(l => l.area.Equals("Ris")).FirstOrDefault().progetti.FirstOrDefault().progettoVarInfos.varDecodificato : "-";
|
|
var distribuzionePtf = !isAssetClass() ? _pianificazioneOrizzontale.portafoglioModello.distribuzioniPtfModello.Where(l => l.asset.livello == 1).ToList() : _pianificazioneOrizzontale.portafoglioModello.distribuzioniPtfModello.Where(l => l.asset.livello == 2).ToList();
|
|
|
|
#endregion
|
|
|
|
#region Definizione Dataset
|
|
var ds = new DataSet();
|
|
|
|
ds.Tables.Add(new DataTable("patrimonio"));
|
|
ds.Tables.Add(new DataTable("portafoglio"));
|
|
|
|
#endregion
|
|
|
|
#region Patrimonio
|
|
ds.Tables["patrimonio"].Columns.Add("ControvaloreattualeString", typeof(string));
|
|
ds.Tables["patrimonio"].Columns.Add("Controvaloreattuale", typeof(string));
|
|
ds.Tables["patrimonio"].Columns.Add("AderenzaportafogliomodelloString", typeof(string));
|
|
ds.Tables["patrimonio"].Columns.Add("Aderenzaportafogliomodello", typeof(string));
|
|
|
|
|
|
ds.Tables["patrimonio"].Rows.Add(
|
|
"Controvalore attuale (€)" + (getNota1().Length > 0 && getNota1().Contains("Grado") ? "*" : ""),
|
|
Helper.FormatCurrency(totaleControvaloreAttuale.ToString()),
|
|
"Aderenza al portafoglio modello (%)" + (getNota1().Length > 0 && getNota1().Contains("aderenza") ? "*" : ""),
|
|
Helper.FormatDecimal(aderenzaPortafogliomodello.ToString(), 2));
|
|
//if (getNota2().Length > 0) //commentato perchè non c'erano ticket a riguardo e impediva la visualizzazione da ppt
|
|
ds.Tables["patrimonio"].Rows.Add(
|
|
"VaR attuale (%)" + (getNota2().Length > 0 ? "*" : ""),
|
|
varAttuale,
|
|
"VaR portafoglio modello (%)",
|
|
_pianificazioneOrizzontale.varPianificatoDec);
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Portafoglio
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("Codice", typeof(string)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("Red", typeof(int)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("Green", typeof(int)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("Blue", typeof(int)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("PercentualeControvaloreModello", typeof(decimal)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("PercentualeControvaloreAttuale", typeof(decimal)));
|
|
ds.Tables["portafoglio"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
#region portafoglio modello
|
|
|
|
if (isAssetClass())
|
|
{
|
|
foreach (var valore in from c in displayInfoA
|
|
join l in distribuzionePtf on c.key equals l.asset.asset
|
|
//orderby c.value.order
|
|
select new
|
|
{
|
|
l.asset.asset,
|
|
l.asset.descrizione,
|
|
new ColorPDF(c.value.fill).Red,
|
|
new ColorPDF(c.value.fill).Green,
|
|
new ColorPDF(c.value.fill).Blue,
|
|
l.percentuale,
|
|
c.value.order
|
|
})
|
|
{
|
|
ds.Tables["portafoglio"].Rows.Add(
|
|
valore.asset,
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
isControvalore() ? (Convert.ToDecimal(valore.percentuale) * totaleControvaloreAttuale) : Convert.ToDecimal(valore.percentuale * 100),
|
|
0,//portafoglio proposto che viene caricato successivamente
|
|
valore.order
|
|
);
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
foreach (var valore in from c in displayInfoM
|
|
join l in distribuzionePtf on c.key equals l.asset.asset
|
|
//orderby c.value.order
|
|
select new
|
|
{
|
|
l.asset.asset,
|
|
l.asset.descrizione,
|
|
new ColorPDF(c.value.fill).Red,
|
|
new ColorPDF(c.value.fill).Green,
|
|
new ColorPDF(c.value.fill).Blue,
|
|
l.percentuale,
|
|
c.value.order
|
|
})
|
|
{
|
|
ds.Tables["portafoglio"].Rows.Add(
|
|
valore.asset,
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
isControvalore() ? (Convert.ToDecimal(valore.percentuale) * totaleControvaloreAttuale) : Convert.ToDecimal(valore.percentuale * 100),
|
|
0,//portafoglio attuale che viene caricato successivamente
|
|
valore.order
|
|
);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region portafoglioattuale
|
|
if (isAssetClass())
|
|
{
|
|
foreach (var valore in from c in displayInfoA
|
|
join l in patrimoniocasa[0].distribuzione.elencoSlice on c.key equals l.codice
|
|
where l.sliceRappresentabile == true
|
|
//orderby c.value.order
|
|
select new
|
|
{
|
|
l.codice,
|
|
l.descrizione,
|
|
new ColorPDF(c.value.fill).Red,
|
|
new ColorPDF(c.value.fill).Green,
|
|
new ColorPDF(c.value.fill).Blue,
|
|
l.pesoCC,
|
|
l.ctvCC,
|
|
c.value.order
|
|
})
|
|
{
|
|
if (ds.Tables["portafoglio"].AsEnumerable().FirstOrDefault(l => l.Field<string>("Codice") == valore.codice) != null)
|
|
{
|
|
ds.Tables["portafoglio"].Select(string.Format("[Codice] = '{0}'", valore.codice))
|
|
.ToList<DataRow>()
|
|
.ForEach(r =>
|
|
{
|
|
r["PercentualeControvaloreAttuale"] = isControvalore() ? Convert.ToDecimal(valore.ctvCC) : Convert.ToDecimal(valore.pesoCC * 100);
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
|
|
ds.Tables["portafoglio"].Rows.Add(
|
|
valore.codice,
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
0,//portafoglio modello per un item che non è presente
|
|
isControvalore() ? valore.ctvCC : valore.pesoCC * 100,
|
|
valore.order
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
foreach (var valore in from c in displayInfoM
|
|
join l in patrimoniocasa[0].distribuzione.elencoSlice on c.key equals l.codice
|
|
where l.sliceRappresentabile == true
|
|
//orderby c.value.order
|
|
select new
|
|
{
|
|
l.codice,
|
|
l.descrizione,
|
|
new ColorPDF(c.value.fill).Red,
|
|
new ColorPDF(c.value.fill).Green,
|
|
new ColorPDF(c.value.fill).Blue,
|
|
l.pesoCC,
|
|
l.ctvCC,
|
|
c.value.order
|
|
})
|
|
{
|
|
if (ds.Tables["portafoglio"].AsEnumerable().FirstOrDefault(l => l.Field<string>("Codice") == valore.codice) != null)
|
|
{
|
|
ds.Tables["portafoglio"].Select(string.Format("[Codice] = '{0}'", valore.codice))
|
|
.ToList<DataRow>()
|
|
.ForEach(r =>
|
|
{
|
|
r["PercentualeControvaloreAttuale"] = isControvalore() ? Convert.ToDecimal(valore.ctvCC) : Convert.ToDecimal(valore.pesoCC * 100);
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
|
|
ds.Tables["portafoglio"].Rows.Add(
|
|
valore.codice,
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
0,//portafoglio modello per un item che non è presente
|
|
isControvalore() ? valore.ctvCC : valore.pesoCC * 100,
|
|
valore.order
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
ds.Tables["portafoglio"].AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento"));
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
|
|
public virtual bool isAssetClass()
|
|
{
|
|
return GetOption<Opzione3_1>().Valore;
|
|
}
|
|
|
|
public virtual bool isControvalore()
|
|
{
|
|
return !GetOption<Opzione3_2>().Valore;
|
|
}
|
|
|
|
public virtual string getTesto1()
|
|
{
|
|
var asset = "";
|
|
var controvalore = "";
|
|
asset = !isAssetClass() ? "macro asset class" : "asset class";
|
|
controvalore = isControvalore() ? "di controvalore" : "percetuali";
|
|
var testo = "In questa scheda è riportato il confronto, sulla base delle principali " + asset + " ";
|
|
testo += "finanziarie, tra il patrimonio destinato all'area Riserva e il relativo portafoglio modello, ";
|
|
testo += "con evidenza dell'esposizione, in termini " + controvalore + ", a ciascuna " + asset + ", e ";
|
|
testo += "con indicazione del grado di Aderenza.";
|
|
|
|
return Helper.ReplaceVariables(testo, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
public virtual string getNota1()
|
|
{
|
|
// Nota Portafoglio ConsigliatoFF
|
|
|
|
var aderenza = datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale.FirstOrDefault(l => l.portafoglioModello.area.Equals("Ris")).aderenza.portafoglioConsiderato;
|
|
var gradoCoperturaVar = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.FirstOrDefault(o => o.area.Equals("Ris")).progetti.FirstOrDefault().progettoVarInfos.stat.copertura;
|
|
|
|
var distribuzione = isAssetClass() ? datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.distribuzioneAree.Where(o => o.area.Equals("Ris")).FirstOrDefault() != null ? datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.distribuzioneAree.Where(o => o.area.Equals("Ris")).FirstOrDefault().distribuzione
|
|
: null : datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzioneAree.Where(o => o.area.Equals("Ris")).FirstOrDefault() != null ? datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzioneAree.Where(o => o.area.Equals("Ris")).FirstOrDefault().distribuzione : null;
|
|
var gradoCoperturaAllocation = distribuzione != null ? distribuzione.coverageCC * 100 : 0;
|
|
var prodottinonrapp = distribuzione != null ? distribuzione.totaleNonRappr : 0;
|
|
|
|
string nota = "";
|
|
if (gradoCoperturaAllocation < 100)
|
|
{
|
|
string var = isAssetClass() ? "asset" : "macro asset";
|
|
nota += string.Format("Grado di copertura (%) della rappresentazione grafica per " + var + " allocation pari a {0}", Helper.FormatDecimal(gradoCoperturaAllocation.ToString(), 2))
|
|
+ (prodottinonrapp > 0 ? string.Format(": non sono considerati i prodotti non rappresentabili ({0}).", Helper.FormatDecimal(prodottinonrapp.ToString(), 2)) : ". ");
|
|
}
|
|
if (aderenza != 0 && aderenza != 100)
|
|
nota += string.Format(" Portafoglio considerato nel calcolo dell'aderenza (%): {0}.", Helper.FormatDecimal(aderenza.ToString(), 2));
|
|
return nota;
|
|
}
|
|
|
|
public virtual string getNota2()
|
|
{
|
|
var gradoCoperturaVar = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.FirstOrDefault(o => o.area.Equals("Ris")).progetti.FirstOrDefault().progettoVarInfos.stat.copertura;
|
|
|
|
string nota = "";
|
|
if (gradoCoperturaVar < 100)
|
|
{
|
|
nota = string.Format("Grado di copertura prodotti in termini di Rischio Mercato (VaR): {0}.", Helper.FormatDecimal(gradoCoperturaVar.ToString(), 2));
|
|
}
|
|
return nota;
|
|
}
|
|
//public virtual string getNota3()
|
|
//{
|
|
// var patrimonioCasa = datiSeiUnico.patrimonioUnit().patrimonioCasa;
|
|
// var pianificazione = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale;
|
|
// var aderenza = datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale.Where(l => l.portafoglioModello.area.Equals("Ris")).FirstOrDefault().aderenza.valoreAderenza;
|
|
// string nota = "";
|
|
// string nota1 = "";
|
|
// string nota2 = "";
|
|
|
|
// if (!isAssetClass())
|
|
// {
|
|
// if ( patrimonioCasa.macroAssetClass.distribuzione.coverageCC != 100)
|
|
// {
|
|
// nota += string.Format("Grado di copertura (%) della rappresentazione grafica per macro asset allocation pari a {0}",Helper.FormatDecimal(patrimonioCasa.macroAssetClass.distribuzione.coverageCC.ToString(), 2));
|
|
// nota1 += patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr > 0 ? string.Format(": non sono considerati i prodotti non rappresentabili ({0} €)",Helper.FormatCurrency(patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr.ToString())) : "";
|
|
|
|
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// if ( patrimonioCasa.assetClass.distribuzione.coverageCC != 100)
|
|
// {
|
|
// nota += string.Format("Grado di copertura (%) della rappresentazione grafica per asset allocation pari a {0}", Helper.FormatDecimal(patrimonioCasa.assetClass.distribuzione.coverageCC.ToString(), 2));
|
|
// nota1 += patrimonioCasa.assetClass.distribuzione.totaleNonRappr > 0 ? string.Format(": non sono considerati i prodotti non rappresentabili ({0} €).",Helper.FormatCurrency(patrimonioCasa.assetClass.distribuzione.totaleNonRappr.ToString())) : ".";
|
|
|
|
// }
|
|
// }
|
|
|
|
// if (aderenza > 0)
|
|
// {
|
|
// nota2 += "Portafoglio considerato nel calcolo dell'aderenza (%): {0}.";
|
|
// nota2 = string.Format(nota2, Helper.FormatCurrency(aderenza.ToString()));
|
|
// }
|
|
// return nota + nota1 + nota2;
|
|
//}
|
|
|
|
//public virtual string getNota2()
|
|
//{
|
|
// // Nota Grado Copertura
|
|
// var gradoCopertura = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.varInfos.stat.copertura;
|
|
// string nota = "";
|
|
// if (gradoCopertura < 100)
|
|
// {
|
|
// if (getNota1().Length > 0 && getNota3().Length > 0)
|
|
// nota += "(**) Grado di copertura prodotti in termini di Rischio Mercato (VaR): {0}.";
|
|
// else
|
|
// nota += "Grado di copertura prodotti in termini di Rischio Mercato (VaR): {0}.";
|
|
// nota = string.Format(nota, Helper.FormatDecimal(gradoCopertura.ToString(), 2));
|
|
// }
|
|
// return nota;
|
|
//}
|
|
|
|
//public virtual string getNota1()
|
|
//{
|
|
// // Nota Portafoglio Consigliato
|
|
// var patrimonioCasa = datiSeiUnico.patrimonioUnit().patrimonioCasa;
|
|
// var pianificazione = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale;
|
|
|
|
// string nota = "";
|
|
// string nota1 = "";
|
|
// if (!isAssetClass())
|
|
// {
|
|
// if (patrimonioCasa.macroAssetClass.distribuzione.coverageCC < 100)
|
|
// {
|
|
// nota += "Grado di copertura (%) della rappresentazione grafica per macro asset allocation pari a {0}: ";
|
|
// nota1 += "non sono considerati i prodotti non rappresentabili ({0} €).";
|
|
|
|
// nota = string.Format(nota, Helper.FormatDecimal(patrimonioCasa.macroAssetClass.distribuzione.coverageCC.ToString(), 2));
|
|
// nota1 = string.Format(nota1, Helper.FormatCurrency(patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr.ToString()));
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// if (patrimonioCasa.assetClass.distribuzione.coverageCC < 100)
|
|
// {
|
|
// nota += "Grado di copertura (%) della rappresentazione grafica per asset allocation pari a {0}: ";
|
|
// nota1 += "non sono considerati i prodotti non rappresentabili ({0} €).";
|
|
|
|
// nota = string.Format(nota, Helper.FormatDecimal(patrimonioCasa.macroAssetClass.distribuzione.coverageCC.ToString(), 2));
|
|
// nota1 = string.Format(nota1, Helper.FormatCurrency(patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr.ToString()));
|
|
// }
|
|
// }
|
|
// return nota + nota1;
|
|
//}
|
|
//public virtual string getNoteCompleto(bool nota3)
|
|
//{
|
|
// string nota = "";
|
|
// if (getNota3().Length > 0)
|
|
// nota = getNota3() + (getNota2().Length > 0 ? "<BR>" : "");
|
|
// else
|
|
// nota = getNota1() + (getNota2().Length > 0 ? "<BR>" : "");
|
|
// if (getNota2().Length > 0)
|
|
// nota += getNota2();
|
|
// return nota;
|
|
|
|
//}
|
|
private int GetNumericStringWidth(string number)
|
|
{
|
|
int width = 0;
|
|
foreach (char s in number)
|
|
{
|
|
if (s == '.' || s == ',')
|
|
{
|
|
width += 1;
|
|
}
|
|
else if (s == '%')
|
|
{
|
|
width += 8;
|
|
}
|
|
else
|
|
{
|
|
width += 5;
|
|
}
|
|
}
|
|
return width;
|
|
}
|
|
}
|
|
}
|