574 lines
30 KiB
C#
574 lines
30 KiB
C#
using System;
|
|
using Consulenza.ReportWriter.Business;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using System.Data;
|
|
using Consulenza.DataServices.fideuram.data.service;
|
|
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>
|
|
/// S26.RiservaDettaglioPortafoglioModello idSezione = 69
|
|
/// </summary>
|
|
public class S26 : Entity.Section
|
|
{
|
|
public S26(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S26", 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 Patrimonio
|
|
|
|
|
|
var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["patrimonio"])
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = false,
|
|
Footer = false,
|
|
AlternateRow = false,
|
|
RowHeight = 25
|
|
};
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("controvalore", 130, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "controvalore", string.Empty) { PaddingLeft = 1 });
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingRight = 15, BackgroundColor = ColorPDF.Bianco });
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 130, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty) { PaddingLeft = 5 });
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("val", 125, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "val", string.Empty) { PaddingRight = 15, BackgroundColor = ColorPDF.Bianco });
|
|
|
|
int e = 0;
|
|
foreach (DataRow dro in dati.Tables["patrimonio"].Rows)
|
|
{
|
|
tabellaPatrimonio.Cells[2, e].BackgroundColor = dro["descrizione"].ToString() == "" ? ColorPDF.Bianco : ColorPDF.Standard_Grigio_SfondoColonnaTabella;
|
|
e++;
|
|
}
|
|
|
|
//AddElement(new SpacePDF(15));
|
|
AddElement(tabellaPatrimonio);
|
|
AddElement(new SpacePDF(20));
|
|
#endregion
|
|
|
|
#region Testo grafico
|
|
AddElement(new FormattedTextAreaPDF(getTesto2(), EnvironmentFacade.RendererFacade.XLeftLimit, 255) {TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
|
|
AddElement(new FormattedTextAreaPDF("Possibile evoluzione del rendimento", EnvironmentFacade.RendererFacade.XLeftLimit + 260, 255) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
|
|
#endregion
|
|
|
|
#region Asset/Macro Asset + Grafico a barre
|
|
AddElement(new SpacePDF(15));
|
|
AddElement(new RectanglePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["asset"].Rows.Count * 30 + 20, 255, ColorPDF.Bianco) { BorderWidth = 0.5F, BorderColor = ColorPDF.ConsulenzaUnica_Grigio_SfondoColonnaHeaderFooterTabella, AutoIncrementYWritable = false });
|
|
|
|
#region Grafico a barre
|
|
|
|
var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 110, 1F)
|
|
{
|
|
HeightSingleBar = 30,
|
|
Width = 140,
|
|
LabelFormatAxisY = FormatType.Intero,
|
|
ShowLabelAxisY = false,
|
|
ShowLineAxisY = false,
|
|
ShowLineAxisX = true,
|
|
ShowLabelPoints = true,
|
|
AutoIncrementYWritable = false,
|
|
BorderLineTop = true,
|
|
BorderLineX = 1,
|
|
BorderLineWidth = 1,
|
|
Height = 400 //400
|
|
};
|
|
|
|
var serieCollezione = new List<Serie> { new Serie { Name = "Patrimoni", Border = true, PointWidth = "0.6" } };
|
|
var datiasset = dati.Tables["asset"];
|
|
Double maxValuePerc = 0.0;
|
|
foreach (DataRow item in datiasset.Rows)
|
|
{
|
|
if (Convert.ToDouble(item["Percentuale"]) > maxValuePerc)
|
|
{
|
|
maxValuePerc = Convert.ToDouble(item["Percentuale"]);
|
|
}
|
|
serieCollezione[0].Points.Add(new Point
|
|
{
|
|
ShowLabelAxisY = true,
|
|
LabelAxisY = Helper.FormatDecimal(item["Percentuale"].ToString(),2),//non vogliono il simbolo %
|
|
FontSizeLabelAxisY = 7,
|
|
|
|
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
|
Value = Convert.ToDouble(item["Percentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["Percentuale"]),
|
|
|
|
ShowLabelAxisX = true,
|
|
LabelAxisX = string.Format("{0}<BR/>", item["Patrimonio"].ToString()),
|
|
FontSizeLabelAxisX = 7,
|
|
FontColorLabelAxisX = ColorPDF.Nero,
|
|
FontBoldLabelAxisY = false
|
|
});
|
|
}
|
|
|
|
graficoBarre.SeriesCollection = serieCollezione;
|
|
graficoBarre.MaximumValueAxisY = maxValuePerc + 10;
|
|
|
|
#endregion
|
|
|
|
AddElement(graficoBarre);
|
|
AddElement(new RectanglePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 260, 140, 255, ColorPDF.Bianco) { BorderWidth = 0.5F, BorderColor = ColorPDF.ConsulenzaUnica_Grigio_SfondoColonnaHeaderFooterTabella, AutoIncrementYWritable = false });
|
|
AddElement(new SpacePDF(6));
|
|
#endregion
|
|
|
|
#region Possibile Evoluzione Rendimento + Grafico combination
|
|
var graficoCombination = new CombinationPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 300, 1F)
|
|
{
|
|
Height = 100,
|
|
Width = 190,
|
|
MinorGridAxisY = true,
|
|
MarginAxisY = 0,
|
|
ShowLineAxisY = true,
|
|
ShowLabelAxisY = true,
|
|
LabelFormatAxisY = FormatType.Percentuale,
|
|
LabelFormatAxisX = FormatType.DataShort,
|
|
ShowLineAxisX = true,
|
|
IntervalNumberAxisX = 5,
|
|
showZeroInLabel = true
|
|
};
|
|
|
|
var serieCombination = new List<Serie>();
|
|
serieCombination.Add(new Serie { Name = "Ottimistico", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 6 });
|
|
if(presenzaColonnaScenarioMedio())
|
|
serieCombination.Add(new Serie { Name = "Medio", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 6 });
|
|
serieCombination.Add(new Serie { Name = "Pessimistico", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 6 });
|
|
serieCombination.Add(new Serie { Name = "Zero", Type = Dundas.Charting.WebControl.SeriesChartType.StepLine, BorderWidth = 6 });
|
|
|
|
//var dts = dati.Tables["evoluzioneRendimento"].AsEnumerable().OrderBy(o => o.Field<DateTime>("Data")).CopyToDataTable();
|
|
|
|
foreach (DataRow item in dati.Tables["evoluzioneRendimento"].Rows)
|
|
{
|
|
#region Serie Ottimistico
|
|
serieCombination[0].Points.Add(new Point
|
|
{
|
|
Color = new ColorPDF(114, 174, 198),
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["Ottimistico"])),
|
|
ShowLabelAxisY = false,
|
|
FontSizeLabelAxisY = 7,
|
|
FontSizeLabelAxisX = 7,
|
|
LabelAxisY = Helper.FormatPercentage(Convert.ToDecimal(item["Ottimistico"]), 2),
|
|
FontBoldLabelAxisY = false,
|
|
ShowLabelAxisX = false
|
|
});
|
|
#endregion
|
|
|
|
#region Serie Medio
|
|
if (presenzaColonnaScenarioMedio())
|
|
{
|
|
serieCombination[1].Points.Add(new Point
|
|
{
|
|
Color = new ColorPDF(255, 0, 0),
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["Medio"])),
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = Helper.FormatPercentage(Convert.ToDecimal(item["Medio"]), 2),
|
|
FontSizeLabelAxisY = 7,
|
|
FontBoldLabelAxisY = false,
|
|
FontSizeLabelAxisX = 7,
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
#region Serie Pessimistico
|
|
if (presenzaColonnaScenarioMedio())
|
|
{
|
|
serieCombination[2].Points.Add(new Point
|
|
{
|
|
Color = new ColorPDF(0, 0, 0),
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["Pessimistico"])),
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = Helper.FormatPercentage(Convert.ToDecimal(item["Pessimistico"]), 2),
|
|
FontSizeLabelAxisY = 7,
|
|
FontBoldLabelAxisY = false,
|
|
FontSizeLabelAxisX = 7,
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
else
|
|
{
|
|
serieCombination[1].Points.Add(new Point
|
|
{
|
|
Color = new ColorPDF(255, 0, 0),
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["Pessimistico"])),
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = Helper.FormatPercentage(Convert.ToDecimal(item["Pessimistico"]), 2),
|
|
FontSizeLabelAxisY = 7,
|
|
FontBoldLabelAxisY = false,
|
|
FontSizeLabelAxisX = 7,
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
graficoCombination.SeriesCollection = serieCombination;
|
|
graficoCombination.MaximumValueAxisY = graficoCombination.GetMaximumValueYPoints()+graficoCombination.IntervalNumberAxisX;// - ((graficoCombination.GetMaximumValueYPoints() - graficoCombination.GetMinimumValueYPoints()) / graficoCombination.IntervalNumberAxisY);
|
|
|
|
AddElement(new SpacePDF(10));
|
|
AddElement(graficoCombination);
|
|
AddElement(new SpacePDF(45));
|
|
|
|
#endregion
|
|
|
|
#region Scenari
|
|
//var dtscenari = new DataTable();
|
|
//dtscenari.Columns.Add("Rettangolo",typeof(string));
|
|
//dtscenari.Columns.Add("Descrizione", typeof(string));
|
|
//dtscenari.Columns.Add("Valore", typeof(decimal));
|
|
//foreach (DataRow ro in dati.Tables["scenario"].Rows)
|
|
//{
|
|
// dtscenari.Rows.Add("", ro["Descrizione"].ToString(),Convert.ToDecimal(ro["Valore"]));
|
|
//}
|
|
|
|
var tabellaScenari = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 260, dati.Tables["scenario"])
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = true,
|
|
Footer = true,
|
|
AlternateRow = false,
|
|
RowHeight = 25,
|
|
ShowBorderLastLine = true
|
|
};
|
|
|
|
|
|
foreach (DataRow row in dati.Tables["scenario"].Rows)
|
|
{
|
|
switch (row["Descrizione"].ToString())
|
|
{
|
|
case "Ottimistico":
|
|
tabellaScenari.Cells[0, 0].ValueObject = new RectanglePDF(2, 25, new ColorPDF(114, 174, 198));
|
|
tabellaScenari.Cells[2, 0].Value = Helper.FormatCurrency(Convert.ToDecimal(row["Valore"]).ToString());
|
|
break;
|
|
case "Medio":
|
|
if (presenzaColonnaScenarioMedio())
|
|
{
|
|
tabellaScenari.Cells[0, 1].ValueObject = new RectanglePDF(2, 25, new ColorPDF(0, 0, 0));
|
|
tabellaScenari.Cells[2, 1].Value = Helper.FormatCurrency(Convert.ToDecimal(row["Valore"]).ToString());
|
|
}
|
|
break;
|
|
case "Pessimistico":
|
|
if (presenzaColonnaScenarioMedio())
|
|
{
|
|
tabellaScenari.Cells[0, 2].ValueObject = new RectanglePDF(2, 25, new ColorPDF(255, 0, 0));
|
|
tabellaScenari.Cells[2, 2].Value = Helper.FormatCurrency(Convert.ToDecimal(row["Valore"]).ToString());
|
|
}
|
|
else
|
|
{
|
|
tabellaScenari.Cells[0, 1].ValueObject = new RectanglePDF(2, 25, new ColorPDF(255, 0, 0));
|
|
tabellaScenari.Cells[2, 1].Value = Helper.FormatCurrency(Convert.ToDecimal(row["Valore"]).ToString());
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//int a = 0;
|
|
//foreach (DataRow row in dati.Tables["scenario"].Rows)
|
|
// {
|
|
// if (row["Descrizione"].ToString().Equals("Ottimistico"))
|
|
// tabellaScenari.Cells[0, a].ValueObject = new RectanglePDF(2, 15, new ColorPDF(114, 174, 198));
|
|
// else if (row["Descrizione"].ToString().Equals("Pessimistico"))
|
|
// tabellaScenari.Cells[0, a].ValueObject = new RectanglePDF(2, 15, new ColorPDF(233, 202, 133));
|
|
// else
|
|
// tabellaScenari.Cells[0, a].ValueObject = new RectanglePDF(2, 15, new ColorPDF(0,0,0));
|
|
// tabellaScenari.Cells[2, a].Value = Helper.FormatCurrency(Convert.ToDecimal(row["Valore"]).ToString());
|
|
// a++;
|
|
//}
|
|
tabellaScenari.Columns.Add(new ColumnPDF("img", 37, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "Rettangolo", "Scenari") { PaddingLeft = 5, DeltaYContent = 12, HeaderFontBold = true, HeaderFontSize = 7 });
|
|
tabellaScenari.Columns.Add(new ColumnPDF("descr", 128, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", "possibili") { PaddingLeft = 0, FontSize = 7, HeaderFontSize = 7, HeaderFontBold = true });
|
|
tabellaScenari.Columns.Add(new ColumnPDF("valore", 90, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Valore", "A scadenza (%)") { FontSize = 7, HeaderFontSize = 7 });
|
|
|
|
AddElement(new SpacePDF(10));
|
|
AddElement(tabellaScenari);
|
|
#endregion
|
|
|
|
#region Statistiche
|
|
if (presenzaTabellaStatistiche() && dati.Tables["statistica"].Rows.Count > 0)
|
|
{
|
|
var tabellaStatistiche = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 260, dati.Tables["statistica"])
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = true,
|
|
Footer = true,
|
|
AlternateRow = false,
|
|
RowHeight = 25,
|
|
ShowBorderLastLine = true
|
|
};
|
|
tabellaStatistiche.Columns.Add(new ColumnPDF("descrst", 165, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", "Statistiche") { PaddingLeft = 5, FontSize = 7, HeaderFontSize = 7 });
|
|
tabellaStatistiche.Columns.Add(new ColumnPDF("valorest", 90, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Valore", "") { PaddingLeft = 5, FontSize = 7, HeaderFontSize=7 });
|
|
|
|
AddElement(new SpacePDF(10));
|
|
AddElement(tabellaStatistiche);
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <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 + Servizi
|
|
//bool rischio = false;
|
|
//int i=0;
|
|
var _pianificazione = datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale.Where(l => l.portafoglioModello.area.Equals("Ris")).ToArray();
|
|
var rischiovar = _pianificazione[0].varPianificatoDec;
|
|
var portafogliomodello = _pianificazione[0].portafoglioModello;
|
|
var cono = _pianificazione[0].cono.ToList();
|
|
//var _pianificazione = datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale;
|
|
//while (rischio == false)
|
|
//{
|
|
// if (!_pianificazione[i].portafoglioModelloarea.Equals("Ris"))
|
|
// i++;
|
|
// else
|
|
// rischio = true;
|
|
//}
|
|
|
|
//var rischiovar = _pianificazione[i].varPianificatoDec;
|
|
//var portafogliomodello = _pianificazione[i].portafoglioModello;
|
|
//var cono = _pianificazione[i].cono.ToList();
|
|
//var ds = new DataSet();
|
|
#endregion
|
|
|
|
#region Definizione Dataset
|
|
var ds = new DataSet();
|
|
|
|
ds.Tables.Add(new DataTable("patrimonio"));
|
|
ds.Tables.Add(new DataTable("asset"));
|
|
ds.Tables.Add(new DataTable("evoluzioneRendimento"));
|
|
ds.Tables.Add(new DataTable("scenario"));
|
|
ds.Tables.Add(new DataTable("statistica"));
|
|
#endregion
|
|
|
|
#region Patrimonio
|
|
|
|
//ds.Tables["patrimonio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
//ds.Tables["patrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("controvalore"));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("valore"));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("descrizione"));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("val"));
|
|
|
|
ds.Tables["patrimonio"].Rows.Add("Orizzonte temporale", portafogliomodello.orizzonteTemporale.ToString() + " anni", "Rischio Mercato (VaR %)", rischiovar);
|
|
|
|
//ds.Tables["patrimonio"].Rows.Add("Orizzonte temporale", portafogliomodello.orizzonteTemporale.ToString() + " anni");
|
|
//ds.Tables["patrimonio"].Rows.Add("Rischio Mercato (VaR %)", rischiovar);
|
|
#endregion
|
|
|
|
#region Asset/Macro Assett
|
|
ds.Tables["asset"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
|
|
ds.Tables["asset"].Columns.Add(new DataColumn("Red", typeof(int)));
|
|
ds.Tables["asset"].Columns.Add(new DataColumn("Green", typeof(int)));
|
|
ds.Tables["asset"].Columns.Add(new DataColumn("Blue", typeof(int)));
|
|
ds.Tables["asset"].Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
|
|
ds.Tables["asset"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
//int livelloasset = !isAssetClass() ? 1 : 2;
|
|
//pure gli oggetti colore so diversi tra loro, per la stessa sezione :( evviva la staticità
|
|
var dtptfModello = portafogliomodello.distribuzioniPtfModello.Where(l => l.asset.livello == (!isAssetClass() ? 1 : 2)).ToList();
|
|
|
|
if (!isAssetClass())//livelloasset == 1)
|
|
{
|
|
var displayInfo = datiSeiUnico.displayInfos().macroAssetDisplayInfos;
|
|
foreach (var valore in from c in displayInfo
|
|
join l in dtptfModello
|
|
on c.key equals l.asset.asset
|
|
where (l.asset.livello == (!isAssetClass() ? 1 : 2))
|
|
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["asset"].Rows.Add(
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
Convert.ToDecimal(valore.percentuale * 100),
|
|
valore.order
|
|
);
|
|
//foreach (var item in from o in portafogliomodello.distribuzioniPtfModello where (o.asset.livello == (!isAssetClass() ? 1 : 2)) select o)
|
|
//{
|
|
|
|
// var mapDisplayInfo = displayInfo.Where(l => l.key == item.asset.asset).ToArray();
|
|
// var colore = new ColorPDF(mapDisplayInfo[0].value.fill);
|
|
// var ordinamento = mapDisplayInfo[0].value.order;
|
|
// ds.Tables["asset"].Rows.Add(item.asset.descrizione, colore.Red, colore.Green, colore.Blue, Convert.ToDecimal(item.percentuale * 100), ordinamento);
|
|
//}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var displayInfo = datiSeiUnico.displayInfos().assetDisplayInfos;
|
|
foreach (var valore in from c in displayInfo
|
|
join l in dtptfModello
|
|
on c.key equals l.asset.asset
|
|
where (l.asset.livello == (!isAssetClass() ? 1 : 2))
|
|
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["asset"].Rows.Add(
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
Convert.ToDecimal(valore.percentuale * 100),
|
|
valore.order
|
|
);
|
|
// foreach (var item in from o in portafogliomodello.distribuzioniPtfModello where (o.asset.livello == (!isAssetClass() ? 1 : 2)) select o)
|
|
//{
|
|
// var mapDisplayInfo = displayInfo.Where(l => l.key == item.asset.asset).ToArray();
|
|
// var colore = new ColorPDF(mapDisplayInfo[0].value.fill);
|
|
// var ordinamento = mapDisplayInfo[0].value.order;
|
|
// ds.Tables["asset"].Rows.Add(item.asset.descrizione, colore.Red, colore.Green, colore.Blue, Convert.ToDecimal(item.percentuale * 100), ordinamento);
|
|
//}
|
|
}
|
|
}
|
|
// VEDI 27
|
|
ds.Tables["asset"].AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento"));
|
|
#endregion
|
|
|
|
#region Evoluzione rendimento
|
|
ds.Tables["evoluzioneRendimento"].Columns.Add(new DataColumn("Data", typeof(DateTime)));
|
|
ds.Tables["evoluzioneRendimento"].Columns.Add(new DataColumn("Ottimistico", typeof(decimal)));
|
|
if (presenzaColonnaScenarioMedio())
|
|
ds.Tables["evoluzioneRendimento"].Columns.Add(new DataColumn("Medio", typeof(decimal)));
|
|
ds.Tables["evoluzioneRendimento"].Columns.Add(new DataColumn("Pessimistico", typeof(decimal)));
|
|
|
|
foreach (var item in cono)
|
|
{
|
|
if (presenzaColonnaScenarioMedio())
|
|
ds.Tables["evoluzioneRendimento"].Rows.Add(item.dtRiferimento, Convert.ToDecimal(item.quantileSup * 100), Convert.ToDecimal(item.quantileInf * 100), Convert.ToDecimal(item.quantileInter * 100));
|
|
else
|
|
ds.Tables["evoluzioneRendimento"].Rows.Add(item.dtRiferimento, Convert.ToDecimal(item.quantileSup * 100), Convert.ToDecimal(item.quantileInf * 100));
|
|
}
|
|
#endregion
|
|
|
|
#region Scenari
|
|
var valoreott = cono.AsEnumerable().OrderByDescending(x => x.dtRiferimento).First().quantileSup;
|
|
var valorepes = cono.AsEnumerable().OrderByDescending(x => x.dtRiferimento).First().quantileInf;
|
|
var valoremed = cono.AsEnumerable().OrderByDescending(x => x.dtRiferimento).First().quantileInter;
|
|
|
|
ds.Tables["scenario"].Columns.Add(new DataColumn("Rettangolo", typeof(string)));
|
|
ds.Tables["scenario"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
ds.Tables["scenario"].Columns.Add(new DataColumn("Valore", typeof(decimal)));
|
|
|
|
ds.Tables["scenario"].Rows.Add("", "Ottimistico", Convert.ToDecimal(valoreott * 100));
|
|
if (presenzaColonnaScenarioMedio())
|
|
ds.Tables["scenario"].Rows.Add("", "Medio", Convert.ToDecimal(valoremed * 100));
|
|
ds.Tables["scenario"].Rows.Add("", "Pessimistico", Convert.ToDecimal(valorepes * 100));
|
|
|
|
|
|
#endregion
|
|
|
|
#region Statistiche
|
|
if (presenzaTabellaStatistiche())
|
|
{
|
|
ds.Tables["statistica"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
ds.Tables["statistica"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["statistica"].Rows.Add("Tempo minimo di investimento", _pianificazione[0].minTimeDec);//poi vediamo se un valore è 1 anno e 2 mesi e perdita stimata in percentuale....mah
|
|
ds.Tables["statistica"].Rows.Add("Perdita massima stimata (%)", Helper.FormatDecimal((_pianificazione[0].maxLoss * 100).ToString(), 2));
|
|
}
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
public virtual bool isAssetClass()
|
|
{
|
|
// livello = 1 -> Macro Asset
|
|
// livello = 2 -> Asset
|
|
return GetOption<Opzione3>().Valore;
|
|
}
|
|
|
|
public virtual bool presenzaColonnaScenarioMedio()
|
|
{
|
|
return GetOption<Opzione4_1>().Valore;
|
|
}
|
|
|
|
public virtual bool presenzaTabellaStatistiche()
|
|
{
|
|
return GetOption<Opzione4_2>().Valore;
|
|
}
|
|
|
|
public virtual string getTesto1()
|
|
{
|
|
string testo = "";
|
|
//switch (!isAssetClass())
|
|
//{
|
|
// case true:
|
|
if (presenzaColonnaScenarioMedio())
|
|
testo += "In questa scheda sono riportate le informazioni di dettaglio relative al portafoglio modello associato all'area Riserva: orizzonte temporale, livello di rischio in termini di Rischio Mercato (VaR), macro asset allocation, possibile evoluzione del rendimento sulla base di tre scenari simulati (ottimistico, medio, pessimistico).";
|
|
else
|
|
testo += "In questa scheda sono riportate le informazioni di dettaglio relative al portafoglio modello associato all'area Riserva: orizzonte temporale, livello di rischio in termini di Rischio Mercato (VaR), macro asset allocation, possibile evoluzione del rendimento sulla base di due scenari simulati (ottimistico, pessimistico).";
|
|
//break;
|
|
|
|
// case false:
|
|
// if (presenzaColonnaScenarioMedio())
|
|
// testo += "In questa scheda sono riportate le informazioni di dettaglio relative al portafoglio modello associato all'area Riserva: orizzonte temporale, livello di rischio in termini di Rischio Mercato (VaR), asset allocation, possibile evoluzione del rendimento sulla base di due scenari simulati (ottimistico, pessimistico).";
|
|
// else
|
|
// testo += "In questa scheda sono riportate le informazioni di dettaglio relative al portafoglio modello associato all'area Riserva: orizzonte temporale, livello di rischio in termini di Rischio Mercato (VaR), asset allocation, possibile evoluzione del rendimento sulla base di tre scenari simulati (ottimistico, medio, pessimistico).";
|
|
// break;
|
|
//}
|
|
return Helper.ReplaceVariables(testo, base.EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
|
|
public virtual string getTesto2()
|
|
{
|
|
return !isAssetClass() ? "Macro asset class (%)" : "Asset class (%)";
|
|
}
|
|
}
|
|
}
|