276 lines
12 KiB
C#
276 lines
12 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 System.Linq;
|
|
using Consulenza.ReportWriter.Business.Entity;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// Scheda 4. Patrimonio finanziario: distribuzione per intermediario. IdSezione 47
|
|
/// </summary>
|
|
public class S4 : Entity.Section
|
|
{
|
|
|
|
|
|
public S4(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S4", 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[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("Intermediario", 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 = "Intermediario", 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["Intermediario"].ToString(),
|
|
FontSizeLabelAxisX = 7,
|
|
FontBoldLabelAxisY = false
|
|
});
|
|
}
|
|
|
|
graficoBarre.SeriesCollection = serieCollezione;
|
|
|
|
AddElement(graficoBarre);
|
|
#region Nota del PatrimonioFinanziario
|
|
|
|
AddElement(new SpacePDF(40));
|
|
AddElement(new FormattedTextAreaPDF(Helper.ReplaceVariables(GetNote1(), EnvironmentFacade.ReportEnvironment), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
|
|
protected sealed override DataTable GetDataTable()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected sealed override DataSet GetDataSet()
|
|
{
|
|
var ds = new DataSet();
|
|
|
|
|
|
|
|
|
|
var totalePatrimonioFinanziario = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.intermediario.totale;
|
|
var intermediari = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.intermediario;
|
|
var displayInfo = datiSeiUnico.displayInfos().intermediariDisplayInfos.ToList();
|
|
var displayInfoT = datiSeiUnico.displayInfos().tipoPatrimonioDisplayInfos.ToList();
|
|
var intermediariAsterisco = datiSeiUnico.patrimonioUnit().patrimonioTerzi.patrimonioTerziBean.intermediari;
|
|
var intermediarioCasaCCN = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale.contoCorrenteNegativo;
|
|
#region Patrimonio finanziario
|
|
|
|
var dtPatrimonio = new DataTable();
|
|
dtPatrimonio.Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
dtPatrimonio.Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
|
|
var testoPatrimonio = string.Format("Patrimonio finanziario complessivo (€){0}", (GetNote1().Length>0 ? "*" : ""));
|
|
|
|
dtPatrimonio.Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.FNZ_TOTALEPOSITIVO.ToString()));
|
|
|
|
ds.Tables.Add(dtPatrimonio);
|
|
|
|
#endregion
|
|
|
|
#region Intermediari
|
|
|
|
var dtIntermediari = new DataTable();
|
|
dtIntermediari.Columns.Add(new DataColumn("Intermediario", typeof(string)));
|
|
dtIntermediari.Columns.Add(new DataColumn("Red", typeof(int)));
|
|
dtIntermediari.Columns.Add(new DataColumn("Green", typeof(int)));
|
|
dtIntermediari.Columns.Add(new DataColumn("Blue", typeof(int)));
|
|
dtIntermediari.Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
|
|
dtIntermediari.Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
|
|
dtIntermediari.Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
//var intermedi = datiSeiUnico.patrimonioUnit().patrimonioTerzi.patrimonioTerziBean.intermediari.ToList();
|
|
foreach (var item in intermediari.elencoSlice)
|
|
{
|
|
|
|
var mapDisplayInfo = item.codice.Equals("PTBF") || item.codice.Equals("PTSPI") ?
|
|
displayInfoT.FirstOrDefault(o => o.key.Equals(item.codice)).value :
|
|
displayInfo.FirstOrDefault(o => o.key.Equals(item.codice)).value;
|
|
var colore = new ColorPDF(mapDisplayInfo.fill);
|
|
var ordinamento = mapDisplayInfo.order;
|
|
|
|
bool contocorrentenegativo = item.codice == "PTBF" || item.codice == "PTSPI" ?
|
|
contocorrentenegativo = intermediarioCasaCCN != 0
|
|
: contocorrentenegativo = intermediariAsterisco.FirstOrDefault(o => o.idIntermediario == Convert.ToInt32(item.chiaveAggragazione)).contoCorrentiNegativi != null &&
|
|
intermediariAsterisco.FirstOrDefault(o => o.idIntermediario == Convert.ToInt32(item.chiaveAggragazione)).contoCorrentiNegativi != 0? true : false;
|
|
|
|
dtIntermediari.Rows.Add(
|
|
GetNote1().Length>0 && contocorrentenegativo
|
|
? item.descrizione + "*" :
|
|
item.descrizione,
|
|
colore.Red, colore.Green, colore.Blue,
|
|
item.ctv,
|
|
item.peso * 100,
|
|
ordinamento);
|
|
}
|
|
|
|
ds.Tables.Add(dtIntermediari.AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento")).CopyToDataTable());
|
|
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
public virtual bool isControvalore()
|
|
{
|
|
return !GetOption<Opzione3>().Valore;
|
|
}
|
|
public virtual bool presenzaContocorrenteInMonterio() { return true; }
|
|
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 = "";
|
|
|
|
|
|
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 = " ";
|
|
}
|
|
|
|
nota = !nota.Equals("") ? "(*) " + nota : nota;
|
|
return datiSeiUnico.FormatBanca(nota);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|