398 lines
19 KiB
C#
398 lines
19 KiB
C#
using System;
|
||
using Consulenza.ReportWriter.Business;
|
||
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
||
using System.Data;
|
||
using Consulenza.ReportCommon;
|
||
using Consulenza.ReportWriter.Business.CHART_PDF;
|
||
using Consulenza.ReportWriter.Business.Entity;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
|
||
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
||
{
|
||
/// <summary>
|
||
/// S33.PatrimonioAltriIstitutiRappresentazioneAssetClass idSezione = 76
|
||
/// </summary>
|
||
public class S33 : Entity.Section
|
||
{
|
||
|
||
|
||
public S33(EnvironmentFacade environmentFacade, int idSection)
|
||
: base(environmentFacade, idSection)
|
||
{
|
||
try
|
||
{
|
||
|
||
Draw();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SectionLogger.Write("S33", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
||
}
|
||
}
|
||
|
||
//protected override sealed void OLD_Draw()
|
||
//{
|
||
// var dati = GetDataSet();
|
||
|
||
// #region Testo introduttivo grafico
|
||
|
||
// AddElement(new SpacePDF(20));
|
||
// var testoGrafico = !isControvalore() ?
|
||
// Helper.ReplaceVariables(GetText().Rows[0]["testo1"].ToString(), base.EnvironmentFacade.ReportEnvironment) :
|
||
// Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), base.EnvironmentFacade.ReportEnvironment);
|
||
|
||
// AddElement(new FormattedTextAreaPDF(testoGrafico, EnvironmentFacade.RendererFacade.XLeftLimit) {FontSize=7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
// AddElement(new SpacePDF(15));
|
||
|
||
// #endregion
|
||
|
||
// #region Tabella Patrimonio
|
||
|
||
// var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables[0])
|
||
// {
|
||
// Style = Style.ConsulenzaUnica,
|
||
// Header = false,
|
||
// Footer = false,
|
||
// AlternateRow = false,
|
||
// RowHeight = 25
|
||
// };
|
||
// tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 190, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty));
|
||
// tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
|
||
|
||
// AddElement(tabellaPatrimonio);
|
||
// AddElement(new SpacePDF(25));
|
||
|
||
// #endregion
|
||
|
||
// #region Grafico a barre
|
||
|
||
// AddElement(new FormattedTextAreaPDF("Asset class", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
|
||
// AddElement(new FormattedTextAreaPDF(string.Format("Distribuzione ({0})", isControvalore() ? "€" : "%"), EnvironmentFacade.RendererFacade.XLeftLimit + 110, 410) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
|
||
// AddElement(new SpacePDF(10));
|
||
|
||
|
||
// var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 110, 1F)
|
||
// {
|
||
// HeightSingleBar = 25,
|
||
// Width = 400,
|
||
// LabelFormatAxisY = isControvalore() ? FormatType.Intero : FormatType.Decimale2,
|
||
// ShowLineAxisX = true,
|
||
// PageBreak = true,
|
||
// DinamicFloatXEtichettaLateraleBarra = true,
|
||
// MinorGridAxisY = true,
|
||
// RemoveWhiteSpaceToTheRightAxisX = true,
|
||
// RemoveWhiteSpaceBetweenChartAndAxisX = true,
|
||
// MarginAxisY = 0,
|
||
// MarginAxisYFromTop = 0
|
||
// };
|
||
// if (isControvalore())
|
||
// graficoBarre.RemoveWhiteSpaceToTheRightAxisX = true;
|
||
// var dtGraficoBarre = dati.Tables[1];
|
||
// var serieCollezione = new List<Serie> { new Serie { Name = "Asset", Border = true } };
|
||
|
||
// foreach (DataRow item in dtGraficoBarre.Rows)
|
||
// {
|
||
// serieCollezione[0].Points.Add(new Point
|
||
// {
|
||
// ShowLabelAxisY = true,
|
||
// LabelAxisY = isControvalore() ? Helper.FormatCurrency(item["Controvalore"].ToString()) : Helper.FormatDecimal(item["Percentuale"].ToString(), 2),
|
||
// FontSizeLabelAxisY = 7,
|
||
|
||
// Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
||
// Value = isControvalore() ? (Convert.ToDouble(item["Controvalore"]) == 0 ? 0.01 : Convert.ToDouble(item["Controvalore"])) : Convert.ToDouble(item["Percentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["Percentuale"]), // Convert.ToDouble(Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
|
||
|
||
// ShowLabelAxisX = true,
|
||
// LabelAxisX = item["Asset"].ToString(),
|
||
// FontSizeLabelAxisX = 7,
|
||
// FontBoldLabelAxisY = false
|
||
// });
|
||
// }
|
||
|
||
// graficoBarre.SeriesCollection = serieCollezione;
|
||
|
||
// AddElement(graficoBarre);
|
||
|
||
// #endregion
|
||
|
||
// #region Nota del Patrimonio Terzi
|
||
// if (GetNote1().Length > 0)
|
||
// {
|
||
// AddElement(new SpacePDF(20));
|
||
// AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
// }
|
||
// #endregion
|
||
//}
|
||
|
||
protected override sealed void Draw()
|
||
{
|
||
var dati = GetDataSet();
|
||
|
||
#region Modifiche 20190628 per Evolutiva
|
||
|
||
string sVerticalText;
|
||
|
||
if (EnvironmentFacade.ReportEnvironment.ReportType.Equals(ReportType.Unica_Nucleo))
|
||
{
|
||
sVerticalText = "";
|
||
}
|
||
else
|
||
{
|
||
sVerticalText = "Le eventuali informazioni riguardanti investimenti da lei detenuti presso altri intermediari vengono elaborate secondo le indicazioni da lei ";
|
||
if (EnvironmentFacade.ReportEnvironment.PrivateBanker.CodiceRete.Equals("F"))
|
||
{
|
||
sVerticalText = sVerticalText + "fornite e/ o disponibili sul mercato, per le quali Fideuram non garantisce la completezza e la veridicità. ";
|
||
sVerticalText = sVerticalText + "La preghiamo di comunicare a Fideuram ogni successiva variazione a tali informazioni, al fine di consentire a Fideuram la correzione e l’aggiornamento dei dati contenuti ";
|
||
sVerticalText = sVerticalText + "nel presente report.Gli investimenti detenuti presso altri intermediari vengono utilizzati da Fideuram con finalità meramente informative e secondo le indicazioni da lei fornite, ";
|
||
sVerticalText = sVerticalText + "in modo da offrire una rappresentazione unitaria degli investimenti, senza con ciò formare oggetto di raccomandazioni personalizzate o di rendicontazione ufficiale.";
|
||
}
|
||
else
|
||
{
|
||
sVerticalText = sVerticalText + "fornite e/ o disponibili sul mercato, per le quali Sanpaolo Invest SIM non garantisce la completezza e la veridicità. ";
|
||
sVerticalText = sVerticalText + "La preghiamo di comunicare a Sanpaolo Invest SIM ogni successiva variazione a tali informazioni, al fine di consentire a Sanpaolo Invest SIM la correzione e l’aggiornamento dei dati contenuti ";
|
||
sVerticalText = sVerticalText + "nel presente report.Gli investimenti detenuti presso altri intermediari vengono utilizzati da Sanpaolo Invest SIM con finalità meramente informative e secondo le indicazioni da lei fornite, ";
|
||
sVerticalText = sVerticalText + "in modo da offrire una rappresentazione unitaria degli investimenti, senza con ciò formare oggetto di raccomandazioni personalizzate o di rendicontazione ufficiale.";
|
||
}
|
||
}
|
||
|
||
|
||
FormattedTextAreaPDF testoPaginaVerticale = null;
|
||
testoPaginaVerticale = new FormattedTextAreaPDF(sVerticalText, EnvironmentFacade.RendererFacade.XLeftLimit - 35, 620)
|
||
{
|
||
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify,
|
||
FontSize = 5,
|
||
TextVerticalDirection = true,
|
||
Y = 745
|
||
};
|
||
var listaOggettiDaRipetere = new List<ObjectPDF> { testoPaginaVerticale };
|
||
AddElement(listaOggettiDaRipetere);
|
||
AddElement(new RepeaterPDF(listaOggettiDaRipetere));
|
||
#endregion
|
||
|
||
|
||
#region Testo introduttivo grafico
|
||
|
||
#region Modifiche 20190628 per Evolutiva
|
||
//AddElement(new SpacePDF(20));
|
||
#endregion Fine Modifiche
|
||
|
||
var testoGrafico = !isControvalore() ?
|
||
Helper.ReplaceVariables(GetText().Rows[0]["testo1"].ToString(), base.EnvironmentFacade.ReportEnvironment) :
|
||
Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), base.EnvironmentFacade.ReportEnvironment);
|
||
|
||
AddElement(new FormattedTextAreaPDF(testoGrafico, EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
AddElement(new SpacePDF(15));
|
||
|
||
#endregion
|
||
|
||
#region Tabella Patrimonio
|
||
|
||
var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables[0])
|
||
{
|
||
Style = Style.ConsulenzaUnica,
|
||
Header = false,
|
||
Footer = false,
|
||
AlternateRow = false,
|
||
RowHeight = 25
|
||
};
|
||
tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 190, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty));
|
||
tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
|
||
|
||
AddElement(tabellaPatrimonio);
|
||
AddElement(new SpacePDF(25));
|
||
|
||
#endregion
|
||
|
||
#region Grafico a barre
|
||
|
||
AddElement(new FormattedTextAreaPDF("Asset class", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
|
||
AddElement(new FormattedTextAreaPDF(string.Format("Distribuzione ({0})", isControvalore() ? "€" : "%"), EnvironmentFacade.RendererFacade.XLeftLimit + 110, 410) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
|
||
AddElement(new SpacePDF(10));
|
||
|
||
|
||
var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 110, 1F)
|
||
{
|
||
HeightSingleBar = 25,
|
||
Width = 400,
|
||
LabelFormatAxisY = isControvalore() ? FormatType.Intero : FormatType.Decimale2,
|
||
ShowLineAxisX = true,
|
||
PageBreak = true,
|
||
DinamicFloatXEtichettaLateraleBarra = true,
|
||
MinorGridAxisY = true,
|
||
RemoveWhiteSpaceToTheRightAxisX = true,
|
||
RemoveWhiteSpaceBetweenChartAndAxisX = true,
|
||
MarginAxisY = 0,
|
||
MarginAxisYFromTop = 0
|
||
};
|
||
if (isControvalore())
|
||
graficoBarre.RemoveWhiteSpaceToTheRightAxisX = true;
|
||
var dtGraficoBarre = dati.Tables[1];
|
||
var serieCollezione = new List<Serie> { new Serie { Name = "Asset", Border = true } };
|
||
|
||
foreach (DataRow item in dtGraficoBarre.Rows)
|
||
{
|
||
serieCollezione[0].Points.Add(new Point
|
||
{
|
||
ShowLabelAxisY = true,
|
||
LabelAxisY = isControvalore() ? Helper.FormatCurrency(item["Controvalore"].ToString()) : Helper.FormatDecimal(item["Percentuale"].ToString(), 2),
|
||
FontSizeLabelAxisY = 7,
|
||
|
||
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
||
Value = isControvalore() ? (Convert.ToDouble(item["Controvalore"]) == 0 ? 0.01 : Convert.ToDouble(item["Controvalore"])) : Convert.ToDouble(item["Percentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["Percentuale"]), // Convert.ToDouble(Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
|
||
|
||
ShowLabelAxisX = true,
|
||
LabelAxisX = item["Asset"].ToString(),
|
||
FontSizeLabelAxisX = 7,
|
||
FontBoldLabelAxisY = false
|
||
});
|
||
}
|
||
|
||
graficoBarre.SeriesCollection = serieCollezione;
|
||
|
||
AddElement(graficoBarre);
|
||
|
||
#endregion
|
||
|
||
#region Nota del Patrimonio Terzi
|
||
if (GetNote1().Length > 0)
|
||
{
|
||
AddElement(new SpacePDF(20));
|
||
AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
/// <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()
|
||
{
|
||
var ds = new DataSet();
|
||
|
||
|
||
|
||
|
||
|
||
var displayInfo = datiSeiUnico.displayInfos().assetDisplayInfos.ToList();
|
||
|
||
|
||
var dataAsset = datiSeiUnico.patrimonioUnit().patrimonioTerzi.assetClass.distribuzione.elencoSlice;
|
||
string RisorseFinanziarie = datiSeiUnico.patrimonioUnit().patrimonioTerzi.patrimonioTerziBean.risorseFinanziarieTerzi.ToString();
|
||
#region Patrimonio terzi
|
||
|
||
var dtPatrimonio = new DataTable("dtPatrimonio");
|
||
dtPatrimonio.Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
||
dtPatrimonio.Columns.Add(new DataColumn("Valore", typeof(string)));
|
||
|
||
var testoPatrimonio = string.Format("Patrimonio altri Istituti (€){0}", (GetNote1().Length>0 ? "*" :""));
|
||
dtPatrimonio.Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.TRZ_TOTALEPOSITIVO.ToString() ));
|
||
|
||
ds.Tables.Add(dtPatrimonio);
|
||
|
||
#endregion
|
||
|
||
#region Asset
|
||
|
||
var dtAssetClass = new DataTable();
|
||
dtAssetClass.Columns.Add(new DataColumn("Asset", typeof(string)));
|
||
dtAssetClass.Columns.Add(new DataColumn("Red", typeof(int)));
|
||
dtAssetClass.Columns.Add(new DataColumn("Green", typeof(int)));
|
||
dtAssetClass.Columns.Add(new DataColumn("Blue", typeof(int)));
|
||
dtAssetClass.Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
|
||
dtAssetClass.Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
|
||
dtAssetClass.Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
||
|
||
foreach (var itemDistribuzione in dataAsset)
|
||
{
|
||
if (itemDistribuzione.sliceRappresentabile)
|
||
{
|
||
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
|
||
|
||
var colore = new ColorPDF(mapDisplayInfo.fill);
|
||
var ordinamento = mapDisplayInfo.order;
|
||
|
||
var controvalore = presenzaContocorrenteInMonterio() ? itemDistribuzione.ctvCC : itemDistribuzione.ctv;
|
||
var percentuale = (presenzaContocorrenteInMonterio() ? itemDistribuzione.pesoCC : itemDistribuzione.peso) * 100;
|
||
if (controvalore != 0)
|
||
{
|
||
dtAssetClass.Rows.Add(itemDistribuzione.descrizione, colore.Red, colore.Green, colore.Blue, controvalore, percentuale, ordinamento);
|
||
}
|
||
}
|
||
}
|
||
|
||
ds.Tables.Add(dtAssetClass.AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento")).CopyToDataTable());
|
||
|
||
#endregion
|
||
|
||
return ds;
|
||
}
|
||
|
||
|
||
|
||
|
||
public virtual bool isControvalore(){ return !GetOption<Opzione3>().Valore;}
|
||
public virtual bool presenzaContocorrenteInMonterio() { return GetOption<Opzione4>().Valore; }
|
||
public virtual string GetNote1()
|
||
{
|
||
|
||
string nota = "";
|
||
string token = "";
|
||
var assetClass = datiSeiUnico.patrimonioUnit().patrimonioTerzi.assetClass;
|
||
|
||
if (datiSeiUnico.TRZ_CCN != 0)
|
||
{
|
||
nota += datiSeiUnico.FormatDecimal("Il controvalore esclude il saldo negativo dei conti correnti ({0} €).", datiSeiUnico.TRZ_CCN);
|
||
token = " ";
|
||
}
|
||
|
||
decimal GC = (presenzaContocorrenteInMonterio() ? assetClass.distribuzione.coverageCC : assetClass.distribuzione.coverage) * 100;
|
||
decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
|
||
decimal PNR_TERZI = assetClass.distribuzione.totaleNonRappr;
|
||
|
||
|
||
|
||
if (GC < 100)
|
||
{
|
||
nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per asset class pari a {0}", GC);
|
||
token = ": ";
|
||
if (PNR_TERZI != 0 || CC_TERZI != 0)
|
||
{
|
||
nota += token + "non sono considerati";
|
||
token = " ";
|
||
|
||
if (PNR_TERZI != 0 || CC_TERZI != 0)
|
||
{
|
||
if (PNR_TERZI != 0)
|
||
{
|
||
nota += token + datiSeiUnico.FormatDecimal("i prodotti non rappresentabili ({0} €)", PNR_TERZI);
|
||
token = ", ";
|
||
}
|
||
if (CC_TERZI != 0)
|
||
{
|
||
nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_TERZI);
|
||
token = ", ";
|
||
}
|
||
token = ", ";
|
||
}
|
||
}
|
||
nota += ".";
|
||
token = " ";
|
||
}
|
||
|
||
nota = !nota.Equals("") ? "(*) " + nota : nota;
|
||
return datiSeiUnico.FormatBanca(nota);
|
||
}
|
||
|
||
}
|
||
}
|