590 lines
36 KiB
C#
590 lines
36 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.ReportWriter.Business.Entity;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Consulenza.ReportCommon;
|
|
using Consulenza.ReportWriter.Manager.Integration;
|
|
using Consulenza.ReportWriter.Business.CUSTOM_PDF.ConsulenzaUnica;
|
|
using Consulenza.DataServices.fideuram.data.service;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// S29. idSezione = 72
|
|
/// </summary>
|
|
public class S29 : Entity.Section
|
|
{
|
|
public string Area = "Inv";
|
|
|
|
public string TitoloProgetto { get; set; }
|
|
public long ChiaveProgetto { get; set; }
|
|
public S29(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S29", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
|
|
protected override sealed void Draw()
|
|
{
|
|
|
|
var dati = GetDataSet();
|
|
for (int i = 0; i < dati.Tables["NomeProgetto"].Rows.Count; i++)
|
|
{
|
|
TitoloProgetto = dati.Tables["NomeProgetto"].Rows[i]["NomeProgetto"].ToString();
|
|
string titolospezzato = TitoloProgetto.Length > 23 ? TitoloProgetto.Substring(0, 23) + "..." : TitoloProgetto;
|
|
ChiaveProgetto = long.Parse(dati.Tables["NomeProgetto"].Rows[i]["ChiaveProgetto"].ToString());
|
|
AddElement(new PagePDF(PagePDF.PagePDFType.Generic));
|
|
|
|
var intestazione = new SectionHeadingPDF(
|
|
"Progetto «" + titolospezzato + "»: portafoglio modello vs attuale",
|
|
|
|
EnvironmentFacade.RendererFacade.XLeftLimit,
|
|
EnvironmentFacade.RendererFacade.YUpperLimit,
|
|
EnvironmentFacade.ReportEnvironment.FontFamily);
|
|
|
|
AddElement(intestazione.ToElement());
|
|
|
|
AddElement(new SpacePDF(20));
|
|
if (dati.Tables["portafoglio" + i].Rows.Count > 0)
|
|
{
|
|
DataTable dtOrdinamento = dati.Tables["portafoglio" + i].AsEnumerable().OrderBy(l => l.Field<int>("Ordinamento")).CopyToDataTable();
|
|
|
|
if (getTesto1().Length > 0)
|
|
{
|
|
AddElement(new FormattedTextAreaPDF(getTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) {FontSize=7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
|
AddElement(new SpacePDF(15));
|
|
}
|
|
|
|
var tabellaCtv = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["labelControvalore" + i])
|
|
{
|
|
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, PaddingRight = 4 });
|
|
|
|
AddElement(tabellaCtv);
|
|
AddElement(new SpacePDF(20));
|
|
|
|
string signValue = isControvalore() ? "(€)" : "(%)";
|
|
|
|
#region ASSET - MACRO ASSET
|
|
|
|
var tabellaAsset = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dtOrdinamento)
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = true,
|
|
Footer = false,
|
|
AlternateRow = false,
|
|
RowHeight = 28,
|
|
ShowSeparationLines = false,
|
|
PageBreak = true,
|
|
HeaderTextHorizontalAlign = HorizontalAlignmentType.Sinistra,
|
|
ShowBorderHeader = true
|
|
|
|
};
|
|
tabellaAsset.Columns.Add(new ColumnPDF("descrizione", 150, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", "Asset class") { HeaderFontSize = 7, FontSize = 7});
|
|
tabellaAsset.Columns.Add(new ColumnPDF("portafogliomodello", 185, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "PercentualeControvaloreModello", "Portafoglio modello " + signValue) { 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 " + signValue) { HeaderFontSize = 7,HeaderPaddingLeft=10, PaddingLeft=3, DeltaYContent = 2, FontSize = 7 });
|
|
int o = 0;
|
|
var list = new List<double>();
|
|
list.Add(Convert.ToDouble(dati.Tables["portafoglio" + i].AsEnumerable().Max(x => x["PercentualeControvaloreModello"])));
|
|
list.Add(Convert.ToDouble(dati.Tables["portafoglio" + i].AsEnumerable().Max(x => x["PercentualeControvaloreAttuale"])));
|
|
var max = (float)Helper.Round(list.Max());
|
|
|
|
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
|
|
width = tabellaAsset.Columns[1].Width - (isControvalore() ? 50 : 20);
|
|
larghezzaBarra = Helper.GetWidthProportional(Convert.ToDouble(row["PercentualeControvaloreModello"]) == 0 ? (float)0.01 : (float)Convert.ToDouble(row["PercentualeControvaloreModello"]), max, width);
|
|
deltaXBarra = Convert.ToDouble(row["PercentualeControvaloreModello"]) == 0 ? -larghezzaBarra + 10 : -larghezzaBarra + (isControvalore() ? 0 : 7);
|
|
if (Convert.ToDouble(row["PercentualeControvaloreModello"]) == 0 && Convert.ToDouble(row["PercentualeControvaloreAttuale"]) == 0)
|
|
{
|
|
tabellaAsset.Cells[1, o].ValueObjectList = new List<Business.Entity.ObjectPDF>()
|
|
{
|
|
|
|
new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreModello"].ToString()) : Helper.FormatDecimal(row["PercentualeControvaloreModello"].ToString(), 2), deltaXBarra-10, isControvalore()? 50 : 35)
|
|
{
|
|
DeltaY =4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
|
|
DeltaX = 20,
|
|
FontSize = 7
|
|
},
|
|
new RectanglePDF(12, 1 , ColorPDF.Bianco){DeltaY = 4}
|
|
};
|
|
tabellaAsset.Cells[2, o].ValueObjectList = new List<Business.Entity.ObjectPDF>()
|
|
{
|
|
new RectanglePDF(12, 1 , ColorPDF.Bianco){DeltaY =4},
|
|
new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreAttuale"].ToString()) :Helper.FormatDecimal(row["PercentualeControvaloreAttuale"].ToString(), 2), deltaXBarra-10, isControvalore()? 50 : 35)
|
|
{
|
|
DeltaY =4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
DeltaX = -20,
|
|
FontSize = 7
|
|
}
|
|
};
|
|
}
|
|
else
|
|
{
|
|
if (Convert.ToDouble(row["PercentualeControvaloreModello"]) == 0)
|
|
{
|
|
tabellaAsset.Cells[1, o].ValueObjectList = new List<Business.Entity.ObjectPDF>()
|
|
{
|
|
|
|
new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreModello"].ToString()) : Helper.FormatDecimal(row["PercentualeControvaloreModello"].ToString(), 2), deltaXBarra-10, isControvalore()? 50 : 35)
|
|
{
|
|
DeltaY =4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
|
|
DeltaX = isControvalore() ? deltaXBarra+20 : deltaXBarra+5,
|
|
FontSize = 7
|
|
},
|
|
new RectanglePDF(12, 1 , ColorPDF.Bianco){DeltaY = 4}
|
|
};
|
|
}
|
|
else
|
|
{
|
|
tabellaAsset.Cells[1, o].ValueObjectList = new List<Business.Entity.ObjectPDF>()
|
|
{
|
|
|
|
new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreModello"].ToString()) : Helper.FormatDecimal(row["PercentualeControvaloreModello"].ToString(), 2), deltaXBarra-10, isControvalore()? 60 : 35)
|
|
{
|
|
DeltaY =4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
|
|
DeltaX = isControvalore() ? deltaXBarra+15 : deltaXBarra,
|
|
FontSize = 7
|
|
},
|
|
new RectanglePDF(12, larghezzaBarra , colore){DeltaY = 4}
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
#region barra colonna Portafoglioattuale
|
|
width = tabellaAsset.Columns[2].Width - (isControvalore() ? 50 : 20);
|
|
larghezzaBarra = Helper.GetWidthProportional(Convert.ToDouble(row["PercentualeControvaloreAttuale"]) == 0 ? (float)0.01 : (float)Convert.ToDouble(row["PercentualeControvaloreAttuale"]), max, width);
|
|
deltaXBarra = Convert.ToDouble(row["PercentualeControvaloreAttuale"]) == 0 ? isControvalore() ? larghezzaBarra - 20 : larghezzaBarra - 10 : isControvalore() ? larghezzaBarra + 3 : larghezzaBarra - 5;
|
|
if (Convert.ToDouble(row["PercentualeControvaloreAttuale"]) == 0)
|
|
{
|
|
tabellaAsset.Cells[2, o].ValueObjectList = new List<Business.Entity.ObjectPDF>()
|
|
{
|
|
new RectanglePDF(12, 1 , ColorPDF.Bianco){DeltaY =4},
|
|
new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreAttuale"].ToString()) :Helper.FormatDecimal(row["PercentualeControvaloreAttuale"].ToString(), 2), deltaXBarra-10, isControvalore()? 50 : 35)
|
|
{
|
|
DeltaY =4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
DeltaX = isControvalore() ? deltaXBarra-10 : deltaXBarra-8,
|
|
FontSize = 7
|
|
}
|
|
};
|
|
}
|
|
else
|
|
{
|
|
tabellaAsset.Cells[2, o].ValueObjectList = new List<Business.Entity.ObjectPDF>()
|
|
{
|
|
new RectanglePDF(12, larghezzaBarra , colore){DeltaY = 4},
|
|
new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["PercentualeControvaloreAttuale"].ToString()) :Helper.FormatDecimal(row["PercentualeControvaloreAttuale"].ToString(), 2), deltaXBarra, isControvalore()? 60 : 35)
|
|
{
|
|
DeltaY =4,
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
DeltaX = isControvalore() ? deltaXBarra-15 : deltaXBarra,
|
|
FontSize = 7
|
|
}
|
|
};
|
|
}
|
|
}
|
|
#endregion
|
|
o++;
|
|
}
|
|
AddElement(new SpacePDF(5));
|
|
AddElement(tabellaAsset);
|
|
#endregion
|
|
|
|
if (getNota1().Length > 0)
|
|
{
|
|
AddElement(new SpacePDF(10));
|
|
tabellaAsset.Notes.Add(
|
|
new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella,
|
|
getNota1(),
|
|
new[] { "" },
|
|
string.Empty,
|
|
TableNotePDF.TableNoteAsteriskPositionType.CorpoTabella) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }
|
|
);
|
|
|
|
}
|
|
if (getNota2().Length > 0)
|
|
{
|
|
AddElement(new SpacePDF(10));
|
|
tabellaAsset.Notes.Add(
|
|
new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella,
|
|
getNota2(),
|
|
new[] { "" },
|
|
string.Empty,
|
|
TableNotePDF.TableNoteAsteriskPositionType.CorpoTabella) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }
|
|
);
|
|
//varAttuale.Text += note;
|
|
|
|
//note += "*";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataTable.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected sealed override DataTable GetDataTable()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataSet.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected override DataSet GetDataSet()
|
|
{
|
|
var ds = new DataSet();
|
|
ds.Tables.Add(new DataTable("NomeProgetto"));
|
|
ds.Tables["NomeProgetto"].Columns.Add(new DataColumn("NomeProgetto", typeof(string)));
|
|
ds.Tables["NomeProgetto"].Columns.Add(new DataColumn("ChiaveProgetto", typeof(string)));
|
|
var piramide = datiSeiUnico.piramideModelloUnit().piramideModello.areaModello.FirstOrDefault(o => o.area.ToLower().Equals("inv"));
|
|
var listaprogetti = getlistaProgetti();
|
|
var listaProgettiCtv = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.FirstOrDefault(o => o.area.Equals("Inv")).progetti.ToList();
|
|
|
|
if (listaprogetti != null)
|
|
{
|
|
var displayInfoM = datiSeiUnico.displayInfos().macroAssetDisplayInfos.ToList();
|
|
var displayInfoA = datiSeiUnico.displayInfos().assetDisplayInfos.ToList();
|
|
int i = 0;
|
|
foreach (progettoPianificazioneBean prog in from o in listaProgettiCtv
|
|
join a in listaprogetti on o.chiaveProgetto equals a.chiaveProgetto
|
|
orderby o.ctvProgetto descending, o.varPianificato descending, o.portafoglioModello.orizzonteTemporale descending, a.nomeProgetto ascending
|
|
select o)
|
|
//foreach (var item in listaprogetti)
|
|
{
|
|
pianificazioneOrizzontaleBean item = listaprogetti.First(it => it.chiaveProgetto == prog.chiaveProgetto);
|
|
decimal percentualeProgetto = 0;
|
|
TitoloProgetto = item.nomeProgetto;
|
|
ChiaveProgetto = item.chiaveProgetto;
|
|
var patrimonioC = datiSeiUnico.patrimonioUnit().patrimonioCasa;
|
|
var patrimoniocasa = isAssetClass() ? patrimonioC.assetClass.distribuzioneAree.FirstOrDefault(s => s.area.Equals("Inv") && item.chiaveProgetto.ToString().Equals(s.chiaveProgetto)) :
|
|
patrimonioC.macroAssetClass.distribuzioneAree.FirstOrDefault(s => s.area.Equals("Inv") && item.chiaveProgetto.ToString().Equals(s.chiaveProgetto));
|
|
|
|
if (piramide != null)
|
|
{
|
|
percentualeProgetto = piramide.progettiPiramideModello.FirstOrDefault(o => o.chiaveProgettoMod == item.chiavePrgMod) != null ?
|
|
piramide.progettiPiramideModello.FirstOrDefault(o => o.chiaveProgettoMod == item.chiavePrgMod).percentualeProgetto :
|
|
0;
|
|
}
|
|
if (percentualeProgetto > 0)
|
|
{
|
|
ds.Tables["NomeProgetto"].Rows.Add(item.nomeProgetto, item.chiaveProgetto);
|
|
var totaleControvaloreAttuale = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.FirstOrDefault(o => o.area.Equals(Area)).progetti.FirstOrDefault(l => l.chiaveProgetto == item.chiaveProgetto).ctvProgetto;//patrimoniocasa.distribuzione.totaleCtv;
|
|
|
|
var varAttuale = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.FirstOrDefault(o => o.area.Equals(Area)).progetti.FirstOrDefault(l => l.chiaveProgetto == item.chiaveProgetto).progettoVarInfos.varDecodificato;
|
|
var distribuzionePtf = !isAssetClass() ? item.portafoglioModello.distribuzioniPtfModello.Where(l => l.asset.livello == 1).ToList() : item.portafoglioModello.distribuzioniPtfModello.Where(l => l.asset.livello == 2).ToList();
|
|
|
|
string labelcontrovalore = "labelControvalore" + i;
|
|
|
|
string portafoglio = "portafoglio" + i;
|
|
ds.Tables.Add(new DataTable(labelcontrovalore));
|
|
|
|
ds.Tables.Add(new DataTable(portafoglio));
|
|
|
|
#region patrimonio controvalore
|
|
ds.Tables[labelcontrovalore].Columns.Add("ControvaloreattualeString", typeof(string));
|
|
ds.Tables[labelcontrovalore].Columns.Add("Controvaloreattuale", typeof(string));
|
|
ds.Tables[labelcontrovalore].Columns.Add("AderenzaportafogliomodelloString", typeof(string));
|
|
ds.Tables[labelcontrovalore].Columns.Add("Aderenzaportafogliomodello", typeof(string));
|
|
//ds.Tables[labelcontrovalore].Columns.Add("VarAttuale", typeof(string));
|
|
//ds.Tables[labelcontrovalore].Columns.Add("Varportafogliomodello", typeof(string));
|
|
ds.Tables[labelcontrovalore].Rows.Add(
|
|
"Controvalore attuale (€)" + (getNota1().Length > 0 && getNota1().Contains("Grado") ? "*" : ""),
|
|
Helper.FormatCurrency(totaleControvaloreAttuale.ToString()),
|
|
"Aderenza al portafoglio modello (%)" + (getNota1().Length > 0 ? "*" : ""),
|
|
Helper.FormatDecimal(item.aderenza.valoreAderenza.ToString(), 2));
|
|
ds.Tables[labelcontrovalore].Rows.Add(
|
|
"VaR attuale (%)" + (getNota2().Length > 0 ? "*" : ""),
|
|
Helper.FormatDecimal(varAttuale, 2),
|
|
"VaR portafoglio modello (%)",
|
|
Helper.FormatDecimal(item.varPianificatoDec, 2));
|
|
|
|
|
|
#endregion
|
|
|
|
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.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.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
|
|
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
return ds;
|
|
|
|
|
|
}
|
|
public virtual List<pianificazioneOrizzontaleBean> getlistaProgetti()
|
|
{
|
|
List<pianificazioneOrizzontaleBean> listaprogetti = new List<pianificazioneOrizzontaleBean>();
|
|
|
|
listaprogetti = datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale.Where(o => o.portafoglioModello.area.Equals(Area)).ToList();
|
|
return listaprogetti;
|
|
}
|
|
public virtual bool isAssetClass()
|
|
{
|
|
return GetOption<Opzione3_1>().Valore;
|
|
}
|
|
|
|
public virtual bool isControvalore()
|
|
{
|
|
return !GetOption<Opzione3_2>().Valore;
|
|
}
|
|
|
|
public virtual string getTesto1()
|
|
{
|
|
string _isAssetClass = isAssetClass() ?"asset class":"macro asset class";
|
|
string _isControvalore = isControvalore() ?"di controvalore":"percentuali";
|
|
|
|
return "In questa scheda è riportato il confronto, sulla base delle principali " +
|
|
_isAssetClass +
|
|
" finanziarie, tra il patrimonio destinato al progetto di investimento \"" +
|
|
TitoloProgetto +
|
|
"\" e il relativo portafoglio modello, con evidenza dell'esposizione, in termini " +
|
|
_isControvalore + ", a ciascuna " +
|
|
_isAssetClass +
|
|
", e con indicazione del grado di Aderenza.";
|
|
}
|
|
|
|
public virtual string getNota1()
|
|
{
|
|
// Nota Portafoglio ConsigliatoFF
|
|
|
|
var aderenza = datiSeiUnico.pianificazioneUnit().pianificazioneOrizzontale.FirstOrDefault(o => o.chiaveProgetto == ChiaveProgetto).aderenza.portafoglioConsiderato;
|
|
var gradoCoperturaVar = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.aree.FirstOrDefault(o => o.area.Equals(Area)).progetti.FirstOrDefault(l => l.chiaveProgetto == ChiaveProgetto).progettoVarInfos.stat.copertura;
|
|
|
|
var distribuzione = isAssetClass() ? datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.distribuzioneAree.Where(o => o.area.Equals(Area)).FirstOrDefault(p => p.chiaveProgetto == ChiaveProgetto.ToString()) != null ? datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.distribuzioneAree.Where(o => o.area.Equals(Area)).FirstOrDefault(p => p.chiaveProgetto == ChiaveProgetto.ToString()).distribuzione
|
|
: null : datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzioneAree.Where(o => o.area.Equals(Area)).FirstOrDefault(p => p.chiaveProgetto == ChiaveProgetto.ToString()) != null ? datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzioneAree.Where(o => o.area.Equals(Area)).FirstOrDefault(p => p.chiaveProgetto == ChiaveProgetto.ToString()).distribuzione : null;
|
|
var gradoCoperturaAllocation = distribuzione != null ? distribuzione.coverageCC*100 : 0;
|
|
var prodottinonrapp =distribuzione != null ? distribuzione.totaleNonRappr : 0;
|
|
|
|
string nota = "";
|
|
if (gradoCoperturaAllocation != 0 && 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.FormatCurrencyWithSymbol(prodottinonrapp.ToString())) : ". ");
|
|
}
|
|
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(Area)).progetti.FirstOrDefault(l => l.chiaveProgetto == ChiaveProgetto).progettoVarInfos.stat.copertura;
|
|
|
|
string nota = "";
|
|
if (gradoCoperturaVar != 0 && gradoCoperturaVar != 100)
|
|
{
|
|
nota = string.Format("Grado di copertura prodotti in termini di Rischio Mercato (VaR): {0}.", Helper.FormatDecimal(gradoCoperturaVar.ToString(), 2));
|
|
}
|
|
return nota;
|
|
}
|
|
}
|
|
}
|