330 lines
15 KiB
C#
330 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 Consulenza.ReportCommon;
|
|
using System.Collections.Generic;
|
|
using Consulenza.ReportWriter.Business.Entity;
|
|
using System.Linq;
|
|
using ceTe.DynamicPDF;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// Scheda 5: Patrimonio finanziario: rappresentazione per macroasset class. IdSezione 48.
|
|
/// </summary>
|
|
public class S5 : Entity.Section
|
|
{
|
|
|
|
public S5(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S5", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
protected override sealed void Draw()
|
|
{
|
|
var dati = GetDataSet();
|
|
|
|
|
|
#region Testo introduttivo grafico
|
|
|
|
AddElement(new SpacePDF(20));
|
|
|
|
|
|
AddElement(new FormattedTextAreaPDF(GetTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) {FontSize=7, TextHorizontalAlign = 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("Macro 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
|
|
};
|
|
var dtGraficoBarre = dati.Tables[1];
|
|
var serieCollezione = new List<Serie> { new Serie { Name = "MacroAssetClass", 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["MacroAssetClass"].ToString(),
|
|
FontSizeLabelAxisX = 7,
|
|
FontBoldLabelAxisY = false
|
|
});
|
|
}
|
|
|
|
graficoBarre.SeriesCollection = serieCollezione;
|
|
|
|
AddElement(graficoBarre);
|
|
|
|
#endregion
|
|
|
|
#region Nota del PatrimonioFinanziario
|
|
if (GetNote1().Length > 0)
|
|
{
|
|
|
|
AddElement(new SpacePDF(20));
|
|
AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = TextAlign.Justify });
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
protected sealed override DataTable GetDataTable()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
|
|
protected sealed override DataSet GetDataSet()
|
|
{
|
|
var ds = new DataSet();
|
|
|
|
var macroAssetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass.distribuzione.elencoSlice;
|
|
var displayInfo = datiSeiUnico.displayInfos().macroAssetDisplayInfos.ToList();
|
|
|
|
#region Patrimonio finanziario
|
|
|
|
var dtPatrimonio = new DataTable();
|
|
dtPatrimonio.Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
dtPatrimonio.Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
|
|
var totaliPatrimonioBanca = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.totaliPatrimonio;
|
|
var totaliPatrimonioTerzi = datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroAssetClass.totaliPatrimonio;
|
|
var totalePatrimonioFinanziario = totaliPatrimonioBanca.risorseFinanziarie + totaliPatrimonioTerzi.risorseFinanziarie;
|
|
|
|
var testoPatrimonio = string.Format("Patrimonio finanziario complessivo (€)" + (GetNote1().Length>0 ? "*" : ""));
|
|
dtPatrimonio.Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.FNZ_TOTALEPOSITIVO.ToString()));
|
|
|
|
ds.Tables.Add(dtPatrimonio);
|
|
|
|
#endregion
|
|
|
|
#region MacroAssetClass
|
|
|
|
|
|
|
|
var dtMacroAssetClass = new DataTable();
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("MacroAssetClass", typeof(string)));
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("Red", typeof(int)));
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("Green", typeof(int)));
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("Blue", typeof(int)));
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
|
|
dtMacroAssetClass.Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
foreach (var itemDistribuzione in macroAssetClass)
|
|
{
|
|
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;
|
|
|
|
dtMacroAssetClass.Rows.Add(itemDistribuzione.descrizione, colore.Red, colore.Green, colore.Blue, controvalore, percentuale, ordinamento);
|
|
}
|
|
}
|
|
|
|
ds.Tables.Add(dtMacroAssetClass.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 bool sliceNonRappresentabileCopertura() {
|
|
var macroAssetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass.distribuzione.elencoSlice;
|
|
return macroAssetClass.AsEnumerable().FirstOrDefault(o => !o.sliceRappresentabile) != null;
|
|
}
|
|
|
|
public virtual string GetTesto1() {
|
|
var _testi = GetText();
|
|
return !isControvalore() ?
|
|
Helper.ReplaceVariables(_testi.Rows[0]["testo1"].ToString(), base.EnvironmentFacade.ReportEnvironment) :
|
|
Helper.ReplaceVariables(_testi.Rows[0]["testo2"].ToString(), base.EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
|
|
public virtual string GetNote1(){
|
|
|
|
string nota = "";
|
|
string token = "";
|
|
|
|
|
|
var macroAssetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass;
|
|
|
|
decimal CCN_CASA = datiSeiUnico.CASA_CCN;
|
|
decimal GPELIGOFONDI_CASA = datiSeiUnico.CASA_GPELIGOFONDI;
|
|
decimal GPELIGTITOLI_CASA = datiSeiUnico.CASA_GPELIGTITOLI;
|
|
decimal CCN_TERZI = datiSeiUnico.TRZ_CCN;
|
|
|
|
// 20181009 AC
|
|
decimal TUOFOGLIO_CASA = datiSeiUnico.CASA_TUOFOGLIO;
|
|
//--20181009 AC
|
|
|
|
// 20181009 AC
|
|
//if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || CCN_TERZI != 0)
|
|
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || CCN_TERZI != 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 = ", ";
|
|
}
|
|
token = " ";
|
|
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || TUOFOGLIO_CASA != 0)
|
|
{
|
|
nota += token + "del patrimonio $/Banca/$";
|
|
token = ", ";
|
|
}
|
|
if (CCN_TERZI != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("dei conti correnti ({0} €) del patrimonio altri Istituti", CCN_TERZI);
|
|
token = ", ";
|
|
}
|
|
nota += ".";
|
|
token = " ";
|
|
}
|
|
|
|
|
|
decimal GC = (presenzaContocorrenteInMonterio() ? macroAssetClass.distribuzione.coverageCC : macroAssetClass.distribuzione.coverage) * 100;
|
|
|
|
decimal OC_CASA = datiSeiUnico.CASA_OC;
|
|
decimal CC_CASA = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.CASA_CC;
|
|
decimal PNR_CASA = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr;
|
|
|
|
decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
|
|
decimal PNR_TERZI = datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroAssetClass.distribuzione.totaleNonRappr;
|
|
|
|
if(GC<100) {
|
|
nota+= token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro asset class pari a {0}",GC);
|
|
token = ": ";
|
|
if(PNR_CASA!=0 || CC_CASA!=0 || OC_CASA!=0 || PNR_TERZI!=0 || CC_TERZI!=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 + "del patrimonio $/Banca/$";
|
|
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 + "del patrimonio altri Istituti";
|
|
token = ", ";
|
|
}
|
|
}
|
|
|
|
|
|
nota+=".";
|
|
token = " ";
|
|
}
|
|
|
|
nota = !nota.Equals("") ? "(*) " + nota : nota;
|
|
return datiSeiUnico.FormatBanca(nota);
|
|
|
|
}
|
|
|
|
}
|
|
}
|