342 lines
14 KiB
C#
342 lines
14 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;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// Scheda 7. Patrimonio finanziario: distribuzione per macrocategoria di prodotto. IdSezione 50
|
|
/// </summary>
|
|
public class S7 : Entity.Section
|
|
{
|
|
|
|
public S7(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S7", 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 = ceTe.DynamicPDF.TextAlign.Justify });
|
|
AddElement(new SpacePDF(15));
|
|
|
|
#endregion
|
|
|
|
#region Tabella Patrimonio
|
|
|
|
var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["patrimonio"])
|
|
{
|
|
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 categoria", 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["macrocategorie"];
|
|
var serieCollezione = new List<Serie> { new Serie { Name = "MacroCategoria", 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["MacroCategoria"].ToString(),
|
|
FontSizeLabelAxisX = 7,
|
|
FontBoldLabelAxisY = false,
|
|
});
|
|
}
|
|
|
|
graficoBarre.SeriesCollection = serieCollezione;
|
|
|
|
AddElement(graficoBarre);
|
|
|
|
#endregion
|
|
|
|
#region Nota del PatrimonioFinanziario
|
|
|
|
AddElement(new SpacePDF(30));
|
|
AddElement(new FormattedTextAreaPDF(Helper.ReplaceVariables(GetNote1(), EnvironmentFacade.ReportEnvironment), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
protected sealed override DataTable GetDataTable()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
|
|
protected override DataSet GetDataSet()
|
|
{
|
|
var ds = new DataSet();
|
|
ds.Tables.Add(new DataTable("patrimonio"));
|
|
ds.Tables.Add(new DataTable("macrocategorie"));
|
|
|
|
var patrimonioFinanziario = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroCategoria;
|
|
|
|
|
|
var displayInfo = datiSeiUnico.displayInfos().macroCategoriaDisplayInfos.ToList();
|
|
|
|
#region Patrimonio finanziario
|
|
|
|
|
|
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 finanziario complessivo (€){0}", GetNote1().Length>0 ? "*" : "");
|
|
|
|
ds.Tables["patrimonio"].Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.FNZ_TOTALEPOSITIVO.ToString()));
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Macrocategoria di prodotto
|
|
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("MacroCategoria", typeof(string)));
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Red", typeof(int)));
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Green", typeof(int)));
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Blue", typeof(int)));
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
|
|
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
var dataMacroCategoria = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroCategoria.distribuzione.elencoSlice;
|
|
|
|
foreach (var valore in from c in displayInfo
|
|
join l in dataMacroCategoria 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.pesoCC
|
|
})
|
|
{
|
|
ds.Tables["macrocategorie"].Rows.Add(
|
|
valore.descrizione,
|
|
valore.Red,
|
|
valore.Green,
|
|
valore.Blue,
|
|
valore.ctvCC,
|
|
Helper.FormatDecimal((valore.pesoCC * 100).ToString(),2)
|
|
);
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
|
|
public virtual bool isControvalore()
|
|
{
|
|
return !GetOption<Opzione3>().Valore;
|
|
}
|
|
public virtual bool presenzaContocorrenteInMonterio() { return true; }
|
|
public virtual string GetTesto1() {
|
|
return !isControvalore() ?
|
|
Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), base.EnvironmentFacade.ReportEnvironment) :
|
|
Helper.ReplaceVariables(GetText().Rows[0]["testo3"].ToString(), base.EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
|
|
public virtual string GetNote1()
|
|
{
|
|
|
|
string nota = "";
|
|
string token = "";
|
|
|
|
|
|
var macroCategoria = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroCategoria;
|
|
|
|
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)
|
|
{
|
|
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() ? macroCategoria.distribuzione.coverageCC : macroCategoria.distribuzione.coverage) * 100;
|
|
|
|
decimal OC_CASA = datiSeiUnico.CASA_OC;
|
|
decimal CC_CASA = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.CASA_CC;
|
|
decimal PNR_CASA = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroCategoria.distribuzione.totaleNonRappr;
|
|
|
|
decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
|
|
decimal PNR_TERZI = datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroCategoria.distribuzione.totaleNonRappr;
|
|
|
|
if (GC < 100)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro categorie 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|