721 lines
39 KiB
C#
721 lines
39 KiB
C#
using System;
|
||
using Consulenza.ReportWriter.Business;
|
||
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
||
using System.Data;
|
||
using Consulenza.ReportCommon;
|
||
using System.Collections.Generic;
|
||
using Consulenza.ReportWriter.Business.CHART_PDF;
|
||
using Consulenza.ReportWriter.Business.Entity;
|
||
using System.Linq;
|
||
using Consulenza.ReportWriter.Business.CUSTOM_PDF.ConsulenzaUnica;
|
||
|
||
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
||
{
|
||
public class S79 : Entity.Section
|
||
{
|
||
|
||
/// <summary>
|
||
///S79.PropostaRischioCreditovsDiversificazionexRischioCredito idSezione = 238
|
||
/// </summary>
|
||
bool presenzaColonnaGradoCopertura;
|
||
double nSogliaMax = 0;
|
||
string sSogliaMax = "";
|
||
|
||
public S79(EnvironmentFacade environmentFacade, int idSection)
|
||
: base(environmentFacade, idSection)
|
||
{
|
||
try
|
||
{
|
||
Draw();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SectionLogger.Write("S79", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
||
}
|
||
}
|
||
|
||
protected override sealed void Draw()
|
||
{
|
||
var dati = GetDataSet();
|
||
bool isAdeguata = datiSeiUnico.flagAdeguatezzaPro();
|
||
|
||
#region Diversificazione
|
||
//AddElement(new PagePDF(PagePDF.PagePDFType.Generic));
|
||
//var intestazione = new SectionHeadingPDF(
|
||
// (isAdeguata ? "Proposta" : "Operazioni richieste") + ": rischio mercato vs diversificazione",
|
||
|
||
// EnvironmentFacade.RendererFacade.XLeftLimit,
|
||
// EnvironmentFacade.RendererFacade.YUpperLimit,
|
||
// EnvironmentFacade.ReportEnvironment.FontFamily);
|
||
|
||
//AddElement(intestazione.ToElement());
|
||
|
||
if (GetTesto1().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(20));
|
||
AddElement(new FormattedTextAreaPDF(GetTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
AddElement(new SpacePDF(20));
|
||
}
|
||
var series = new List<Serie>();
|
||
|
||
AddElement(new FormattedTextAreaPDF("Rischio credito", EnvironmentFacade.RendererFacade.XLeftLimit + 110) { FontBold = true, FontSize = 7 });
|
||
AddElement(new SpacePDF(7));
|
||
|
||
|
||
var labelPersonalizzateAsseY = new List<CombinationPDFCustomLabel>();
|
||
foreach (DataRow rowX in dati.Tables["dtSoglieY"].Rows)
|
||
{
|
||
labelPersonalizzateAsseY.Add(new CombinationPDFCustomLabel { Text = string.Empty, Value = Convert.ToDouble(rowX["Valore"]) });
|
||
//20180907 AC: commentato
|
||
if (rowX["testo"].ToString().ToUpper() == sSogliaMax.ToUpper())
|
||
nSogliaMax = Convert.ToDouble(rowX["Valore"]);
|
||
}
|
||
|
||
#region Grafico VaR Diversificazione
|
||
|
||
//var graficoCombination = new CombinationPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 150, 1F)
|
||
var graficoCombination = new CombinationPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 115, 1F)
|
||
{
|
||
|
||
Height = 200,
|
||
Width = 350,
|
||
BackImage = "ChartGradient_VarDiversificazione.png",
|
||
MarginAxisY = 0,
|
||
ShowLabelAxisY = true,
|
||
LabelFormatAxisY = FormatType.Decimale0,
|
||
IntervalNumberAxisY = 4,
|
||
StartFromZeroAxisY = true,
|
||
MaximumValueAxisY = 35, // valore fisso
|
||
CustomLabelAxisY = labelPersonalizzateAsseY,
|
||
LabelFormatAxisX = FormatType.Intero,
|
||
ShowLineAxisX = true,
|
||
ShowLabelAxisX = true,
|
||
StartFromZeroAxisX = true,
|
||
MaximumValueAxisX = 100,
|
||
IntervalNumberAxisX = 10,
|
||
IndicatorAxisY = new CombinationPDFIndicator()
|
||
{
|
||
Text = "Rischio Credito massimo profilo",
|
||
//Value = Convert.ToDouble(dati.Tables[1].Rows[0]["VarMassimoProfilo"]),
|
||
//Value = Convert.ToDouble(dati.Tables[1].Rows[0]["VarMassimoProfilo"]) >= 50 ? 35 : Convert.ToDouble(dati.Tables[1].Rows[0]["VarMassimoProfilo"]),
|
||
//20180907 AC
|
||
Value = nSogliaMax,
|
||
//Value = Convert.ToDouble(yPosRC(dati.Tables[1].Rows[0]["rischioCreditoProfiloCliente"].ToString())),
|
||
DeltaX = -115,
|
||
DeltaYText = -10
|
||
}
|
||
|
||
|
||
//Height = 200,
|
||
//Width = 350,
|
||
//MinorGridAxisY = false,
|
||
//BackImage = "ChartGradient_VarDiversificazione.png",
|
||
//MarginAxisY = 0,
|
||
//ShowLineAxisY = true,
|
||
//ShowLabelAxisY = true,
|
||
//LabelFormatAxisY = FormatType.Decimale2,
|
||
//IntervalNumberAxisY = 5,
|
||
//StartFromZeroAxisY = true,
|
||
//IndicatorAxisY = new CombinationPDFIndicator() { Text = "Rischio Mercato (VaR) massimo", Value = Convert.ToDouble(dati.Tables["cliente"].Rows[0]["VarMassimoProfilo"]), DeltaX = -120, DeltaYText = -10 },
|
||
//MaximumValueAxisY = 30, // valore fisso
|
||
//CustomLabelAxisY = labelPersonalizzateAsseY,
|
||
|
||
//LabelFormatAxisX = FormatType.Intero,
|
||
//ShowLineAxisX = true,
|
||
//ShowLabelAxisX = true,
|
||
//StartFromZeroAxisX = true,
|
||
//MaximumValueAxisX = 100,
|
||
//IntervalNumberAxisX = 10
|
||
};
|
||
|
||
// creo le Serie
|
||
var d = dati.Tables["rischio"].AsEnumerable().OrderByDescending(o => o.Field<int>("Numero")).CopyToDataTable();
|
||
foreach (DataRow item in d.Rows)
|
||
{
|
||
// lets leave this serie (with visible = false, so that the chart doesnt dissapear)
|
||
series.Add(
|
||
new Serie
|
||
{
|
||
//il name è fatto così perchè se si stampano 63 e 64 che hanno stessi codicipatrimonio nei grafici, il nome viene registrato e va in errore perchè già presente..
|
||
Name = series.FirstOrDefault(o => o.Name.Equals(item["CodicePatrimonio"].ToString())) != null ? item["CodicePatrimonio"].ToString() + 1 : item["CodicePatrimonio"].ToString(),
|
||
Type = Dundas.Charting.WebControl.SeriesChartType.Point,
|
||
MarkerImage = item["CodicePatrimonio"].ToString().Equals("PA") ? "PallinoPortafoglioAttuale2_new.png" : "PallinoPortafoglioProposto2_new.png",
|
||
Points = new List<Point>() {
|
||
new Point {
|
||
//AC 20180907
|
||
//Values = new ValuesPointXY(Convert.ToDouble(item["Diversificazione"]), Convert.ToDouble(item["RischioCredito"])),
|
||
Values = new ValuesPointXY(Convert.ToDouble(item["Diversificazione"]), Convert.ToDouble(yPosRC(item["RischioCreditoString"].ToString()))),
|
||
ShowLabelAxisY = false,
|
||
ShowLabelAxisX = false,
|
||
FontSizeLabelAxisX=7,
|
||
FontSizeLabelAxisY=7,
|
||
Visible = false
|
||
}
|
||
},
|
||
}
|
||
);
|
||
// adding element to new Markers feature
|
||
graficoCombination.Markers.Add(new Marker()
|
||
{
|
||
Image = item["CodicePatrimonio"].ToString().Equals("PA") ? "PallinoPortafoglioAttuale2_new.png" : "PallinoPortafoglioProposto2_new.png",
|
||
Width = 15,
|
||
Height = 15,
|
||
//Scale = 1,
|
||
X = Convert.ToDouble(item["Diversificazione"]) > 100 ? 100 : (float)Convert.ToDouble(item["Diversificazione"]),
|
||
//20180907 AC
|
||
//Y = Convert.ToDouble(item["RischioCredito"]) > 35 ? 35 : (float)Convert.ToDouble(item["RischioCredito"])
|
||
Y = Convert.ToDouble(item["RischioCredito"]) >= 35 ? 35 : (float)yPosRC(item["RischioCreditoString"].ToString())
|
||
});
|
||
};
|
||
// this point is needed so that horizontal dashed lines dont dissapepar
|
||
// it is visible, but it's X and Y equals -10
|
||
// and it makes it invisible for user
|
||
|
||
//series.Add(
|
||
// new Serie
|
||
// {
|
||
// //il name è fatto così perchè se si stampano 63 e 64 che hanno stessi codicipatrimonio nei grafici, il nome viene registrato e va in errore perchè già presente..
|
||
// Name = "tmpSerieNeededByDashedHorizontalLines",
|
||
// Type = Dundas.Charting.WebControl.SeriesChartType.Point,
|
||
// Points = new List<Point>() {
|
||
// new Point {
|
||
// Values = new ValuesPointXY(-10, -10),
|
||
// ShowLabelAxisY = false,
|
||
// ShowLabelAxisX = false,
|
||
// Visible = true
|
||
// }
|
||
// },
|
||
// }
|
||
// );
|
||
|
||
|
||
// aggiungo le Serie al grafico
|
||
graficoCombination.SeriesCollection = series;
|
||
|
||
AddElement(graficoCombination);
|
||
|
||
AddElement(new FormattedTextAreaPDF("Classe A", graficoCombination.X - 40) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = -32 });
|
||
AddElement(new FormattedTextAreaPDF("Classe B", graficoCombination.X - 40) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = -80 });
|
||
AddElement(new FormattedTextAreaPDF("Classe C", graficoCombination.X - 40) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = -128 });
|
||
AddElement(new FormattedTextAreaPDF("Classe D", graficoCombination.X - 40) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = -176 });
|
||
|
||
#endregion
|
||
|
||
AddElement(new SpacePDF(17));
|
||
AddElement(new FormattedTextAreaPDF("Diversificazione del rischio credito", EnvironmentFacade.RendererFacade.XLeftLimit + 230) { FontBold = true, FontSize = 7 });
|
||
AddElement(new SpacePDF(20));
|
||
|
||
// Stesso spazio con S63
|
||
AddElement(new SpacePDF(20));
|
||
|
||
#region Tabella
|
||
|
||
var tabella = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["rischio"])
|
||
{
|
||
Style = Style.ConsulenzaUnica,
|
||
AlternateRow = false,
|
||
ShowSeparationLines = true,
|
||
RowHeight = 27,
|
||
Footer = false,
|
||
HeaderHeight = 30,
|
||
ShowBorderLastLine = true
|
||
};
|
||
|
||
tabella.Columns.Add(new ColumnPDF("ImmaginePatrimonio", 15, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Immagine, "ImmaginePatrimonio", string.Empty) { DeltaYContent = 6.5F, ScaleColumnTypeImage = 0.27F });
|
||
if (presenzaColonnaGradoCopertura)
|
||
tabella.Columns.Add(new ColumnPDF("Patrimonio", 110, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Patrimonio", "Portafoglio") { HeaderPaddingLeft = 10, PaddingLeft = 10, HeaderFontSize = 7 });
|
||
else
|
||
tabella.Columns.Add(new ColumnPDF("Patrimonio", 185, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Patrimonio", "Portafoglio") { HeaderPaddingLeft = 10, PaddingLeft = 10, HeaderFontSize = 7 });
|
||
tabella.Columns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Decimale, "Controvalore", "Controvalore (€)") { HeaderFontSize = 7, PaddingRight = 4 });
|
||
tabella.Columns.Add(new ColumnPDF("RischioCredito", 60, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "RischioCreditoString", "Rischio<br>Credito") { HeaderFontSize = 7, PaddingRight = 4 });
|
||
|
||
tabella.Columns.Add(new ColumnPDF("Diversificazione", 90, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Decimale, "Diversificazione", "Diversificazione<br>rischio credito") { HeaderFontSize = 7, PaddingRight = 4 });
|
||
if (presenzaColonnaGradoCopertura)
|
||
tabella.Columns.Add(new ColumnPDF("GradoCopertura", 80, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Decimale, "GradoCopertura", "Grado di <br>copertura (%)") { HeaderFontSize = 7, PaddingRight = 4 });
|
||
tabella.Columns.Add(new ColumnPDF("Adeguatezza", 75, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "AdeguatezzaString", "Adeguatezza") { HeaderFontSize = 7, PaddingRight = 2 });
|
||
|
||
int i = 0;
|
||
int colonna = 0;
|
||
foreach (DataRow r in tabella.DataSource.Rows)
|
||
{
|
||
if (presenzaColonnaGradoCopertura)
|
||
colonna = 6;
|
||
else
|
||
colonna = 5;
|
||
switch (r["AdeguatezzaString"].ToString())
|
||
{
|
||
case "Adeguato":
|
||
tabella.Cells[colonna, i].FontColor = ColorPDF.Verde;
|
||
break;
|
||
case "Non adeguato":
|
||
tabella.Cells[colonna, i].FontColor = ColorPDF.Rosso;
|
||
break;
|
||
default:
|
||
tabella.Cells[colonna, i].FontColor = ColorPDF.Nero;
|
||
break;
|
||
}
|
||
//var colorAdeguatezza = Convert.ToBoolean(r["Adeguatezza"]) ? new ColorPDF(0, 176, 70) : new ColorPDF(255, 0, 0);
|
||
//if(presenzaColonnaGradoCopertura)
|
||
// tabella.Cells[6, i].FontColor = colorAdeguatezza;
|
||
//else
|
||
// tabella.Cells[5, i].FontColor = colorAdeguatezza;
|
||
|
||
tabella.Cells[2, i].HorizontalAlignment =
|
||
tabella.Cells[3, i].HorizontalAlignment =
|
||
tabella.Cells[4, i].HorizontalAlignment = HorizontalAlignmentType.Destra;
|
||
if (presenzaColonnaGradoCopertura)
|
||
tabella.Cells[5, i].HorizontalAlignment = HorizontalAlignmentType.Destra;
|
||
i++;
|
||
}
|
||
|
||
AddElement(tabella);
|
||
|
||
#endregion
|
||
|
||
|
||
if (GetNota1().Length > 0 || GetNota2().Length > 0)
|
||
tabella.Notes.Add(
|
||
new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella,
|
||
GetNota1() + GetNota2(),
|
||
new[] { "" },
|
||
string.Empty,
|
||
TableNotePDF.TableNoteAsteriskPositionType.CorpoTabella)
|
||
{ FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, DeltaY = 5 }
|
||
);
|
||
|
||
if (GetNota3().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(GetNota1().Length + GetNota2().Length > 0 ? 10 : 5));
|
||
AddElement(new FormattedTextAreaPDF(GetNota3(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
|
||
}
|
||
|
||
if (datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.datiPortafoglio != null && GetNota4().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(GetNota1().Length + GetNota2().Length > 0 || GetNota3().Length > 0 ? 10 : 5));
|
||
AddElement(new FormattedTextAreaPDF(GetNota4(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
|
||
}
|
||
|
||
if (GetNota5().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(GetNota1().Length + GetNota2().Length > 0 || GetNota3().Length > 0 || GetNota4().Length > 0 ? 10 : 5));
|
||
AddElement(new FormattedTextAreaPDF(GetNota5(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
|
||
}
|
||
|
||
if (GetNota6().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(GetNota1().Length + GetNota2().Length > 0 || GetNota3().Length > 0 || GetNota4().Length > 0 || GetNota5().Length > 0 ? 10 : 5));
|
||
AddElement(new FormattedTextAreaPDF(GetNota6(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
|
||
}
|
||
|
||
if (datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.flagfiduciariaPluriMandato)
|
||
{
|
||
string testonota637 = isAdeguata ? "La valutazione di adeguatezza del \"portafoglio attuale\" e del \"portafoglio proposto\" in termini di \"Rischio Mercato (VaR)\" e di \"Rischio Credito\" prende in considerazione il patrimonio detenuto presso $/Banca/$ da tutti i mandati fiduciari associati al medesimo fiduciante a cui appartiene il mandato " + datiSeiUnico.getClienteReport().codiceMandato + ", insieme al patrimonio del mandato " + datiSeiUnico.getClienteReport().codiceMandato + " derivante dalla presente proposta (limitatamente al \"portafoglio proposto\"). Gli indicatori \"Rischio Mercato (VaR)\" e \"Rischio Credito\", invece, sono calcolati considerando esclusivamente i prodotti detenuti dal mandato " + datiSeiUnico.getClienteReport().codiceMandato + ", insieme alle operazioni effettuate nella presente proposta. "
|
||
: "La valutazione di adeguatezza del \"portafoglio attuale\" e del \"portafoglio prospettico\" in termini di \"Rischio Mercato (VaR)\" e di \"Rischio Credito\" prende in considerazione il patrimonio detenuto presso $/Banca/$ da tutti i mandati fiduciari associati al medesimo fiduciante a cui appartiene il mandato " + datiSeiUnico.getClienteReport().codiceMandato + ", insieme al patrimonio del mandato " + datiSeiUnico.getClienteReport().codiceMandato + " derivante dalle operazioni da lei richieste al suo private banker (limitatamente al \"portafoglio prospettico\"). Gli indicatori \"Rischio Mercato (VaR)\" e \"Rischio Credito\", invece, sono calcolati considerando esclusivamente i prodotti detenuti dal mandato " + datiSeiUnico.getClienteReport().codiceMandato + ", insieme alle operazioni da lei richieste al suo private banker. ";
|
||
AddElement(new SpacePDF(GetNota1().Length + GetNota2().Length > 0 || GetNota3().Length > 0 || GetNota4().Length > 0 || GetNota5().Length > 0 || GetNota6().Length > 0 ? 10 : 5));
|
||
AddElement(new FormattedTextAreaPDF(datiSeiUnico.FormatBanca(testonota637), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
}
|
||
|
||
if (GetNota7().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.flagfiduciariaPluriMandato || GetNota1().Length + GetNota2().Length > 0 || GetNota3().Length > 0 || GetNota4().Length > 0 || GetNota5().Length > 0 || GetNota7().Length > 0 ? 10 : 5));
|
||
AddElement(new FormattedTextAreaPDF(GetNota7(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
|
||
}
|
||
|
||
AddElement(new FormattedTextAreaPDF("Area di pericolo", EnvironmentFacade.RendererFacade.XLeftLimit + 155 - 35) { Y = 217, FontSize = 7, FontBold = true, FontColor = ColorPDF.Bianco, AbsolutePosition = true });
|
||
AddElement(new FormattedTextAreaPDF("Area di equilibrio", EnvironmentFacade.RendererFacade.XLeftLimit + 290 - 35) { Y = 305, FontSize = 7, FontBold = true, FontColor = ColorPDF.Bianco, AbsolutePosition = true });
|
||
AddElement(new FormattedTextAreaPDF("Area di sicurezza", EnvironmentFacade.RendererFacade.XLeftLimit + 425 - 35) { Y = 375, FontSize = 7, FontBold = true, FontColor = ColorPDF.Bianco, AbsolutePosition = true });
|
||
#endregion Diversificazione
|
||
|
||
}
|
||
/// <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 sealed override DataSet GetDataSet()
|
||
{
|
||
#region Dataset + tabelle
|
||
var ds = new DataSet();
|
||
ds.Tables.Add(new DataTable("rischio"));
|
||
ds.Tables.Add(new DataTable("cliente"));
|
||
ds.Tables.Add(new DataTable("soglieY"));
|
||
#endregion
|
||
|
||
#region Estrazione dati
|
||
//profilo finanziario cliente/nucleo
|
||
var varMassimoProfiloCliente = datiSeiUnico.piramideModelloUnit().questionarioMifid.profileVarMax;
|
||
|
||
//20180907 AC
|
||
string rischioCreditoProfiloCliente;
|
||
|
||
//20180907 AC
|
||
rischioCreditoProfiloCliente = datiSeiUnico.piramideModelloUnit().questionarioMifid.profileClassRiskMax;
|
||
|
||
#region RC
|
||
var adegRischioCreditoAttuale = (from o in datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.listaAdeguatezza where o.id == "RC" select o).LastOrDefault();
|
||
var adegRischioCreditoProposto = (from o in datiSeiUnico.propostaUnit().stAdequatezza.listaDettagliAdeguatezza where o.idDescIndicatore == "RC" select o).LastOrDefault();
|
||
#endregion
|
||
|
||
#region RM
|
||
var adegRischioMercatoAttuale = (from o in datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.listaAdeguatezza where o.id == "RM" select o).LastOrDefault();
|
||
var adegRischioMercatoProposto = (from o in datiSeiUnico.propostaUnit().stAdequatezza.listaDettagliAdeguatezza where o.idDescIndicatore == "RM" select o).LastOrDefault();
|
||
#endregion
|
||
|
||
var rischio = datiSeiUnico.rischioUnit().rischio.rischioMercatoCredito;
|
||
var datiPortaglioAttuale = datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.datiPortafoglio;
|
||
var portafoglioproposto = datiSeiUnico.propostaUnit().stDettaglioProposta;
|
||
var datiAdeguatezzaProposta = datiSeiUnico.propostaUnit().stAdequatezza;
|
||
#endregion
|
||
if (datiPortaglioAttuale != null)
|
||
presenzaColonnaGradoCopertura = datiPortaglioAttuale.copertura < 100 || portafoglioproposto.copertura < 100;
|
||
else
|
||
presenzaColonnaGradoCopertura = false;
|
||
|
||
#region Rischio
|
||
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("Numero", typeof(int)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("CodicePatrimonio", typeof(string)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("ImmaginePatrimonio", typeof(string)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("RischioCredito", typeof(decimal)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("RischioCreditoString", typeof(string)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("Diversificazione", typeof(decimal)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("GradoCopertura", typeof(decimal)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("Adeguatezza", typeof(bool)));
|
||
ds.Tables["rischio"].Columns.Add(new DataColumn("AdeguatezzaString", typeof(string)));
|
||
|
||
#region Attuale
|
||
if (datiPortaglioAttuale != null)
|
||
{
|
||
ds.Tables["rischio"].Rows.Add(
|
||
1, //NumeroPatrimonio
|
||
"Portafoglio attuale" + (GetNota1().Length > 0 ? "*" : ""), //Patrimonio
|
||
"PA", //CodicePortafoglio
|
||
"PallinoPortafoglioAttuale_new.png", //pallino
|
||
datiSeiUnico.ATTUTALE_TOTALEPOSITIVO, //Controvalore
|
||
datiPortaglioAttuale.classeRischioCredito.ToString(), //RischioCredito
|
||
Helper.resultValueVariousString(adegRischioCreditoAttuale.patrimonioFideuram), //RischioCreditoString
|
||
rischio.diversicazioneCasa.beneficio.Count() > 0 ?
|
||
rischio.diversicazioneCasa.beneficio.FirstOrDefault(o => o.key.ToUpper().Equals("DIVERSIFICAZIONERISCHIOCREDITO")).value
|
||
: 0,
|
||
//rischio.diversicazioneCasa.beneficio.FirstOrDefault(o => o.key.ToUpper().Equals("DIVERSIFICAZIONERISCHIOCREDITO")).value,
|
||
datiPortaglioAttuale.copertura, //GradoCopertura
|
||
adegRischioMercatoAttuale.isAdeguato,
|
||
!adegRischioCreditoAttuale.isAdeguatoSpecified ? "n.a." : (datiPortaglioAttuale.copertura > 0 ? adegRischioMercatoAttuale.isAdeguato ? "Adeguato" : "Non adeguato" : "n.c.")//AdeguatezzaString
|
||
); //Adeguatezza
|
||
}
|
||
#endregion
|
||
|
||
#region Proposto
|
||
|
||
ds.Tables["rischio"].Rows.Add(
|
||
2, //NumeroPatrimonio
|
||
"Portafoglio " + (datiSeiUnico.flagAdeguatezzaPro() ? "proposto" : "prospettico") + (GetNota2().Length > 0 ? "*" : ""), //Patrimonio
|
||
"PP", //CodicePortafoglio
|
||
"PallinoPortafoglioProposto_new.png", //pallino
|
||
datiSeiUnico.PROPOSTO_TOTALEPOSITIVO, //Controvalore
|
||
portafoglioproposto.rischioCredito, //RischioCredito
|
||
Helper.resultValueVariousString(portafoglioproposto.rischioCreditoDec), //RischioCreditoString
|
||
portafoglioproposto.diversificazioneProposta.FirstOrDefault(o => o.key.ToUpper().Equals("DIVERSIFICAZIONERISCHIOCREDITO")).value,
|
||
Math.Round(portafoglioproposto.copertura, 2), //GradoCopertura
|
||
adegRischioMercatoProposto.flagAdeguatezza, //Adeguatezza TODO
|
||
!adegRischioMercatoProposto.flagAdeguatezzaSpecified ? "n.a." : (adegRischioMercatoProposto.flagAdeguatezza ? "Adeguato" : "Non adeguato") //AdeguatezzaString
|
||
); //Adeguatezza
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region Cliente
|
||
|
||
ds.Tables["cliente"].Columns.Add(new DataColumn("VarMassimoProfilo", typeof(decimal)));
|
||
//20180907 AC
|
||
//ds.Tables["cliente"].Rows.Add(varMassimoProfiloCliente);
|
||
ds.Tables["cliente"].Columns.Add(new DataColumn("rischioCreditoProfiloCliente", typeof(string)));
|
||
ds.Tables["cliente"].Rows.Add(varMassimoProfiloCliente, rischioCreditoProfiloCliente);
|
||
|
||
sSogliaMax = Helper.resultValueVariousString(portafoglioproposto.rischioCreditoDec);
|
||
|
||
#endregion
|
||
|
||
#region Soglie Asse Y
|
||
|
||
var dtSoglieY = new DataTable("dtSoglieY");
|
||
dtSoglieY.Columns.Add(new DataColumn("Id", typeof(int)));
|
||
dtSoglieY.Columns.Add(new DataColumn("Testo", typeof(string)));
|
||
dtSoglieY.Columns.Add(new DataColumn("Valore", typeof(decimal)));
|
||
dtSoglieY.Rows.Add(1, "Classe A", 8.77);
|
||
dtSoglieY.Rows.Add(2, "Classe B", 17.54);
|
||
dtSoglieY.Rows.Add(3, "Classe C", 26.31);
|
||
dtSoglieY.Rows.Add(4, "Classe D", 35.08);
|
||
|
||
ds.Tables.Add(dtSoglieY);
|
||
|
||
#endregion
|
||
|
||
return ds;
|
||
}
|
||
|
||
public virtual string GetTesto1()
|
||
{
|
||
bool isAdeguata = datiSeiUnico.flagAdeguatezzaPro();
|
||
string testo = "";
|
||
string banca = "$/Banca/$";
|
||
banca = /*"altri Istituti";*/ banca.Replace("$/Banca/$", Helper.ReplaceVariables("$/Banca/$", EnvironmentFacade.ReportEnvironment));
|
||
testo = isAdeguata ?
|
||
"In questa scheda è riportato il confronto, in termini di Rischio Credito e di Diversificazione del rischio credito, tra il patrimonio che lei attualmente detiene presso " + banca + " (\"portafoglio attuale\") e il patrimonio derivante dalla presente proposta (\"portafoglio proposto\"). " :
|
||
"In questa scheda è riportato il confronto, in termini di Rischio Credito e di Diversificazione del rischio credito, tra il patrimonio che lei attualmente detiene presso " + banca + " (\"portafoglio attuale\") e il patrimonio derivante dalle operazioni da lei richieste al suo private banker (\"portafoglio prospettico\"). ";
|
||
|
||
return testo;
|
||
}
|
||
|
||
|
||
|
||
|
||
public virtual string GetNota1()
|
||
{
|
||
string nota = string.Empty;
|
||
|
||
// 2181009 AC
|
||
//if (getCCN_CASA() != 0 || getGPELIGOFONDI_CASA() != 0 || getGPELIGOTITOLI_CASA() != 0)
|
||
if (getCCN_CASA() != 0 || getGPELIGOFONDI_CASA() != 0 || getGPELIGOTITOLI_CASA() != 0|| getTUOFOGLIO_CASA()!=0)
|
||
//--20181009 AC
|
||
{
|
||
nota = "Il controvalore del portafoglio attuale esclude il saldo negativo ";
|
||
if (getCCN_CASA() != 0)
|
||
nota += "dei conti correnti (" + Helper.FormatCurrency(getCCN_CASA().ToString()) + " €)";
|
||
|
||
// 20181009 AC
|
||
if (getTUOFOGLIO_CASA() != 0)
|
||
{
|
||
nota += getCCN_CASA() != 0 ? ", " : "";
|
||
nota += "della liquidità sottostante Il Mio Foglio (" + Helper.FormatCurrency(getTUOFOGLIO_CASA().ToString()) + "€)";
|
||
}
|
||
//--20181009 AC
|
||
if (getGPELIGOFONDI_CASA() != 0)
|
||
{
|
||
// 20181009 AC
|
||
//nota += getCCN_CASA() != 0 ? ", " : "";
|
||
nota += (getCCN_CASA() != 0 || getTUOFOGLIO_CASA() != 0) ? ", " : "";
|
||
//--20181009 AC
|
||
nota += "della liquidità sottostante la GP Eligo Fondi (" + Helper.FormatCurrency(getGPELIGOFONDI_CASA().ToString()) + "€)";
|
||
}
|
||
|
||
if (getGPELIGOTITOLI_CASA() != 0)
|
||
{
|
||
// 20181009 AC
|
||
//nota += (getCCN_CASA() != 0 || getGPELIGOFONDI_CASA() != 0) ? ", " : "";
|
||
nota += (getCCN_CASA() != 0 || getTUOFOGLIO_CASA() != 0 || getGPELIGOFONDI_CASA() != 0) ? ", " : "";
|
||
//--20181009 AC
|
||
nota += "della liquidità sottostante la GP Eligo Titoli (" + Helper.FormatCurrency(getGPELIGOTITOLI_CASA().ToString()) + "€)";
|
||
}
|
||
nota += ". ";
|
||
}
|
||
return nota;
|
||
}
|
||
|
||
public virtual string GetNota2()
|
||
{
|
||
string nota = "";
|
||
|
||
// 20181009 AC
|
||
//if (getPropostaCCN_CASA() != 0 || getPropostaGPELIGOFONDI_CASA() != 0 || getPropostaGPELIGOTITOLI_CASA() != 0)
|
||
if (getPropostaCCN_CASA() != 0 || getPropostaGPELIGOFONDI_CASA() != 0 || getPropostaGPELIGOTITOLI_CASA() != 0 || getPropostaTUOFOGLIO_CASA()!=0)
|
||
//--20181009 AC
|
||
{
|
||
nota += "Il controvalore del portafoglio " + (datiSeiUnico.flagAdeguatezzaPro() ? "proposto" : "prospettico") + " esclude il saldo negativo ";
|
||
if (getPropostaCCN_CASA() != 0)
|
||
nota += "dei conti correnti (" + Helper.FormatCurrency(getCCN_CASA().ToString()) + " €)";
|
||
|
||
// 20181009 AC
|
||
if (getPropostaTUOFOGLIO_CASA() != 0)
|
||
{
|
||
nota += getCCN_CASA() != 0 ? ", " : "";
|
||
nota += "della liquidità sottostante Il Mio Foglio (" + Helper.FormatCurrency(getPropostaGPELIGOFONDI_CASA().ToString()) + "€)";
|
||
}
|
||
//--20181009 AC
|
||
if (getPropostaGPELIGOFONDI_CASA() != 0)
|
||
{
|
||
// 20181009 AC
|
||
//nota += getCCN_CASA() != 0 ? ", " : "";
|
||
nota += (getCCN_CASA() != 0 || getPropostaTUOFOGLIO_CASA() != 0) ? ", " : "";
|
||
//--20181009 AC
|
||
nota += "della liquidità sottostante la GP Eligo Fondi (" + Helper.FormatCurrency(getPropostaGPELIGOFONDI_CASA().ToString()) + "€)";
|
||
}
|
||
|
||
if (getGPELIGOTITOLI_CASA() != 0)
|
||
{
|
||
// 20181009 AC
|
||
//nota += (getPropostaCCN_CASA() != 0 || getPropostaGPELIGOFONDI_CASA() != 0) ? ", " : "";
|
||
nota += (getPropostaCCN_CASA() != 0 || getPropostaTUOFOGLIO_CASA() != 0 || getPropostaGPELIGOFONDI_CASA() != 0) ? ", " : "";
|
||
//--20181009 AC
|
||
nota += "della liquidità sottostante la GP Eligo Titoli (" + Helper.FormatCurrency(getPropostaGPELIGOTITOLI_CASA().ToString()) + "€)";
|
||
}
|
||
nota += ". ";
|
||
}
|
||
return nota;
|
||
}
|
||
|
||
public virtual string GetNota3()
|
||
{
|
||
|
||
foreach (var item in datiSeiUnico.propostaUnit().dettaglioOperazioni.elencoDettagliOperazioni)
|
||
{
|
||
foreach (var i in item.listaOperzioni)
|
||
{
|
||
if (i.investi != 0) return "";
|
||
}
|
||
}
|
||
string nota = "A prescindere dai singoli indicatori di rischio relativi al patrimonio derivante dalla presente proposta (";
|
||
nota += "\"portafoglio proposto\"), la proposta risulta adeguata in quanto contiene esclusivamente operazioni di vendita ";
|
||
nota += "/ liquidazione / riscatto, che non sono oggetto di valutazione di adeguatezza. ";
|
||
return nota;
|
||
}
|
||
|
||
public virtual string GetNota4()
|
||
{
|
||
string nota = "";
|
||
var GCproposto = datiSeiUnico.propostaUnit().stDettaglioProposta.copertura;
|
||
var coperturaDeltaRM = datiSeiUnico.propostaUnit().stAdequatezza.listaDettagliAdeguatezza.FirstOrDefault(x => x.idDescIndicatore.Equals("RM")).coperturaDelta;
|
||
var varProposto = datiSeiUnico.propostaUnit().stDettaglioProposta.rischioMercato;
|
||
var varAttuale = Convert.ToDecimal(datiSeiUnico.rischioUnit().adeguatezza.adeguatezzaTopBean.datiPortafoglio.valoreVaR);
|
||
var varMax = datiSeiUnico.piramideModelloUnit().questionarioMifid.profileVarMax;
|
||
|
||
|
||
bool prospetticoMigliorativoVar = varAttuale > varMax & varProposto < varAttuale & varProposto > varMax;
|
||
bool coperturaAdeguatezza = GCproposto < 90 & coperturaDeltaRM.Equals("100.00");
|
||
|
||
if (prospetticoMigliorativoVar || coperturaAdeguatezza)
|
||
{
|
||
nota = "La valutazione di adeguatezza in termini di Rischio Mercato (VaR) è stata effettuata verificando che il livello di Rischio Mercato (VaR) delle sole operazioni d’investimento";
|
||
nota += datiSeiUnico.flagAdeguatezzaPro() ?
|
||
" effettuate sia coerente con la soglia massima associata al suo profilo finanziario." :
|
||
" da lei richieste al suo private banker sia coerente con la soglia massima associata al suo profilo finanziario.";
|
||
}
|
||
|
||
return nota;
|
||
}
|
||
|
||
|
||
|
||
public virtual string GetNota5()
|
||
{
|
||
string nota = "";
|
||
|
||
var RM = !datiSeiUnico.propostaUnit().stAdequatezza.listaDettagliAdeguatezza.AsEnumerable().FirstOrDefault(o => o.idDescIndicatore == "RM").copertura.Equals("100.00");
|
||
var RC = false;
|
||
if (!datiSeiUnico.flagAdeguatezzaPro() && (RM || RC))
|
||
{
|
||
|
||
|
||
|
||
nota += "Il patrimonio derivante dalle operazioni da lei richieste al suo private banker (\"portafoglio prospettico\") risulta non adeguato al suo profilo finanziario in termini di " +
|
||
(RM ? RC ? "Rischio Mercato (VaR) e di Rischio Credito" : "Rischio Mercato (VaR)" : RC ? "Rischio Credito" : "") +
|
||
", in quanto le operazioni da lei richieste al suo private banker hanno ad oggetto uno o più prodotti per cui non è disponibile " +
|
||
(RM ? RC ? "il relativo livello di Rischio Mercato (VaR) e la relativa classe di Rischio Credito" : "il relativo livello di Rischio Mercato (VaR)" : RC ? "la relativa classe di Rischio Credito" : "") +
|
||
".";
|
||
|
||
|
||
|
||
}
|
||
return datiSeiUnico.FormatBanca(nota);
|
||
}
|
||
|
||
public virtual string GetNota6()
|
||
{
|
||
string nota = string.Empty;
|
||
if (datiSeiUnico.propostaUnit().stAdequatezza.flagAdeguatezzaMIFIDPro)
|
||
{
|
||
nota += "La valutazione di adeguatezza del patrimonio derivante dalla presente proposta (\"portafoglio proposto\") ";
|
||
nota += "non è necessaria in quanto tutti i prodotti oggetto delle operazioni di investimento effettuate non sono ";
|
||
nota += "soggetti alla valutazione di adeguatezza MiFID. ";
|
||
}
|
||
return nota;
|
||
}
|
||
|
||
public virtual string GetNota7()
|
||
{
|
||
string nota = string.Empty;
|
||
if (datiSeiUnico.propostaUnit().stAdequatezza.flagVarEccessivamenteAdeguatoPro)
|
||
{
|
||
nota += "Il patrimonio derivante dalla presente proposta (\"portafoglio proposto\") risulta adeguato al suo profilo ";
|
||
nota += "finanziario. Le segnaliamo, tuttavia, che il livello di Rischio Mercato (VaR) del patrimonio derivante dalla ";
|
||
nota += "presente proposta (\"portafoglio proposto\") si posiziona su un valore sensibilmente inferiore rispetto alla ";
|
||
nota += "soglia minima attribuita al suo profilo finanziario. ";
|
||
}
|
||
return nota;
|
||
}
|
||
|
||
public virtual decimal getCCN_CASA()
|
||
{
|
||
return datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.contoCorrenteNegativo;
|
||
}
|
||
|
||
public virtual decimal getGPELIGOFONDI_CASA()
|
||
{
|
||
return datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.liqEligoFondiNeg;
|
||
}
|
||
|
||
public virtual decimal getGPELIGOTITOLI_CASA()
|
||
{
|
||
return datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.liqEligoTitoliNeg;
|
||
}
|
||
|
||
public virtual decimal getPropostaCCN_CASA()
|
||
{
|
||
return datiSeiUnico.propostaUnit().stDettaglioProposta.contoCorrenteNegativo;
|
||
}
|
||
|
||
public virtual decimal getPropostaGPELIGOFONDI_CASA()
|
||
{
|
||
return datiSeiUnico.propostaUnit().stDettaglioProposta.liqEligoFondiNeg;
|
||
}
|
||
|
||
public virtual decimal getPropostaGPELIGOTITOLI_CASA()
|
||
{
|
||
return datiSeiUnico.propostaUnit().stDettaglioProposta.liqEligoTitoliNeg;
|
||
}
|
||
|
||
// 20181009 AC
|
||
public virtual decimal getTUOFOGLIO_CASA()
|
||
{
|
||
return datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.liqFogliNeg;
|
||
}
|
||
|
||
public virtual decimal getPropostaTUOFOGLIO_CASA()
|
||
{
|
||
return datiSeiUnico.propostaUnit().stDettaglioProposta.liqFogliNeg;
|
||
}
|
||
//--20181009 AC
|
||
|
||
private double yPosRC(string val)
|
||
{
|
||
double retVal = 0;
|
||
switch (val.ToLower())
|
||
{
|
||
case "classe a": retVal = 4.385; break;
|
||
case "classe b": retVal = 13.155; break;
|
||
case "classe c": retVal = 21.925; break;
|
||
case "classe d": retVal = 30.695; break;
|
||
default: retVal = 0; break;
|
||
}
|
||
|
||
return retVal;
|
||
|
||
}
|
||
}
|
||
}
|