322 lines
15 KiB
C#
322 lines
15 KiB
C#
using System;
|
|
using Consulenza.ReportWriter.Business;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using System.Data;
|
|
using Consulenza.ReportWriter.Business.CHART_PDF;
|
|
using System.Collections.Generic;
|
|
using Consulenza.ReportCommon;
|
|
using Consulenza.ReportWriter.Business.Entity;
|
|
using System.Linq;
|
|
using ceTe.DynamicPDF;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// S16.PatrimonioFideuramRappresentazioneAssetClass idSezione = 59
|
|
/// </summary>
|
|
public class S16 : Entity.Section
|
|
{
|
|
|
|
public S16(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S16", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
protected override sealed void Draw()
|
|
{
|
|
var dati = GetDataSet();
|
|
|
|
|
|
#region Testo introduttivo grafico
|
|
if (getTesto().Length > 0)
|
|
{
|
|
AddElement(new SpacePDF(20));
|
|
AddElement(new FormattedTextAreaPDF(getTesto(), EnvironmentFacade.RendererFacade.XLeftLimit) {FontSize=7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
|
AddElement(new SpacePDF(15));
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Tabella Patrimonio
|
|
FormattedTextAreaPDF captionPatrimonioCtv = new FormattedTextAreaPDF(dati.Tables["patrimonio"].Rows[0]["Descrizione"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit, 160) { FontSize = 7, BackGroundMarginLeft = 10, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, AutoIncrementYWritable = false };
|
|
AddElement(captionPatrimonioCtv);
|
|
FormattedTextAreaPDF ctvPatrimonio = new FormattedTextAreaPDF(dati.Tables["patrimonio"].Rows[0]["Valore"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit + 165) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = true };
|
|
AddElement(ctvPatrimonio);
|
|
|
|
AddElement(new SpacePDF(20));
|
|
|
|
#endregion
|
|
|
|
#region Grafico a barre
|
|
|
|
//AddElement(new FormattedTextAreaPDF("Asset class", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 8, 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 = 8, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
|
|
#region table finta per nota a piè del grafico
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("descrizione", typeof(string));
|
|
dt.Columns.Add("dis", typeof(string));
|
|
dt.Rows.Add("","");
|
|
var tabellaAsset = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit,dt)
|
|
{
|
|
Style = Style.ConsulenzaUnica,
|
|
Header = false,
|
|
|
|
Footer = false,
|
|
AlternateRow = false,
|
|
RowHeight = 28,
|
|
ShowSeparationLines = false
|
|
|
|
};
|
|
tabellaAsset.Columns.Add(new ColumnPDF("descrizione", 145, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "descrizione", "") { HeaderFontSize = 7, PaddingLeft = 20, FontSize = 7 });
|
|
tabellaAsset.Columns.Add(new ColumnPDF("distribuzione", 375, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "dis", "") { HeaderPaddingLeft = 5, HeaderFontSize = 7, DeltaYContent = 2 });
|
|
#endregion
|
|
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
|
|
};
|
|
graficoBarre.Headers.Add(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 });
|
|
graficoBarre.Headers.Add(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 });
|
|
|
|
var serieCollezione = new List<Serie> { new Serie { Name = "Asset", Border = true } };
|
|
|
|
foreach (DataRow item in dati.Tables["assetClass"].Rows)
|
|
{
|
|
serieCollezione[0].Points.Add(new Point
|
|
{
|
|
ShowLabelAxisY = true,
|
|
LabelAxisY = isControvalore() ? Helper.FormatCurrency(item["ControvalorePercentuale"].ToString()) : Helper.FormatDecimal(item["ControvalorePercentuale"].ToString(), 2),
|
|
FontSizeLabelAxisY = 7,
|
|
|
|
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
|
Value = !isControvalore() ? (Convert.ToDouble(item["ControvalorePercentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["ControvalorePercentuale"])) : Convert.ToDouble(item["ControvalorePercentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["ControvalorePercentuale"]), // Convert.ToDouble(Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
|
|
ShowLabelAxisX = true,
|
|
LabelAxisX = item["Asset"].ToString(),
|
|
FontSizeLabelAxisX = 7,
|
|
FontBoldLabelAxisY = false
|
|
});
|
|
}
|
|
|
|
graficoBarre.SeriesCollection = serieCollezione;
|
|
AddElement(graficoBarre);
|
|
AddElement(tabellaAsset);
|
|
|
|
#endregion
|
|
#region Nota del Patrimonio Casa
|
|
if (GetNote1().Length > 0)
|
|
{
|
|
captionPatrimonioCtv.Text += "*";
|
|
AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = 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();
|
|
ds.Tables.Add(new DataTable("patrimonio"));
|
|
ds.Tables.Add(new DataTable("assetClass"));
|
|
var displayInfo = datiSeiUnico.displayInfos().assetDisplayInfos;
|
|
|
|
var dataAsset = datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.distribuzione.elencoSlice;
|
|
|
|
var patrimonioFideuram = datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.totaliPatrimonio.risorseFinanziarie
|
|
+ datiSeiUnico.patrimonioUnit().patrimonioCasa.assetClass.totaliPatrimonio.partiteViaggianti;
|
|
|
|
#region Patrimonio casa
|
|
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
|
|
var testoPatrimonio = string.Format("Patrimonio {0} (€)", Helper.ReplaceVariables("$/Banca/$", EnvironmentFacade.ReportEnvironment));
|
|
ds.Tables["patrimonio"].Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.CASA_TOTALEPOSITIVO.ToString()));
|
|
|
|
#endregion
|
|
|
|
#region Asset
|
|
|
|
|
|
ds.Tables["assetClass"].Columns.Add(new DataColumn("Asset", typeof(string)));
|
|
ds.Tables["assetClass"].Columns.Add(new DataColumn("Red", typeof(int)));
|
|
ds.Tables["assetClass"].Columns.Add(new DataColumn("Green", typeof(int)));
|
|
ds.Tables["assetClass"].Columns.Add(new DataColumn("Blue", typeof(int)));
|
|
ds.Tables["assetClass"].Columns.Add(new DataColumn("ControvalorePercentuale", typeof(decimal)));
|
|
|
|
foreach (var valore in from c in displayInfo
|
|
join l in dataAsset on c.key equals l.codice
|
|
orderby c.value.order
|
|
select new
|
|
{
|
|
l.descrizione,
|
|
new ColorPDF(c.value.fill).Red,
|
|
new ColorPDF(c.value.fill).Green,
|
|
new ColorPDF(c.value.fill).Blue,
|
|
l.ctvCC,
|
|
l.ctv,
|
|
l.peso,
|
|
l.pesoCC
|
|
})
|
|
{
|
|
ds.Tables["assetClass"].Rows.Add(
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
isControvalore() ? presenzaContocorrenteInMonterio() ? valore.ctvCC : valore.ctv
|
|
: (presenzaContocorrenteInMonterio() ? valore.pesoCC : valore.peso) * 100
|
|
|
|
);
|
|
}
|
|
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
public virtual string getTesto()
|
|
{
|
|
return !isControvalore() ? Helper.ReplaceVariables(GetText().Rows[0]["testo1"].ToString(), base.EnvironmentFacade.ReportEnvironment) : Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), base.EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
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().patrimonioCasa.assetClass;
|
|
|
|
decimal CCN_CASA = datiSeiUnico.CASA_CCN;
|
|
decimal GPELIGOFONDI_CASA = datiSeiUnico.CASA_GPELIGOFONDI;
|
|
decimal GPELIGTITOLI_CASA = datiSeiUnico.CASA_GPELIGTITOLI;
|
|
|
|
// 20181009 AC
|
|
decimal TUOFOGLIO_CASA = datiSeiUnico.CASA_TUOFOGLIO;
|
|
//--20181009 AC
|
|
|
|
// 20181009 AC
|
|
//if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0
|
|
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || TUOFOGLIO_CASA != 0)
|
|
//--20181009 AC
|
|
{
|
|
nota += token + "Il controvalore esclude il saldo negativo";
|
|
token = " ";
|
|
if (CCN_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("dei conti correnti ({0} €)", CCN_CASA);
|
|
token = ", ";
|
|
}
|
|
// 20181009 AC
|
|
if (TUOFOGLIO_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante Il Mio Foglio ({0} €)", TUOFOGLIO_CASA);
|
|
token = ", ";
|
|
}
|
|
//--20181009 AC
|
|
if (GPELIGOFONDI_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Fondi ({0} €)", GPELIGOFONDI_CASA);
|
|
token = ", ";
|
|
}
|
|
if (GPELIGTITOLI_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Titoli ({0} €)", GPELIGTITOLI_CASA);
|
|
token = ", ";
|
|
}
|
|
nota += ".";
|
|
token = " ";
|
|
}
|
|
|
|
|
|
decimal GC = (presenzaContocorrenteInMonterio() ? assetClass.distribuzione.coverageCC : assetClass.distribuzione.coverage) * 100;
|
|
|
|
decimal OC_CASA = datiSeiUnico.CASA_OC;
|
|
decimal CC_CASA = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.CASA_CC;
|
|
decimal PNR_CASA = 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_CASA != 0 || CC_CASA != 0 || OC_CASA != 0)
|
|
{
|
|
nota += token + "non sono considerati";
|
|
token = " ";
|
|
if (PNR_CASA != 0 || CC_CASA != 0 || OC_CASA != 0)
|
|
{
|
|
if (PNR_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("i prodotti non rappresentabili ({0} €)", PNR_CASA);
|
|
token = ", ";
|
|
}
|
|
if (CC_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_CASA);
|
|
token = ", ";
|
|
}
|
|
if (OC_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("gli importi relativi alle operazioni in corso ({0} €)", OC_CASA);
|
|
token = ", ";
|
|
}
|
|
token = " ";
|
|
}
|
|
}
|
|
|
|
nota += ".";
|
|
token = " ";
|
|
}
|
|
|
|
nota = !nota.Equals("") ? "(*) " + nota : nota;
|
|
return datiSeiUnico.FormatBanca(nota);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|