3185 lines
167 KiB
C#
3185 lines
167 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Consulenza.ExternalServices;
|
|
using Consulenza.ReportWriter.Business;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using System.Data;
|
|
using Consulenza.ReportWriter.Business.CHART_PDF;
|
|
using Consulenza.ReportCommon;
|
|
using Consulenza.ReportWriter.Business.Entity;
|
|
using System.Text;
|
|
using ceTe.DynamicPDF;
|
|
using System.Reflection;
|
|
using System.ComponentModel;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio
|
|
{
|
|
/// <summary>
|
|
/// Scheda 15
|
|
/// </summary>
|
|
public class S15 : Entity.Section
|
|
{
|
|
//public virtual bool presenzaContocorrenteInMonterio() { return GetOption<Opzione4_2>().Valore; }
|
|
|
|
public bool bFlag = false;
|
|
public decimal GC_AssetClass = 0;
|
|
DatiPatrimonioGenerali _clsDatiPatrimonioGenerali = new DatiPatrimonioGenerali();
|
|
|
|
public S15(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
if (idSection == 999)
|
|
bFlag = true;
|
|
else
|
|
bFlag = false;
|
|
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S15", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Scheda15. Analisi del rischio - Diversificazione del patrimonio
|
|
/// </summary>
|
|
protected override sealed void Draw()
|
|
{
|
|
|
|
/******** Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino ******/
|
|
//var dataset = GetDataSet();
|
|
var dataset = GetDataSetNew();
|
|
/***********************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#region Pagina 1
|
|
AddElement(new SpacePDF(40));
|
|
var titolo1 = new FormattedTextAreaPDF(getTesto1(), 35, 700) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left };
|
|
AddElement(titolo1);
|
|
AddElement(new SpacePDF(10));
|
|
|
|
#region Tabella
|
|
|
|
var tabellaPatrimonio = new TablePDF(35, dataset.Tables["patrimonio"], dataset.Tables["patrimonioFooter"])
|
|
{
|
|
Style = Style.Immobiliare,
|
|
AlternateRow = false,
|
|
HeaderHeight = 15,
|
|
RowHeight = 10,
|
|
ShowBorderLastLine = false,
|
|
ShowBorderLastLineInPageBreak = false,
|
|
ShowBorderHeader = false
|
|
};
|
|
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", "Patrimonio complessivo") { DeltaYContent = 1 });
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Valore", "Valore totale (€)") { DeltaYContent = 1 });
|
|
tabellaPatrimonio.Columns.Add(new ColumnPDF("peso", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Peso", "Peso (%)") { DeltaYContent = 1 });
|
|
|
|
tabellaPatrimonio.FooterColumns.Add(new ColumnPDF("descrizione", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo));
|
|
tabellaPatrimonio.FooterColumns.Add(new ColumnPDF("valore", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo));
|
|
tabellaPatrimonio.FooterColumns.Add(new ColumnPDF("peso", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo));
|
|
|
|
if (bFlag)
|
|
{
|
|
if (getNota2().Length > 0 || getNota3().Length > 0)
|
|
tabellaPatrimonio.Notes.Add(new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella, getNota2() + getNota3()) { FontSize = 7, DeltaY = 3 });
|
|
}
|
|
else
|
|
{
|
|
if (getNota2().Length > 0 || getNota3().Length > 0)
|
|
tabellaPatrimonio.Notes.Add(new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella, getNota2() + getNota3()) { FontSize = 7, DeltaY = 3 });
|
|
}
|
|
#endregion
|
|
|
|
int i = 0;
|
|
foreach (DataRow rw in dataset.Tables["patrimonio"].Rows)
|
|
{
|
|
if (!dataset.Tables["patrimonio"].Rows[i]["Descrizione"].ToString().Contains("<B>"))
|
|
tabellaPatrimonio.Cells[0, i].XContentOffset = 10;
|
|
i++;
|
|
}
|
|
|
|
AddElement(tabellaPatrimonio);
|
|
AddElement(new SpacePDF(20));
|
|
|
|
if (dataset.Tables["composizionePatrimonio"].Rows.Count > 0 )
|
|
{
|
|
var tabellaComposizione = new TablePDF(35, dataset.Tables["composizionePatrimonio"].AsEnumerable().OrderBy(x => x.Field<int>("ordinamento")).CopyToDataTable(),
|
|
dataset.Tables["composizionePatrimonioFooter"])
|
|
{
|
|
Style = Style.Immobiliare,
|
|
AlternateRow = false,
|
|
HeaderHeight = 15,
|
|
RowHeight = 10,
|
|
ShowBorderLastLine = false,
|
|
ShowBorderLastLineInPageBreak = false,
|
|
ShowBorderHeader = false
|
|
};
|
|
|
|
tabellaComposizione.Columns.Add(new ColumnPDF("composizione", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Composizione", "Composizione patrimonio finanziario") { DeltaYContent = 1 });
|
|
tabellaComposizione.Columns.Add(new ColumnPDF("valore", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Valore", "Valore totale (€)") { DeltaYContent = 1 });
|
|
tabellaComposizione.Columns.Add(new ColumnPDF("peso", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "Peso", "Peso (%)") { DeltaYContent = 1 });
|
|
|
|
tabellaComposizione.FooterColumns.Add(new ColumnPDF("composizione", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo));
|
|
tabellaComposizione.FooterColumns.Add(new ColumnPDF("valore", 130, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo));
|
|
tabellaComposizione.FooterColumns.Add(new ColumnPDF("peso", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo));
|
|
|
|
if (bFlag)
|
|
{
|
|
if (getNota4().Length > 0)
|
|
tabellaComposizione.Notes.Add(new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella, getNota4()) { FontSize = 7, DeltaY = 3 });
|
|
}
|
|
else
|
|
{
|
|
if (getNota4().Length > 0)
|
|
tabellaComposizione.Notes.Add(new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella, getNota4()) { FontSize = 7, DeltaY = 3 });
|
|
}
|
|
|
|
AddElement(tabellaComposizione);
|
|
}
|
|
#endregion
|
|
|
|
AddElement(new ResetterYPDF());
|
|
#region Grafico torta
|
|
|
|
var serieTorta = new List<Serie>();
|
|
|
|
foreach (var row in dataset.Tables["torta"].AsEnumerable())
|
|
{
|
|
serieTorta.Add(new Serie { Name = row["tipologia"].ToString() });
|
|
|
|
serieTorta[0].Points.Add(new Point
|
|
{
|
|
LabelAxisX = row["tipologia"].ToString(),
|
|
Value = Convert.ToDouble(row["peso"]),
|
|
Color = getColor(row["tipologia"].ToString()),
|
|
ShowLabelAxisX = false,
|
|
ShowLabelAxisY = false,
|
|
FontSizeLabelAxisX = 10,
|
|
FontSizeLabelAxisY = 10,
|
|
Label = Convert.ToDouble(row["peso"]).ToString("0.0"),
|
|
ID = row["ordine"].ToString(),
|
|
});
|
|
|
|
}
|
|
serieTorta[0].Points = SortPointsList(serieTorta[0].Points);
|
|
#endregion
|
|
|
|
// Aggiunta ES
|
|
//serieTorta[0].AutoCalculateLastPointLabelPosition = true;
|
|
// Fine
|
|
|
|
var torta = new PiePDF(40 + tabellaPatrimonio.Width, 0.2F)
|
|
{
|
|
Width = 340,
|
|
Height = 340,
|
|
SeriesCollection = serieTorta,
|
|
StartAngle = 250,
|
|
ShowLabelPoints = true,
|
|
Style3DEnabled = false,
|
|
AutoIncrementYWritable = true,
|
|
/********************Fix per valore a 2 cifre decimali sul peso 17/07/2020 - Pino*****************/
|
|
LabelDecimalDigitsCount = 2,
|
|
//LabelDecimalDigitsCount = 1, //Originale
|
|
/*************************************************************************************************/
|
|
FontLabelSize = 5f,
|
|
CustomPlottingHeight = 50,
|
|
CustomPlottingWidth = 50,
|
|
CustomPlottingX = 25,
|
|
CustomPlottingY = 7,
|
|
UseCustomPlotting = true,
|
|
};
|
|
|
|
//torta.Style3DEnabled = true;
|
|
//torta.Style3DXAngle = 15;
|
|
|
|
AddElement(new SpacePDF(70));
|
|
var tortaTitolo = new FormattedTextAreaPDF(string.Format("{0}", "Patrimonio complessivo"), 130 + tabellaPatrimonio.Width) { FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 10, FontBold = true, AutoIncrementYWritable = true, DeltaY = -2 };
|
|
|
|
AddElement(tortaTitolo);
|
|
|
|
AddElement(torta);
|
|
|
|
|
|
//AddElement(new SpacePDF(100));
|
|
|
|
var xLegenda1 = 0;
|
|
var xLegenda2 = 0;
|
|
|
|
if (dataset.Tables["composizionePatrimonio"].Rows.Count > 0)
|
|
{
|
|
xLegenda1 = 55 + (int)tabellaPatrimonio.Width;
|
|
xLegenda2 = 215 + (int)tabellaPatrimonio.Width;
|
|
}
|
|
else
|
|
{
|
|
//xLegenda1 = 85 + (int)tabellaPatrimonio.Width;
|
|
xLegenda2 = 140 + (int)tabellaPatrimonio.Width;
|
|
}
|
|
|
|
|
|
ColorPDF coloriUsoAbitativo = new ColorPDF(207, 220, 210);
|
|
ColorPDF coloriStrumentale = new ColorPDF(167, 192, 168);
|
|
ColorPDF coloriInvestimento = new ColorPDF(115, 152, 109);
|
|
ColorPDF coloriNonSpecificata = new ColorPDF(245, 245, 220);
|
|
ColorPDF coloriFideuram = new ColorPDF(174, 150, 81);
|
|
ColorPDF coloriTerzi = new ColorPDF(215, 206, 169);
|
|
|
|
float _yLegend = 340;
|
|
foreach (var row in dataset.Tables["torta"].AsEnumerable())
|
|
{
|
|
switch (row["indice"].ToString())
|
|
{
|
|
|
|
case "U":
|
|
var legendaUsoAbitativoRettangolo = new RectanglePDF(xLegenda2, 12, 17, coloriUsoAbitativo) { AutoIncrementYWritable = false, Y = _yLegend };
|
|
var legendaUsoAbitativoTesto = new FormattedTextAreaPDF(string.Format("{0}", "Immobili d'uso abitativo"), xLegenda2 + 25) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = 0, Y = _yLegend };
|
|
|
|
AddElement(legendaUsoAbitativoRettangolo);
|
|
AddElement(legendaUsoAbitativoTesto);
|
|
_yLegend += 15;
|
|
break;
|
|
|
|
case "PF":
|
|
var legendaFideuram = new RectanglePDF(xLegenda1, 12, 17, coloriFideuram) { AutoIncrementYWritable = false, Y = _yLegend };
|
|
var legendaFideuramTesto = new FormattedTextAreaPDF(string.Format("{0}", "Patrimonio finanziario Fideuram"), xLegenda1 + 25) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = 0, Y = _yLegend };
|
|
|
|
AddElement(legendaFideuram);
|
|
AddElement(legendaFideuramTesto);
|
|
if (dataset.Tables["torta"].AsEnumerable().Any(x => x.Field<string>("indice").Equals("PT")))
|
|
_yLegend += 15;
|
|
break;
|
|
|
|
case "S":
|
|
var legendaStrumentaleRettangolo = new RectanglePDF(xLegenda2, 12, 17, coloriStrumentale) { AutoIncrementYWritable = false, Y = _yLegend };
|
|
var legendaStrumentaleTesto = new FormattedTextAreaPDF(string.Format("{0}", "Immobili strumentali"), xLegenda2 + 25) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = 0, Y = _yLegend };
|
|
|
|
AddElement(legendaStrumentaleRettangolo);
|
|
AddElement(legendaStrumentaleTesto);
|
|
_yLegend += 15;
|
|
break;
|
|
|
|
case "PT":
|
|
var legendaTerzi = new RectanglePDF(xLegenda1, 12, 17, coloriTerzi) { AutoIncrementYWritable = false, Y = _yLegend };
|
|
var legendaTerziTesto = new FormattedTextAreaPDF(string.Format("{0}", "Patrimonio finanziario altri istituti"), xLegenda1 + 25) { FontSize = 7, AutoIncrementYWritable = false, DeltaY = 0, Y = _yLegend };
|
|
|
|
AddElement(legendaTerzi);
|
|
AddElement(legendaTerziTesto);
|
|
if (dataset.Tables["torta"].AsEnumerable().Any(x => x.Field<string>("indice").Equals("S") || x.Field<string>("indice").Equals("NS")
|
|
|| x.Field<string>("indice").Equals("U") || x.Field<string>("indice").Equals("I")))
|
|
_yLegend = 340;
|
|
break;
|
|
|
|
case "I":
|
|
var legendaInvestimentoRettangolo = new RectanglePDF(xLegenda2, 12, 17, coloriInvestimento) { AutoIncrementYWritable = false, Y = _yLegend };
|
|
var legendaInvestimentoTesto = new FormattedTextAreaPDF(string.Format("{0}", "Immobili d'investimento"), xLegenda2 + 25) { FontSize = 7, AutoIncrementYWritable = true, DeltaY = 0, Y = _yLegend };
|
|
|
|
AddElement(legendaInvestimentoRettangolo);
|
|
AddElement(legendaInvestimentoTesto);
|
|
_yLegend += 15;
|
|
break;
|
|
|
|
case "NS":
|
|
var legendaNonSpecificataRettangolo = new RectanglePDF(xLegenda2, 12, 17, coloriNonSpecificata) { AutoIncrementYWritable = false, Y = _yLegend };
|
|
var legendaNonSpecificataTesto = new FormattedTextAreaPDF(string.Format("{0}", "Finalità non specificata"), xLegenda2 + 25) { FontSize = 7, AutoIncrementYWritable = true, DeltaY = 0, Y = _yLegend };
|
|
|
|
AddElement(legendaNonSpecificataRettangolo);
|
|
AddElement(legendaNonSpecificataTesto);
|
|
_yLegend += 15;
|
|
break;
|
|
}
|
|
}
|
|
|
|
float startFrameX = tabellaPatrimonio.X + tabellaPatrimonio.Width + 10;
|
|
float startFrameY = 79;
|
|
//addFrame(startFrameX, startFrameX + 320, startFrameY, startFrameY + 335);
|
|
addFrame(startFrameX, startFrameX + 320, startFrameY, startFrameY + 325);
|
|
|
|
|
|
var pagina2 = GetDataSet2();
|
|
AddElement(new PagePDF(PagePDF.PagePDFType.Generic));
|
|
|
|
var border = new RectanglePDF(332, 700, new ColorPDF(0, 0, 0))
|
|
{
|
|
Y = 105,
|
|
X = 40,
|
|
BorderColor = new ColorPDF(196, 196, 186),
|
|
BorderStyle = LineStylePDF.Solid,
|
|
BorderWidth = 0.75f,
|
|
Color = new ColorPDF(255, 255, 255),
|
|
AutoIncrementYWritable = false
|
|
};
|
|
AddElement(border);
|
|
|
|
DrawDiamondBar(570, 175, 100, 233, pagina2.Tables[1].Rows[0][2].ToString());
|
|
|
|
AddElement(new SpacePDF(40));
|
|
var titolo2 = new FormattedTextAreaPDF(getTesto2(), 35, 750) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard };
|
|
|
|
AddElement(titolo2);
|
|
AddElement(new SpacePDF(20));
|
|
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
var titoloRiquadro = new FormattedTextAreaPDF("Diversificazione del patrimonio complessivo", 40, 700)
|
|
{
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Bianco,
|
|
FontBold = true,
|
|
//BackGroundColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo,
|
|
BackGroundColor = new ColorPDF(196, 196, 186),
|
|
DeltaX = 5,
|
|
FixedHeight = 5,
|
|
DeltaY = 2
|
|
};
|
|
|
|
var titolo2_2 = new FormattedTextAreaPDF(getTesto2_2(), 40, 400) { AutoIncrementYWritable = true, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, DeltaX = 5, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
|
|
|
|
if (pagina2.Tables[0].Rows[1]["grado"].ToString().Trim() == "0,00" && pagina2.Tables[1].Rows[0]["gradoFooter"].ToString().Trim() == "0,00")
|
|
DrawCustomTable(50, 325, 105, 400, pagina2.Tables[0].Rows[0]["grado"].ToString(),
|
|
"n.c.",
|
|
"n.c.");
|
|
else
|
|
DrawCustomTable(50, 325, 105, 400, pagina2.Tables[0].Rows[0]["grado"].ToString(),
|
|
pagina2.Tables[0].Rows[1]["grado"].ToString(),
|
|
pagina2.Tables[1].Rows[0]["gradoFooter"].ToString());
|
|
|
|
TablePDF tablePDF = new TablePDF(40, pagina2.Tables[0], pagina2.Tables[1])
|
|
{
|
|
Style = Style.Immobiliare,
|
|
AlternateRow = false,
|
|
HeaderHeight = 25,
|
|
RowHeight = 25,
|
|
Footer = true,
|
|
PageBreak = true,
|
|
IndexesOfRowLinesToIgnoreSeparators = new List<int>() { 0,1,2},
|
|
ShowSeparationLines = false,
|
|
HideLastSeparationLine = true,
|
|
HideFirstSeparationLine = true,
|
|
ShowBorderLastLine = false,
|
|
ShowBorderLastLineInPageBreak = false,
|
|
ShowFooterSeparationLines = false,
|
|
ShowBorderContent = false,
|
|
ShowBorderFooter = false,
|
|
ShowBorderHeader = false
|
|
};
|
|
|
|
tablePDF.Columns.Add(new ColumnPDF("immagine", 55, HorizontalAlignmentType.Destra, false, true, 11, ColumnType.Immagine, "immagine", "") { HeaderFontBold = true, ScaleColumnTypeImage = 0.1F, DeltaYContent = 7, PaddingLeft = -10 });
|
|
tablePDF.Columns.Add(new ColumnPDF("patrimonio", 145, HorizontalAlignmentType.Sinistra, false, true, 11, ColumnType.Testo, "patrimonio", "") { FontBold = false, HeaderFontBold = true, DeltaYContent = 1 });
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
tablePDF.Columns.Add(new ColumnPDF("grado", 190, HorizontalAlignmentType.Destra, false, true, 11, ColumnType.Testo, "grado", "Diversificazione") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 10, DeltaYContent = 1 });
|
|
|
|
tablePDF.FooterColumns.Add(new ColumnPDF("immagineFooter", 55, HorizontalAlignmentType.Destra, false, false, 12, ColumnType.Immagine) { ScaleColumnTypeImage = 0.12F, DeltaYContent = 2, PaddingLeft = -10 });
|
|
tablePDF.FooterColumns.Add(new ColumnPDF("patrimonioFooter", 145, HorizontalAlignmentType.Sinistra, false, false, 12, ColumnType.Testo) { FontBold = true });
|
|
tablePDF.FooterColumns.Add(new ColumnPDF("gradoFooter", 190, HorizontalAlignmentType.Destra, false, false, 12, ColumnType.Testo) { FontBold = true, PaddingLeft = 2 });
|
|
tablePDF.FooterCells[0, 0].Value = "Diamond.png";
|
|
|
|
|
|
var titoloGradient = new FormattedTextAreaPDF("Patrimonio complessivo", 530, 300) { AutoIncrementYWritable = false, Y = 130, FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontBold = true };
|
|
var imageGradient = new ImagePDF(550, 0.70F, "patrimonioComplessivoChart.png") { AutoIncrementYWritable = false, Y = 160 };
|
|
|
|
AddElement(titoloRiquadro);
|
|
AddElement(new SpacePDF(10));
|
|
AddElement(titolo2_2);
|
|
AddElement(new SpacePDF(20));
|
|
|
|
AddElement(titoloGradient);
|
|
|
|
|
|
var nota = new FormattedTextAreaPDF(getNota1(), 60, 400) { Y = EnvironmentFacade.RendererFacade.YLowerLimit - 20, FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
|
|
AddElement(nota);
|
|
|
|
|
|
|
|
}
|
|
|
|
private List<Point> SortPointsList(List<Point> points)
|
|
{
|
|
var tmpPoints = points.OrderByDescending(x => x.ID).ToList();
|
|
List<Point> resultList = new List<Point>();
|
|
resultList = tmpPoints;
|
|
|
|
//while (tmpPoints.Any())
|
|
//{
|
|
// Point biggest = null;
|
|
// Point smallest = null;
|
|
// if (tmpPoints.Any())
|
|
// {
|
|
// biggest = tmpPoints.Where(x => x.Value == tmpPoints.Max(y => y.Value)).FirstOrDefault();
|
|
// if (biggest != null)
|
|
// {
|
|
// tmpPoints.Remove(biggest);
|
|
// resultList.Add(biggest);
|
|
// }
|
|
// }
|
|
// if (tmpPoints.Any())
|
|
// {
|
|
// smallest = tmpPoints.Where(x => x.Value == tmpPoints.Min(y => y.Value)).FirstOrDefault();
|
|
// if (smallest != null)
|
|
// {
|
|
// tmpPoints.Remove(smallest);
|
|
// resultList.Add(smallest);
|
|
// }
|
|
// }
|
|
//}
|
|
return resultList;
|
|
}
|
|
public void addFrame(float XupSx, float XupDx, float Yup, float Ydown)
|
|
{
|
|
|
|
var horizontalTopLine = new LinePDF(XupSx, Yup, XupDx, Yup, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false };
|
|
AddElement(horizontalTopLine);
|
|
var horizontalBottomLine = new LinePDF(XupSx, Ydown, XupDx, Ydown, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false };
|
|
AddElement(horizontalBottomLine);
|
|
var verticalLeftLine = new LinePDF(XupSx, Yup, XupSx, Ydown, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false };
|
|
AddElement(verticalLeftLine);
|
|
var verticalRightLine = new LinePDF(XupDx, Yup, XupDx, Ydown, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false };
|
|
AddElement(verticalRightLine);
|
|
}
|
|
|
|
private string getTesto1()
|
|
{
|
|
string testo = "";
|
|
testo = "Di seguito è rappresentato il patrimonio complessivo distinto tra patrimonio finanziario e immobiliare.";
|
|
return testo;
|
|
}
|
|
|
|
private string getTesto2()
|
|
{
|
|
string testo = "";
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
testo = "Di seguito è rappresentata la diversificazione del patrimonio complessivo, di quello finanziario e di quello immobiliare.";
|
|
return testo;
|
|
}
|
|
|
|
private string getTesto2_2()
|
|
{
|
|
string testo = "";
|
|
testo = "La diversificazione del patrimonio complessivo* è calcolata sulla base della diversificazione della componente finanziaria "
|
|
+ "e di quella immobiliare, in base alla relativa rischiosità e al relativo controvalore.<BR>";
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
testo += "Alla diversificazione complessiva contribuisce anche il livello di correlazione complessiva tra le due componenti patrimoniali: "
|
|
+ "in generale, diversificare un portafoglio tra asset non correlati consente di ridurre il livello complessivo di rischio.<BR>";
|
|
testo += "La correlazione fra le due componenti (finanziaria e immobiliare) viene ipotizzata nulla, in ottica prudenziale, "
|
|
+ "qualora risultino storicamente non correlate (correlazione storica negativa fra asset finanziari e immobiliari).<BR><BR>";
|
|
testo += "Inoltre, qualora il nucleo di riferimento sia composto da più soggetti con portafogli finanziari distinti "
|
|
+ "e per i quali il livello di rischio e di diversificazione siano stimati sui singoli portafogli, gli indicatori complessivi (di rischio e diversificazione) "
|
|
+ "vengono determinati come media ponderata per il controvalore dei singoli portafogli.<BR>";
|
|
testo += "Tale approccio prudenziale risulta coerente con le proprietà statistiche della misura di rischio utilizzata (Value at Risk) che implica la possibilità "
|
|
+ "che all'aumentare della diversificazione complessiva dei portafogli analizzati congiuntamente, il rischio complessivo non si riduca di conseguenza.";
|
|
|
|
return testo;
|
|
}
|
|
|
|
private string getNota1()
|
|
{
|
|
string testo = "";
|
|
testo = "* Il patrimonio complessivo considera il patrimonio finanziario e il patrimonio immobiliare.";
|
|
return testo;
|
|
}
|
|
|
|
public virtual string getNota2()
|
|
{
|
|
|
|
string nota = "";
|
|
string token = "";
|
|
decimal CCN_CASA = 0;
|
|
decimal GPELIGOFONDI_CASA = 0;
|
|
decimal GPELIGTITOLI_CASA = 0;
|
|
|
|
if (bFlag == true)
|
|
{
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_MP_S133AreeBisognoPrincProd]", parametriBatch);
|
|
if (dsBatch.Tables[0].Rows.Count == 0)
|
|
CCN_CASA = 0;
|
|
else
|
|
{
|
|
CCN_CASA = Convert.ToDecimal(dsBatch.Tables[0].Rows[5][4]);
|
|
if (CCN_CASA >= 0)
|
|
CCN_CASA = 0;
|
|
}
|
|
|
|
parametriBatch = null;
|
|
parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "ChiaveClientePB",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
|
}
|
|
|
|
};
|
|
|
|
var dsBatchGPEligo = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_AnalisiRischioSintesiSemestrale", parametriBatch);
|
|
if (dsBatchGPEligo.Tables[0].Rows.Count == 0)
|
|
{
|
|
GPELIGOFONDI_CASA = 0;
|
|
GPELIGTITOLI_CASA = 0;
|
|
}
|
|
else
|
|
{
|
|
if (dsBatchGPEligo.Tables[0].Rows.Count == 1)
|
|
{
|
|
if (dsBatchGPEligo.Tables[0].Rows[0][1].ToString() == "L191")
|
|
{
|
|
// FONDI
|
|
GPELIGOFONDI_CASA = Convert.ToDecimal(dsBatchGPEligo.Tables[0].Rows[0][1]);
|
|
}
|
|
else
|
|
{
|
|
// TITOLI
|
|
GPELIGTITOLI_CASA = Convert.ToDecimal(dsBatchGPEligo.Tables[0].Rows[0][1]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GPELIGOFONDI_CASA = Convert.ToDecimal(dsBatchGPEligo.Tables[0].Rows[0][1]);
|
|
GPELIGTITOLI_CASA = Convert.ToDecimal(dsBatchGPEligo.Tables[0].Rows[1][1]);
|
|
}
|
|
|
|
}
|
|
if (CCN_CASA != 0 || GPELIGOFONDI_CASA < 0 || GPELIGTITOLI_CASA < 0)
|
|
{
|
|
nota += token + "Il controvalore esclude il saldo negativo";
|
|
token = " ";
|
|
if (CCN_CASA != 0)
|
|
{
|
|
nota += token + "dei conti correnti ("+ CCN_CASA.ToString("#,##0.00").ToString() + " €)";
|
|
token = ", ";
|
|
}
|
|
if (GPELIGOFONDI_CASA < 0)
|
|
{
|
|
nota += token + "della liquidità sottostante la GP Eligo Fondi (" + GPELIGOFONDI_CASA.ToString("#,##0.00").ToString() + " €)";
|
|
token = ", ";
|
|
}
|
|
if (GPELIGTITOLI_CASA < 0)
|
|
{
|
|
nota += token + "della liquidità sottostante la GP Eligo Titoli (" + GPELIGTITOLI_CASA.ToString("#,##0.00").ToString() + " €)";
|
|
token = ", ";
|
|
}
|
|
nota += ".";
|
|
token = " ";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CCN_CASA = datiSeiUnico.CASA_CCN;
|
|
GPELIGOFONDI_CASA = datiSeiUnico.CASA_GPELIGOFONDI;
|
|
GPELIGTITOLI_CASA = datiSeiUnico.CASA_GPELIGTITOLI;
|
|
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0)
|
|
{
|
|
nota += token + "Il controvalore esclude il saldo negativo";
|
|
token = " ";
|
|
if (CCN_CASA != 0)
|
|
{
|
|
nota += token + datiSeiUnico.FormatDecimal("dei conti correnti ({0} €)", CCN_CASA);
|
|
token = ", ";
|
|
}
|
|
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 = " ";
|
|
}
|
|
}
|
|
|
|
return nota;
|
|
}
|
|
|
|
public virtual string getNota3()
|
|
{
|
|
string nota = "";
|
|
if (bFlag == true)
|
|
{
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_MP_S133AreeBisognoPrincProd]", parametriBatch);
|
|
if (dsBatch.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (Convert.ToDecimal(dsBatch.Tables[0].Rows[6][4]) < 0)
|
|
{
|
|
nota += getNota2().Length > 0 ? "<BR>" : "";
|
|
//nota += datiSeiUnico.FormatDecimal("(*" + (getNota2().Length > 0 ? "*" : "") + ") Il controvalore esclude il saldo negativo dei conti correnti ({0} €).", Convert.ToDecimal(dsBatch.Tables[0].Rows[6][4]));
|
|
nota += string.Format("(*" + (getNota2().Length > 0 ? "*" : "") + ") Il controvalore esclude il saldo negativo dei conti correnti ({0} €).", Convert.ToDecimal(dsBatch.Tables[0].Rows[6][4]).ToString("#,##0.00").ToString());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (datiSeiUnico.TRZ_CCN != 0)
|
|
{
|
|
nota += getNota2().Length > 0 ? "<BR>" : "";
|
|
nota += datiSeiUnico.FormatDecimal("(*" + (getNota2().Length > 0 ? "*" : "") + ") Il controvalore esclude il saldo negativo dei conti correnti ({0} €).", datiSeiUnico.TRZ_CCN);
|
|
|
|
}
|
|
}
|
|
|
|
return nota;
|
|
}
|
|
|
|
public virtual string getNota4()
|
|
{
|
|
string nota = "";
|
|
string token = "";
|
|
|
|
if (bFlag == true)
|
|
|
|
#region Immobiliare Batch
|
|
{
|
|
nota = "";
|
|
token = "";
|
|
|
|
decimal totalePartiteViaggiantiInv = 0;
|
|
decimal totalePartiteViaggiantiDisinv = 0;
|
|
decimal OC_CASA = 0;
|
|
decimal CC_CASA = 0;
|
|
decimal CC_TERZI = 0;
|
|
decimal PNR_CASA = 0;
|
|
decimal PNR_TERZI = 0;
|
|
|
|
DataTable table1 = new DataTable();
|
|
// Partite Viaggianti Disivestimento OK
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT DISTINCT RETE, COD_FISCALE, sum(PARTVIA_DISINV) AS PARTVIA_DISINV FROM C6MartPeriodicoImmobiliare.PATRIMONIO_BF WHERE (PARTVIA_DISINV <> 0.000 AND PARTVIA_DISINV IS NOT NULL) AND COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' GROUP BY RETE, COD_FISCALE", null);
|
|
if (table1.Rows.Count > 0)
|
|
totalePartiteViaggiantiDisinv = (decimal)table1.Rows[0][2];
|
|
|
|
// Partite Viaggianti Investimento OK
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT DISTINCT RETE, COD_FISCALE, sum(IMPORTO) AS IMPORTO FROM C6MartPeriodicoImmobiliare.PARTITE_VIAGGIANTI WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' GROUP BY RETE, COD_FISCALE", null);
|
|
if (table1.Rows.Count > 0)
|
|
totalePartiteViaggiantiInv = (decimal)table1.Rows[0][2];
|
|
|
|
OC_CASA = totalePartiteViaggiantiInv + totalePartiteViaggiantiDisinv;
|
|
|
|
// PNR_CASA
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
};
|
|
|
|
|
|
var dsBatch1 = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_S76AlternativaPatrimonioNonRappresentabileAssettClass]", parametriBatch);
|
|
if (dsBatch1.Tables[0].Rows.Count > 0)
|
|
//PNR_CASA = PNR_CASA + (decimal)dsBatch1.Tables[0].AsEnumerable().Sum(dr => dr.Field<decimal>("Controvalore"));
|
|
PNR_CASA = (decimal)dsBatch1.Tables[0].AsEnumerable().Sum(dr => dr.Field<decimal>("Controvalore"));
|
|
|
|
// CC_CASA
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT SUM(CTV) FROM C6MartPeriodicoImmobiliare.PATRIMONIO_BF WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND REND_NON_RAPPR = 0 AND UPPER(TIPO_PRODOTTO) = 'CC'", null);
|
|
if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
CC_CASA = (decimal)table1.Rows[0][0];
|
|
|
|
// CC_TERZI
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT SUM(CTV) FROM C6MartPeriodicoImmobiliare.PATRIMONIO_TERZI WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND UPPER(TIPO_PRODOTTO) = 'CONTI CORRENTI'", null);
|
|
if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
CC_TERZI = (decimal)table1.Rows[0][0];
|
|
|
|
// PNR_TERZI
|
|
string sSql = "SELECT SUM(p.ctv ) ";
|
|
sSql = sSql + "FROM[C6StagingPeriodicoImmobiliare].[RP_PatrimonioTerzi] p ";
|
|
sSql = sSql + "INNER JOIN[C6StagingPeriodicoImmobiliare].[RP_DettProdottiTerzi] dp ";
|
|
sSql = sSql + "ON p.chiaveprodottoterzi = dp.chiaveprodottoterzi ";
|
|
sSql = sSql + "LEFT JOIN[C6StagingPeriodicoImmobiliare].[RP_Mappatura] m ";
|
|
sSql = sSql + "ON m.chiaveprodotto = dp.chiaveProdotto ";
|
|
sSql = sSql + "WHERE dp.chiaveprodotto IS NOT NULL ";
|
|
sSql = sSql + "AND p.dtfine > getdate() ";
|
|
sSql = sSql + "AND m.chiaveprodotto IS NULL ";
|
|
sSql = sSql + "AND p.chiaveClientePB = " + EnvironmentFacade.ReportEnvironment.Cliente.Chiave;
|
|
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, sSql, null);
|
|
if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
PNR_TERZI = (decimal)table1.Rows[0][0];
|
|
|
|
/***********ATTENZIONE è da togliere per la successiva semestrale di settembre 2021 ********************/
|
|
/*********** Modifica per la semestrale del 04-05-2021, solo per il cliente RGHSRG... per allineare la nota con quella presente nella trimestrale - Pino *****************/
|
|
if ("RGHSRG62P27A944G" == EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale)
|
|
GC_AssetClass = 99.97M;
|
|
/*******************************************************************************************************************/
|
|
|
|
if (GC_AssetClass < 100)
|
|
{
|
|
#region Immobiliare Batch
|
|
|
|
|
|
//nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro asset class pari a {0}", GC);
|
|
nota += token + string.Format("Grado di copertura (%) della rappresentazione grafica per macro asset class pari a {0}", GC_AssetClass.ToString("#,##0.00").ToString());
|
|
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);
|
|
nota += token + string.Format("i prodotti non rappresentabili ({0} €)", PNR_CASA.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
if (CC_CASA != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_CASA);
|
|
nota += token + string.Format("i conti correnti ({0} €)", CC_CASA.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
if (OC_CASA != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("gli importi relativi alle operazioni in corso ({0} €)", OC_CASA);
|
|
nota += token + string.Format("gli importi relativi alle operazioni in corso ({0} €)", OC_CASA.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
token = " ";
|
|
if (EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto == "F")
|
|
nota += token + "del patrimonio Fideuram";
|
|
else
|
|
nota += token + "del patrimonio Sanpaolo Invest";
|
|
token = ", ";
|
|
}
|
|
if (PNR_TERZI != 0 || CC_TERZI != 0)
|
|
{
|
|
if (PNR_TERZI != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("i prodotti non rappresentabili ({0} €)", PNR_TERZI);
|
|
nota += token + string.Format("i prodotti non rappresentabili ({0} €)", PNR_TERZI.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
if (CC_TERZI != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_TERZI);
|
|
nota += token + string.Format("i conti correnti ({0} €)", CC_TERZI.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
token = " ";
|
|
nota += token + "del patrimonio altri Istituti";
|
|
token = ", ";
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
return nota;
|
|
}
|
|
#endregion
|
|
|
|
else
|
|
|
|
#region Immobiliare Online
|
|
{
|
|
var macroAssetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass;
|
|
|
|
if (macroAssetClass != null && macroAssetClass.distribuzione != null)
|
|
{
|
|
//decimal GC = (presenzaContocorrenteInMonterio() ? macroAssetClass.distribuzione.coverageCC : macroAssetClass.distribuzione.coverage) * 100;
|
|
decimal GC = macroAssetClass.distribuzione.coverageCC * 100;
|
|
|
|
decimal OC_CASA = datiSeiUnico.CASA_OC;
|
|
//decimal CC_CASA = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.CASA_CC;
|
|
decimal CC_CASA = datiSeiUnico.CASA_CC;
|
|
|
|
decimal PNR_CASA = 0;
|
|
if (datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass != null && datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzione != null)
|
|
PNR_CASA = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr;
|
|
|
|
//decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
|
|
decimal CC_TERZI = datiSeiUnico.TRZ_CC;
|
|
|
|
decimal PNR_TERZI = 0;
|
|
if (datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroAssetClass != null && datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroAssetClass.distribuzione != null)
|
|
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 = " ";
|
|
if (EnvironmentFacade.ReportEnvironment.PrivateBanker.CodiceRete == "F")
|
|
nota += token + "del patrimonio Fideuram";
|
|
else
|
|
nota += token + "del patrimonio Sanpaolo Invest";
|
|
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);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Funzione getNota4 originale - presa da Master. Viene rinominata getNota4_Master perchè viene sostituita dalla funzione precedente relatova al brach della semestrale
|
|
/// di settembre 2019.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public virtual string getNota4_Master()
|
|
{
|
|
//string nota = "";
|
|
//if (bFlag == false)
|
|
//{
|
|
// if (datiSeiUnico.FNZ_OC != 0)
|
|
// {
|
|
// nota = datiSeiUnico.FormatDecimal("Grado di copertura pari a xx,xx%: non sono considerati i prodotti non rappresentabili ({0} €).", datiSeiUnico.FNZ_OC);
|
|
// //“(*) Grado di copertura pari a xx,xx%: non sono considerati [i prodotti non rappresentabili (x.xxx,xx €)][,] [gli importi relativi alle operazioni in corso (x.xxx,xx €)].”
|
|
// }
|
|
//}
|
|
//return nota;
|
|
|
|
string nota = "";
|
|
string token = "";
|
|
|
|
if (bFlag == true)
|
|
|
|
#region Immobiliare Batch
|
|
{
|
|
nota = "";
|
|
token = "";
|
|
|
|
//decimal totalNegativeCurrentAccountValue = 0;
|
|
//decimal totalSelfNegCurrentAccountValue = 0;
|
|
//decimal totalePartiteViaggiantiInv = 0;
|
|
//decimal totalePartiteViaggiantiDisinv = 0;
|
|
//decimal totalePartiteViaggianti = 0;
|
|
|
|
//var parametriBatch = new List<Parametro>
|
|
//{
|
|
// new Parametro
|
|
// {
|
|
// Direction = ParameterDirection.Input,
|
|
// DbType = DbType.String,
|
|
// ParameterName = "Rete",
|
|
// Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
// },
|
|
// new Parametro
|
|
// {
|
|
// Direction = ParameterDirection.Input,
|
|
// DbType = DbType.String,
|
|
// ParameterName = "CodiceFiscale",
|
|
// Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
// }
|
|
|
|
//};
|
|
|
|
//var dsBatch1 = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_GetClientNegativeCurrentAccountsValue]", parametriBatch);
|
|
//if (dsBatch1.Tables[0].Rows.Count == 0)
|
|
// totalNegativeCurrentAccountValue = 0;
|
|
//else
|
|
//{
|
|
// totalNegativeCurrentAccountValue = Convert.ToDecimal(dsBatch1.Tables[0].Rows[0][0]);
|
|
// if (totalNegativeCurrentAccountValue >= 0)
|
|
// totalNegativeCurrentAccountValue = 0;
|
|
//}
|
|
|
|
|
|
//parametriBatch = new List<Parametro>
|
|
//{
|
|
// new Parametro
|
|
// {
|
|
// Direction = ParameterDirection.Input,
|
|
// DbType = DbType.String,
|
|
// ParameterName = "Rete",
|
|
// Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
// },
|
|
// new Parametro
|
|
// {
|
|
// Direction = ParameterDirection.Input,
|
|
// DbType = DbType.String,
|
|
// ParameterName = "CodiceFiscale",
|
|
// Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
// }
|
|
|
|
//};
|
|
|
|
//var dsBatch2 = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_GetClientSelfNegCurrentAccountValue]", parametriBatch);
|
|
//if (dsBatch2.Tables[0].Rows.Count == 0)
|
|
// totalNegativeCurrentAccountValue = 0;
|
|
//else
|
|
//{
|
|
// totalSelfNegCurrentAccountValue = Convert.ToDecimal(dsBatch2.Tables[0].Rows[0][0]);
|
|
// if (totalSelfNegCurrentAccountValue >= 0)
|
|
// totalSelfNegCurrentAccountValue = 0;
|
|
//}
|
|
|
|
|
|
|
|
//DataTable table1 = new DataTable();
|
|
//// Partite Viaggianti Disivestimento
|
|
//table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT DISTINCT RETE, COD_FISCALE, PARTVIA_DISINV FROM C6MartPeriodicoImmobiliare.PATRIMONIO_BF WHERE (PARTVIA_DISINV <> 0.000 AND PARTVIA_DISINV IS NOT NULL) AND COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "'", null);
|
|
//if (table1.Rows.Count > 0)
|
|
// totalePartiteViaggiantiDisinv = (decimal)table1.Rows[0][2];
|
|
|
|
//// Partite Viaggianti Investimento
|
|
//table1 = new DataTable();
|
|
//table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT DISTINCT RETE, COD_FISCALE, IMPORTO FROM C6MartPeriodicoImmobiliare.PARTITE_VIAGGIANTI WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "'", null);
|
|
//if (table1.Rows.Count > 0)
|
|
// totalePartiteViaggiantiInv = (decimal)table1.Rows[0][2];
|
|
|
|
//totalePartiteViaggianti = totalePartiteViaggiantiInv + totalePartiteViaggiantiDisinv;
|
|
|
|
//if (totalNegativeCurrentAccountValue == 0 && totalSelfNegCurrentAccountValue == 0 && totalePartiteViaggianti != 0)
|
|
//{
|
|
// nota += "Il controvalore esclude gli investimenti in corso";
|
|
//}
|
|
//if (totalNegativeCurrentAccountValue < 0 && totalSelfNegCurrentAccountValue == 0 && totalePartiteViaggianti == 0)
|
|
//{
|
|
// nota += "Il controvalore esclude il saldo negativo del conto corrente ({0} €)";
|
|
// nota = string.Format(nota, totalNegativeCurrentAccountValue.ToString("N"));
|
|
//}
|
|
//if (totalNegativeCurrentAccountValue == 0 && totalSelfNegCurrentAccountValue < 0 && totalePartiteViaggianti == 0)
|
|
//{
|
|
// nota += "Il controvalore esclude il saldo negativo della liquidità sottostante le linee “GP Eligo” ({0} €)";
|
|
// nota = string.Format(nota, totalSelfNegCurrentAccountValue.ToString("N"));
|
|
//}
|
|
//if (totalNegativeCurrentAccountValue < 0 && totalSelfNegCurrentAccountValue == 0 && totalePartiteViaggianti != 0)
|
|
//{
|
|
// nota += "Il controvalore esclude il saldo negativo del conto corrente ({0} €) e gli investimenti in corso";
|
|
// nota = string.Format(nota, totalNegativeCurrentAccountValue.ToString("N"));
|
|
//}
|
|
//if (totalNegativeCurrentAccountValue < 0 && totalSelfNegCurrentAccountValue < 0 && totalePartiteViaggianti == 0)
|
|
//{
|
|
// nota += "Il controvalore esclude il saldo negativo del conto corrente ({0} €) e il saldo negativo della liquidità sottostante le linee “GP Eligo” ({1} €)";
|
|
// nota = string.Format(nota, totalNegativeCurrentAccountValue.ToString("N"), totalSelfNegCurrentAccountValue.ToString("N"));
|
|
//}
|
|
//if (totalNegativeCurrentAccountValue == 0 && totalSelfNegCurrentAccountValue < 0 && totalePartiteViaggianti != 0)
|
|
//{
|
|
// nota += "Il controvalore esclude il saldo negativo della liquidità sottostante le linee “GP Eligo” ({0} €) e gli investimenti in corso";
|
|
// nota = string.Format(nota, totalSelfNegCurrentAccountValue.ToString("N"));
|
|
//}
|
|
//if (totalNegativeCurrentAccountValue < 0 && totalSelfNegCurrentAccountValue < 0 && totalePartiteViaggianti != 0)
|
|
//{
|
|
// nota += "Il controvalore esclude il saldo negativo del conto corrente ({0} €), il saldo negativo della liquidità sottostante le linee “GP Eligo” ({1} €) e gli investimenti in corso";
|
|
// nota = string.Format(nota, totalNegativeCurrentAccountValue.ToString("N"), totalSelfNegCurrentAccountValue.ToString("N"));
|
|
//}
|
|
|
|
decimal totalePartiteViaggiantiInv = 0;
|
|
decimal totalePartiteViaggiantiDisinv = 0;
|
|
decimal OC_CASA = 0;
|
|
decimal GC = 0;
|
|
decimal CC_CASA = 0;
|
|
decimal CC_TERZI = 0;
|
|
decimal PNR_CASA = 0;
|
|
decimal PNR_TERZI = 0;
|
|
|
|
DataTable table1 = new DataTable();
|
|
// Partite Viaggianti Disivestimento
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT DISTINCT RETE, COD_FISCALE, PARTVIA_DISINV FROM C6MartPeriodicoImmobiliare.PATRIMONIO_BF WHERE (PARTVIA_DISINV <> 0.000 AND PARTVIA_DISINV IS NOT NULL) AND COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "'", null);
|
|
if (table1.Rows.Count > 0)
|
|
totalePartiteViaggiantiDisinv = (decimal)table1.Rows[0][2];
|
|
|
|
// Partite Viaggianti Investimento
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT DISTINCT RETE, COD_FISCALE, IMPORTO FROM C6MartPeriodicoImmobiliare.PARTITE_VIAGGIANTI WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "'", null);
|
|
if (table1.Rows.Count > 0)
|
|
totalePartiteViaggiantiInv = (decimal)table1.Rows[0][2];
|
|
|
|
OC_CASA = totalePartiteViaggiantiInv + totalePartiteViaggiantiDisinv;
|
|
|
|
// PNR_CASA
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT SUM(CTV) FROM C6MartPeriodicoImmobiliare.PATRIMONIO_BF WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND REND_NON_RAPPR =1", null);
|
|
if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
PNR_CASA = (decimal)table1.Rows[0][0];
|
|
|
|
// CC_CASA
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT SUM(CTV) FROM C6MartPeriodicoImmobiliare.PATRIMONIO_BF WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND REND_NON_RAPPR =0", null);
|
|
if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
CC_CASA = (decimal)table1.Rows[0][0];
|
|
|
|
// CC_TERZI
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT SUM(CTV) FROM C6MartPeriodicoImmobiliare.PATRIMONIO_TERZI WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND UPPER(TIPO_PRODOTTO) = 'CONTI CORRENTI'", null);
|
|
if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
CC_TERZI = (decimal)table1.Rows[0][0];
|
|
|
|
// PNR_TERZI
|
|
|
|
//table1 = new DataTable();
|
|
//table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT SUM(CTV) FROM C6MartPeriodicoImmobiliare.PATRIMONIO_TERZI WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND UPPER(TIPO_PRODOTTO) = 'CONTI CORRENTI'", null);
|
|
//if (table1.Rows.Count > 0 && table1.Rows[0][0].ToString() != "")
|
|
// PNR_TERZI = (decimal)table1.Rows[0][0];
|
|
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
var dsBatch1 = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_MP_S140AnalisiRisparmioCharts]", parametriBatch);
|
|
if (dsBatch1.Tables[0].Rows.Count == 0)
|
|
PNR_TERZI = 0;
|
|
else
|
|
{
|
|
if (dsBatch1.Tables[0].AsEnumerable().Where(x => x.Field<string>("intermediario") == "Complessivo").Count() > 0)
|
|
{
|
|
DataTable copyDataTable = dsBatch1.Tables[0].AsEnumerable().Where(x => x.Field<string>("intermediario") == "Complessivo").CopyToDataTable();
|
|
PNR_TERZI = Convert.ToDecimal(copyDataTable.Rows[0][5]);
|
|
}
|
|
}
|
|
|
|
|
|
// GC
|
|
table1 = new DataTable();
|
|
table1 = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerStampeC6, "SELECT COPERTURA FROM C6MartPeriodicoImmobiliare.RISCHIO_AGGREGATO WHERE COD_FISCALE = '" + EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale + "' AND RETE = '" + EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto + "' AND UPPER(COD_AGGREG) = 'COMPLESSIVO|BF'", null);
|
|
if (table1.Rows.Count > 0)
|
|
GC = (decimal)table1.Rows[0][0];
|
|
//GC = (decimal)99;
|
|
if (EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale.ToString() == "ZNLGRG62C21A291U")
|
|
GC = (decimal)90.37;
|
|
if (EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale.ToString() == "BRBLGU62L11F205E")
|
|
GC = (decimal)94.02;
|
|
|
|
if (GC < 100)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro asset class pari a {0}", GC);
|
|
nota += token + string.Format("Grado di copertura (%) della rappresentazione grafica per macro asset class pari a {0}", GC.ToString("#,##0.00").ToString());
|
|
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);
|
|
nota += token + string.Format("i prodotti non rappresentabili ({0} €)", PNR_CASA.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
//if (CC_CASA != 0)
|
|
//{
|
|
// //nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_CASA);
|
|
// nota += token + string.Format("i conti correnti ({0} €)", CC_CASA.ToString("#,##0.00").ToString());
|
|
// token = ", ";
|
|
//}
|
|
if (OC_CASA != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("gli importi relativi alle operazioni in corso ({0} €)", OC_CASA);
|
|
nota += token + string.Format("gli importi relativi alle operazioni in corso ({0} €)", OC_CASA.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
token = " ";
|
|
if (EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto == "F")
|
|
nota += token + "del patrimonio Fideuram";
|
|
else
|
|
nota += token + "del patrimonio Sanpaolo Invest";
|
|
token = ", ";
|
|
}
|
|
if (PNR_TERZI != 0 || CC_TERZI != 0)
|
|
{
|
|
if (PNR_TERZI != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("i prodotti non rappresentabili ({0} €)", PNR_TERZI);
|
|
nota += token + string.Format("i prodotti non rappresentabili ({0} €)", PNR_TERZI.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
if (CC_TERZI != 0)
|
|
{
|
|
//nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_TERZI);
|
|
nota += token + string.Format("i conti correnti ({0} €)", CC_TERZI.ToString("#,##0.00").ToString());
|
|
token = ", ";
|
|
}
|
|
token = " ";
|
|
nota += token + "del patrimonio altri Istituti";
|
|
token = ", ";
|
|
}
|
|
}
|
|
}
|
|
|
|
return nota;
|
|
}
|
|
#endregion
|
|
|
|
else
|
|
|
|
#region Immobiliare Online
|
|
{
|
|
var macroAssetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass;
|
|
|
|
if (macroAssetClass != null && macroAssetClass.distribuzione != null)
|
|
{
|
|
//decimal GC = (presenzaContocorrenteInMonterio() ? macroAssetClass.distribuzione.coverageCC : macroAssetClass.distribuzione.coverage) * 100;
|
|
decimal GC = macroAssetClass.distribuzione.coverageCC * 100;
|
|
|
|
decimal OC_CASA = datiSeiUnico.CASA_OC;
|
|
//decimal CC_CASA = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.CASA_CC;
|
|
decimal CC_CASA = datiSeiUnico.CASA_CC;
|
|
|
|
decimal PNR_CASA = 0;
|
|
if (datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass != null && datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzione != null)
|
|
PNR_CASA = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass.distribuzione.totaleNonRappr;
|
|
|
|
//decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
|
|
decimal CC_TERZI = datiSeiUnico.TRZ_CC;
|
|
|
|
decimal PNR_TERZI = 0;
|
|
if (datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroAssetClass != null && datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroAssetClass.distribuzione != null)
|
|
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 = " ";
|
|
if (EnvironmentFacade.ReportEnvironment.PrivateBanker.CodiceRete == "F")
|
|
nota += token + "del patrimonio Fideuram";
|
|
else
|
|
nota += token + "del patrimonio Sanpaolo Invest";
|
|
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 = ", ";
|
|
}
|
|
}
|
|
|
|
//if (GC < 100)
|
|
//{
|
|
// nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro 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);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
private void DrawDiamondBar(int x, int y, int width, int height, string val)
|
|
{
|
|
var border = new RectanglePDF(height + 40, width + 120, new ColorPDF(0, 0, 0))
|
|
{
|
|
Height = height + 75,
|
|
Width = width + 130,
|
|
X = x - 90,
|
|
Y = y - 55,
|
|
BorderColor = new ColorPDF(196, 196, 186),
|
|
BorderStyle = LineStylePDF.Solid,
|
|
BorderWidth = 0.75f,
|
|
Color = new ColorPDF(255,255,255),
|
|
AutoIncrementYWritable = false
|
|
};
|
|
AddElement(border);
|
|
|
|
double value = double.Parse(val.Replace("%", "")) / 100;
|
|
|
|
var textMax = new FormattedTextAreaPDF("Max:100", x + width / 2, width / 2)
|
|
{
|
|
FontColor = new ColorPDF(91, 88, 79),
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
FontSize = 10,
|
|
FontBold = true,
|
|
Y = y - 14,
|
|
AutoIncrementYWritable = false,
|
|
};
|
|
AddElement(textMax);
|
|
AddElement(new LinePDF(x, x + width, 0.5f, new ColorPDF(System.Drawing.Color.Black))
|
|
{
|
|
Color = new ColorPDF(91, 88, 79),
|
|
Y1 = y - 1,
|
|
Y2 = y - 1,
|
|
AutoIncrementYWritable = false
|
|
});
|
|
AddElement(new ImagePDF(x, 1, "gradientbar.png")
|
|
{
|
|
Y = y,
|
|
Width = width / 2,
|
|
Height = height,
|
|
AutoIncrementYWritable = false
|
|
});
|
|
AddElement(new LinePDF(x, x + width, 0.5f, new ColorPDF(System.Drawing.Color.Black))
|
|
{
|
|
Color = new ColorPDF(91, 88, 79),
|
|
Y1 = y + height,
|
|
Y2 = y + height,
|
|
AutoIncrementYWritable = false
|
|
});
|
|
var textMin = new FormattedTextAreaPDF("Min:0 ", x + width / 2, width / 2)
|
|
{
|
|
FontColor = new ColorPDF(91, 88, 79),
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
FontSize = 10,
|
|
FontBold = true,
|
|
Y = y + height - 13,
|
|
AutoIncrementYWritable = false
|
|
};
|
|
AddElement(textMin);
|
|
var triangleImg = new ImagePDF(x - 26, 0.2f, "triangle_big.png")
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + height * (100 - (float)value * 100) / 100 - 8
|
|
};
|
|
AddElement(triangleImg);
|
|
|
|
|
|
var valueElement = new FormattedTextAreaPDF();
|
|
|
|
if (value == 0)
|
|
valueElement = new FormattedTextAreaPDF("n.c.", x - 80, 50)
|
|
{
|
|
FontColor = new ColorPDF(91, 88, 79),
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
FontSize = 10,
|
|
FontBold = true,
|
|
Y = y + height * (100 - (float)value*100) / 100 - 6,
|
|
AutoIncrementYWritable = false
|
|
};
|
|
else
|
|
valueElement = new FormattedTextAreaPDF(Convert.ToDecimal(value * 100).ToString("#,##0.00").ToString(), x - 80, 50)
|
|
{
|
|
FontColor = new ColorPDF(91, 88, 79),
|
|
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
|
|
FontSize = 10,
|
|
FontBold = true,
|
|
Y = y + height * (100 - (float)value * 100) / 100 - 6,
|
|
AutoIncrementYWritable = false
|
|
};
|
|
|
|
AddElement(valueElement);
|
|
|
|
|
|
// COMMENTATO PER INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
//var imagePdf = new ImagePDF(x - 52, 0.2f, "Diamond.png")
|
|
//{
|
|
// Y = y + height * (100 - (float)value * 100) / 100 - 30,
|
|
// AutoIncrementYWritable = false
|
|
//};
|
|
var imagePdf = new ImagePDF(x - 56, 0.2f, "Diamond.png")
|
|
{
|
|
Y = y + height * (100 - (float)value*100) / 100 - 30,
|
|
AutoIncrementYWritable = false
|
|
};
|
|
AddElement(imagePdf);
|
|
}
|
|
|
|
|
|
private void DrawCustomTable(int x, int y, int height, int width, string val1, string val2, string val3)
|
|
{
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
val1 = val1.Replace("%", "");
|
|
val2 = val2.Replace("%", "");
|
|
val3 = val3.Replace("%", "");
|
|
|
|
var border = new RectanglePDF(height, width, new ColorPDF(0, 0, 0))
|
|
{
|
|
Y = y,
|
|
X = x,
|
|
BorderColor = new ColorPDF(196, 196, 186),
|
|
BorderStyle = LineStylePDF.Solid,
|
|
BorderWidth = 0.75f,
|
|
Color = new ColorPDF(255, 255, 255),
|
|
AutoIncrementYWritable = false
|
|
};
|
|
AddElement(border);
|
|
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
var row0col1 = new FormattedTextAreaPDF("Diversificazione", x + 240, 150)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 10,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Right
|
|
};
|
|
|
|
var lineTitle = new LinePDF(x + 290, x + 390, 0.75f, new ColorPDF(196, 196, 186))
|
|
{
|
|
Y1 = y + 25,
|
|
Y2 = y + 25
|
|
};
|
|
AddElement(lineTitle);
|
|
AddElement(new ImagePDF(x + 20, 0.13f, "StimaValore.png")
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 32
|
|
});
|
|
var row1col0 = new FormattedTextAreaPDF("Patrimonio finanziario", x + 40, 150)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 35,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Left
|
|
};
|
|
var row1col1 = new FormattedTextAreaPDF(val1, x + 340, 50)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 35,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Right
|
|
};
|
|
|
|
AddElement(new ImagePDF(x + 20, 0.13f, "Fabbricati.png")
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 52
|
|
});
|
|
var row2col0 = new FormattedTextAreaPDF("Patrimonio immobiliare", x + 40, 150)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 55,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Left
|
|
};
|
|
var row2col1 = new FormattedTextAreaPDF(val2, x + 340, 50)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 55,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Right
|
|
};
|
|
|
|
var longLine = new LinePDF(x + 10, x + 390, 0.75f, new ColorPDF(196, 196, 186))
|
|
{
|
|
Y1 = y + 74,
|
|
Y2 = y + 74
|
|
};
|
|
AddElement(longLine);
|
|
|
|
AddElement(new ImagePDF(x + 20, 0.13f, "Diamond.png")
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 80
|
|
});
|
|
|
|
var row3col0 = new FormattedTextAreaPDF("Patrimonio complessivo", x + 40, 200)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 80,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Left
|
|
};
|
|
var row3col1 = new FormattedTextAreaPDF(val3, x + 340, 50)
|
|
{
|
|
AutoIncrementYWritable = false,
|
|
Y = y + 80,
|
|
FontSize = 10,
|
|
FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard,
|
|
FontBold = true,
|
|
TextHorizontalAlign = TextAlign.Right
|
|
};
|
|
|
|
AddElement(row0col1);
|
|
AddElement(row1col0);
|
|
AddElement(row1col1);
|
|
AddElement(row2col0);
|
|
AddElement(row2col1);
|
|
AddElement(row3col0);
|
|
AddElement(row3col1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataTable.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected override DataTable GetDataTable()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected DataSet GetDataSet2()
|
|
{
|
|
var parametri = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.Int64,
|
|
ParameterName = "ChiaveClientePB",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
|
}
|
|
};
|
|
|
|
var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_AnalisiRischioDiversificazione", parametri);
|
|
if (dsOriginal.Tables[0].Rows.Count == 0)
|
|
return null;
|
|
|
|
DataTable data = new DataTable();
|
|
data.Columns.Add("immagine", typeof(string));
|
|
data.Columns.Add("patrimonio", typeof(string));
|
|
data.Columns.Add("grado", typeof(string));
|
|
|
|
DataTable dataFooter = new DataTable();
|
|
dataFooter.Columns.Add("immagineFooter", typeof(string));
|
|
dataFooter.Columns.Add("patrimonioFooter", typeof(string));
|
|
dataFooter.Columns.Add("gradoFooter", typeof(string));
|
|
|
|
//data.Rows.Add("StimaValore.png", "Patrimonio finanziario", Helper.FormatPercentage(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoFinanziario"]) * 100, 0));
|
|
//data.Rows.Add("Fabbricati.png", "Patrimonio immobiliare", Helper.FormatPercentage(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoImmobiliare"]) * 100, 0));
|
|
//dataFooter.Rows.Add("Diamond.png", "Patrimonio complessivo", Helper.FormatPercentage(Math.Abs(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoComplessivo"]) * 100), 0));
|
|
|
|
// Modificata per Batch Immobiliare il 26.03.2018
|
|
//data.Rows.Add("StimaValore.png", "Patrimonio finanziario", Helper.FormatPercentage(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoFinanziario"]), 0));
|
|
//data.Rows.Add("Fabbricati.png", "Patrimonio immobiliare", Helper.FormatPercentage(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoImmobiliare"]) * 100, 0));
|
|
//dataFooter.Rows.Add("Diamond.png", "Patrimonio complessivo", Helper.FormatPercentage(Math.Abs(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoComplessivo"])), 0));
|
|
|
|
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
|
|
data.Rows.Add("StimaValore.png", "Patrimonio finanziario", Helper.FormatDecimal((Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoFinanziario"]) * 100).ToString(), 2));
|
|
data.Rows.Add("Fabbricati.png", "Patrimonio immobiliare", Helper.FormatDecimal((Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoImmobiliare"]) * 100).ToString(), 2));
|
|
dataFooter.Rows.Add("Diamond.png", "Patrimonio complessivo", Helper.FormatDecimal((Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoComplessivo"]) * 100).ToString(), 2));
|
|
|
|
|
|
|
|
//var _GradoFinanziario = datiSeiUnico.rischioUnit().rischio.rischioMercatoCredito.bancaFideuram.stat.diversificazione;
|
|
//var _GradoComplessivo = datiSeiUnico.rischioUnit().rischio.rischioMercatoCredito.totale.stat.diversificazione;
|
|
|
|
//data.Rows.Add("StimaValore.png", "Patrimonio finanziario", Helper.FormatPercentage(Convert.ToDecimal(_GradoFinanziario), 0));
|
|
//data.Rows.Add("Fabbricati.png", "Patrimonio immobiliare", Helper.FormatPercentage(Convert.ToDecimal(dsOriginal.Tables[0].Rows[0]["GradoImmobiliare"]) * 100, 0));
|
|
//dataFooter.Rows.Add("Diamond.png", "Patrimonio complessivo", Helper.FormatPercentage(Math.Abs(Convert.ToDecimal(_GradoComplessivo)), 0));
|
|
|
|
DataSet set = new DataSet();
|
|
set.Tables.Add(data);
|
|
set.Tables.Add(dataFooter);
|
|
|
|
return set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataSet.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected override DataSet GetDataSet()
|
|
{
|
|
|
|
|
|
decimal finanziarioFideuram = 0;
|
|
decimal finanziarioTerzi = 0;
|
|
decimal immobiliare = 0;
|
|
decimal totale = 0;
|
|
decimal pesoFideuram = 0;
|
|
decimal pesoTerzi = 0;
|
|
decimal pesoImmobiliare = 0;
|
|
decimal totaleFinanziario = 0;
|
|
|
|
if (bFlag == true)
|
|
{
|
|
#region Immobiliare Batch
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_D_S152Patrimonio]", parametriBatch);
|
|
if (dsBatch.Tables[0].Rows.Count == 0)
|
|
return null;
|
|
|
|
// Lettura Dati da Procedura Batch
|
|
finanziarioFideuram = Convert.ToDecimal(dsBatch.Tables[0].Rows[0][0]);
|
|
finanziarioTerzi = Convert.ToDecimal(dsBatch.Tables[0].Rows[0][1]);
|
|
immobiliare = Convert.ToDecimal(dsBatch.Tables[0].Rows[0][4]);
|
|
totale = finanziarioFideuram + finanziarioTerzi + immobiliare;
|
|
pesoFideuram = finanziarioFideuram * 100 / totale;
|
|
pesoTerzi = finanziarioTerzi * 100 / totale;
|
|
pesoImmobiliare = immobiliare * 100 / totale;
|
|
totaleFinanziario = 0;
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region Immobiliare Online
|
|
// Lettura Dati Normale
|
|
var datiSei = datiSeiUnico;
|
|
finanziarioFideuram = datiSeiUnico.CASA_TOTALEPOSITIVO;
|
|
finanziarioTerzi = datiSeiUnico.TRZ_TOTALE;
|
|
immobiliare = datiSeiUnico.IMB_TOTALE;
|
|
totale = finanziarioFideuram + finanziarioTerzi + immobiliare;
|
|
pesoFideuram = finanziarioFideuram * 100 / totale;
|
|
pesoTerzi = finanziarioTerzi * 100 / totale;
|
|
pesoImmobiliare = immobiliare * 100 / totale;
|
|
totaleFinanziario = 0;
|
|
#endregion
|
|
}
|
|
|
|
|
|
var parametri = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.Int64,
|
|
ParameterName = "ChiaveClientePB",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
|
}
|
|
};
|
|
|
|
var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_AnalisiRischioSintesi", parametri);
|
|
if (dsOriginal.Tables[0].Rows.Count == 0)
|
|
return null;
|
|
|
|
DataSet ds = new DataSet();
|
|
ds.Tables.Add(new DataTable("patrimonio"));
|
|
ds.Tables.Add(new DataTable("patrimonioFooter"));
|
|
ds.Tables.Add(new DataTable("composizionePatrimonio"));
|
|
ds.Tables.Add(new DataTable("composizionePatrimonioFooter"));
|
|
ds.Tables.Add(new DataTable("torta"));
|
|
|
|
//ds.Tables["patrimonio"].Columns.Add(new DataColumn("space", typeof(string)));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
|
|
ds.Tables["patrimonioFooter"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
|
|
ds.Tables["patrimonioFooter"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["patrimonioFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Composizione", typeof(string)));
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Composizione", typeof(string)));
|
|
ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
|
|
ds.Tables["torta"].Columns.Add(new DataColumn("indice", typeof(string)));
|
|
ds.Tables["torta"].Columns.Add(new DataColumn("tipologia", typeof(string)));
|
|
ds.Tables["torta"].Columns.Add(new DataColumn("peso", typeof(decimal)));
|
|
ds.Tables["torta"].Columns.Add(new DataColumn("ordine", typeof(int)));
|
|
|
|
// Check se Totale > di 100
|
|
decimal nTotalePercento = Convert.ToDecimal(Helper.FormatDecimal(pesoTerzi.ToString(), 1)) + Convert.ToDecimal(Helper.FormatDecimal(pesoFideuram.ToString(), 1)) + Convert.ToDecimal(Helper.FormatDecimal(pesoImmobiliare.ToString(), 1));
|
|
|
|
if (nTotalePercento > 100)
|
|
{
|
|
if (pesoFideuram != 0)
|
|
pesoFideuram = pesoFideuram - Convert.ToDecimal(0.1);
|
|
else
|
|
pesoTerzi = pesoTerzi - Convert.ToDecimal(0.1);
|
|
}
|
|
if (nTotalePercento < 100)
|
|
{
|
|
if (pesoFideuram != 0)
|
|
pesoFideuram = pesoFideuram + Convert.ToDecimal(0.1);
|
|
else
|
|
pesoTerzi = pesoTerzi + Convert.ToDecimal(0.1);
|
|
}
|
|
// Fine Check
|
|
|
|
/************************* Fix per valore a 2 cifre decimali sul peso 17 / 07 / 2020 - Pino *********************************/
|
|
// TOTALI PATRIMONIO
|
|
if (finanziarioFideuram != 0)
|
|
ds.Tables["patrimonio"].Rows.Add("<B>Patrimonio finanziario Fideuram" + (getNota2().Length > 0 ? "*" : "") + "</B>", "<B>" + Helper.FormatCurrency(finanziarioFideuram.ToString()) + "</B>", "<B>" + Helper.FormatPercentage(pesoFideuram, 2) + "</B>");
|
|
if (finanziarioTerzi != 0)
|
|
ds.Tables["patrimonio"].Rows.Add("<B>Patrimonio finanziario altri Istituti" + (getNota3().Length <= 0 ? "" : (getNota2().Length > 0 ? "**" : "*")) + "</B>", "<B>" + Helper.FormatCurrency(finanziarioTerzi.ToString()) + "</B>", "<B>" + Helper.FormatPercentage(pesoTerzi, 2) + "</B>");
|
|
if (immobiliare != 0)
|
|
ds.Tables["patrimonio"].Rows.Add("<B>Patrimonio immobiliare</B>", "<B>" + Helper.FormatCurrency(immobiliare.ToString()) + "</B>", "<B>" + Helper.FormatPercentage(pesoImmobiliare, 2) + "</B>");
|
|
|
|
|
|
//// TOTALI PATRIMONIO
|
|
//if (finanziarioFideuram != 0)
|
|
// ds.Tables["patrimonio"].Rows.Add("<B>Patrimonio finanziario Fideuram" + (getNota2().Length > 0 ? "*" : "") + "</B>", "<B>" + Helper.FormatCurrency(finanziarioFideuram.ToString()) + "</B>", "<B>" + Helper.FormatPercentage(pesoFideuram, 1) + "</B>");
|
|
//if (finanziarioTerzi != 0)
|
|
// ds.Tables["patrimonio"].Rows.Add("<B>Patrimonio finanziario altri Istituti" + (getNota3().Length <= 0 ? "" : (getNota2().Length > 0 ? "**" : "*")) + "</B>", "<B>" + Helper.FormatCurrency(finanziarioTerzi.ToString()) + "</B>", "<B>" + Helper.FormatPercentage(pesoTerzi, 1) + "</B>");
|
|
//if (immobiliare != 0)
|
|
// ds.Tables["patrimonio"].Rows.Add("<B>Patrimonio immobiliare</B>", "<B>" + Helper.FormatCurrency(immobiliare.ToString()) + "</B>", "<B>" + Helper.FormatPercentage(pesoImmobiliare, 1) + "</B>");
|
|
/*****************************************************************************************************************************/
|
|
|
|
|
|
if (pesoFideuram != 0)
|
|
ds.Tables["torta"].Rows.Add("PF", "<B>Patrimonio finanziario Fideuram</B>", pesoFideuram, 5);
|
|
if (pesoTerzi != 0)
|
|
ds.Tables["torta"].Rows.Add("PT", "<B>Patrimonio finanziario altri Istituti</B>", pesoTerzi, 6);
|
|
|
|
// CALCOLO PER COMPOSIZIONE PATRIMONIO IMMOBILIARE
|
|
decimal nTotaleImmobiliare = 0;
|
|
for (int k = 0; k < dsOriginal.Tables[1].Rows.Count; k++)
|
|
{
|
|
var nPercentuale = Convert.ToDecimal(dsOriginal.Tables[1].Rows[k]["totale"].ToString()) * 100 / totale;
|
|
nTotaleImmobiliare = nTotaleImmobiliare + Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(nPercentuale).ToString(), 1));
|
|
}
|
|
|
|
bool bMax = false;
|
|
bool bMin = false;
|
|
|
|
if (nTotaleImmobiliare > Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(pesoImmobiliare).ToString(), 1)))
|
|
bMax = true;
|
|
else
|
|
{
|
|
if (nTotaleImmobiliare < Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(pesoImmobiliare).ToString(), 1)))
|
|
bMin = true;
|
|
}
|
|
|
|
// DIVISIONE PATRIMONIO IMMOBILIARE
|
|
|
|
//decimal totalePatrimonioImmobiliare = 0;
|
|
|
|
for (int k = 0; k < dsOriginal.Tables[1].Rows.Count; k++)
|
|
{
|
|
var percentuale = Convert.ToDecimal(dsOriginal.Tables[1].Rows[k]["totale"]) * 100 / totale;
|
|
|
|
/********************* Fix per allineare il peso % di ogni singolo immobile con il Peso % totale degli immobili 26/09/2020 - Pino **********************/
|
|
//if (bMax == true)
|
|
//{
|
|
// percentuale = percentuale - Convert.ToDecimal(0.1);
|
|
// //percentuale = Math.Round(percentuale);
|
|
// bMax = false;
|
|
//}
|
|
//else
|
|
//{
|
|
// if (bMin == true)
|
|
// {
|
|
// percentuale = percentuale + Convert.ToDecimal(0.1);
|
|
// //percentuale = Math.Round(percentuale);
|
|
// bMin = false;
|
|
// }
|
|
//}
|
|
/***********************************************************************************************************************************************
|
|
|
|
/****************************** Fix per valore a 2 cifre decimali sul peso 17/07/2020 - Pino *****************/
|
|
ds.Tables["patrimonio"].Rows.Add(getTipologia(dsOriginal.Tables[1].Rows[k]["codFinalita"].ToString()), Helper.FormatCurrency(dsOriginal.Tables[1].Rows[k]["totale"].ToString()), Helper.FormatPercentage(percentuale, 2));
|
|
ds.Tables["torta"].Rows.Add(dsOriginal.Tables[1].Rows[k]["codFinalita"].ToString(), getTipologia(dsOriginal.Tables[1].Rows[k]["codFinalita"].ToString()), Helper.FormatDecimal(percentuale.ToString(), 2), dsOriginal.Tables[1].Rows[k]["ordine"]);
|
|
/**************************************************************************************************/
|
|
}
|
|
|
|
|
|
// TOTALI PATRIMONIO - FOOTER
|
|
ds.Tables["patrimonioFooter"].Rows.Add("<B>Totale</B>", "<B>" + Helper.FormatCurrency(totale.ToString()) + "</B>", "<B>100,0%</B>");
|
|
|
|
if (bFlag == true)
|
|
|
|
#region Immobiliare Batch
|
|
{
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
//var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodico].[PL_D_S159PatrimonioFinanziario]", parametriBatch);
|
|
var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_D_S154PatrimonioFinanziario]", parametriBatch);
|
|
if (dsBatch.Tables[0].Rows.Count == 0)
|
|
return ds;
|
|
|
|
// CALCOLO PER COMPOSIZIONE PATRIMONIO
|
|
decimal nTotalePatrimonio = 0;
|
|
foreach (DataRow itemDistribuzione in dsBatch.Tables[0].Rows)
|
|
{
|
|
var percentuale = (Convert.ToDecimal(itemDistribuzione[5]));
|
|
nTotalePatrimonio = nTotalePatrimonio + Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(percentuale).ToString(), 1));
|
|
}
|
|
bMax = false;
|
|
bMin = false;
|
|
|
|
if (nTotalePatrimonio > 100)
|
|
bMax = true;
|
|
else
|
|
{
|
|
if (nTotalePatrimonio < 100)
|
|
bMin = true;
|
|
}
|
|
|
|
GC_AssetClass = (Convert.ToDecimal(dsBatch.Tables[0].Rows[0][6]) / (finanziarioFideuram + finanziarioTerzi)) * 100;
|
|
|
|
#region Controllo per allineamento importi +/- decimale in data 28/03/2018
|
|
decimal bCheckFinanziario = 0;
|
|
foreach (DataRow itemDistribuzione in dsBatch.Tables[0].Rows)
|
|
{
|
|
var controvalore = Convert.ToDecimal(itemDistribuzione[4]);
|
|
/********** Fix per limare 1 cent sul totale - Pino *********************/
|
|
totaleFinanziario += Convert.ToDecimal(controvalore.ToString());
|
|
//totaleFinanziario += Convert.ToDecimal(Helper.FormatCurrency(controvalore.ToString())); -- Riga Originale
|
|
/*****************************************/
|
|
}
|
|
/*********** Pino ***************/
|
|
//if ((finanziarioFideuram + finanziarioTerzi) > totaleFinanziario)
|
|
//{
|
|
// bCheckFinanziario = -Convert.ToDecimal(0.01);
|
|
//}
|
|
//else
|
|
//{
|
|
// if ((finanziarioFideuram + finanziarioTerzi) < totaleFinanziario)
|
|
// {
|
|
// bCheckFinanziario = Convert.ToDecimal(0.01);
|
|
// }
|
|
//}
|
|
|
|
//totaleFinanziario = totaleFinanziario + bCheckFinanziario;
|
|
/************************************/
|
|
#endregion
|
|
|
|
foreach (DataRow itemDistribuzione in dsBatch.Tables[0].Rows)
|
|
{
|
|
var ordinamento = Convert.ToInt32(itemDistribuzione[1]);
|
|
|
|
var controvalore = Convert.ToDecimal(itemDistribuzione[4]);
|
|
var percentuale = (Convert.ToDecimal(itemDistribuzione[5]));
|
|
if (bMax == true)
|
|
{
|
|
percentuale = percentuale - Convert.ToDecimal(0.1);
|
|
bMax = false;
|
|
}
|
|
else
|
|
{
|
|
if (bMin == true)
|
|
{
|
|
percentuale = percentuale + Convert.ToDecimal(0.1);
|
|
bMin = false;
|
|
}
|
|
}
|
|
/******************* Fix per eliminare la gestione de decimali - Pino ********************/
|
|
//if (bCheckFinanziario != 0)
|
|
//{
|
|
// controvalore = controvalore + bCheckFinanziario;
|
|
// bCheckFinanziario = 0;
|
|
//}
|
|
/************************************************/
|
|
|
|
// Commentato per Controllo 28/03/2018
|
|
// totaleFinanziario += Convert.ToDecimal(Helper.FormatCurrency(controvalore.ToString()));
|
|
/******************************* Fix per valori a 3 cifre decimali - Pino ************************/
|
|
//ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione[3].ToString(), Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 2), ordinamento); // Originale
|
|
/**************************************************************************************************/
|
|
|
|
/****************************** Fix per valore a 2 cifre decimali sul peso 17/07/2020 - Pino *****************/
|
|
ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione[3].ToString(), Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 2), ordinamento);
|
|
//ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione[3].ToString(), Helper.FormatDecimal(controvalore.ToString(),3), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
/************************************************/
|
|
}
|
|
//if (getNota4().Length > 0)
|
|
// ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale *" + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
//else
|
|
// ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
|
|
if (getNota2().Length > 0)
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>"); // Originale
|
|
//ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatDecimal(totaleFinanziario.ToString(),3) + "</B>", "<B>100,0%</B>");
|
|
else
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>"); // Originale
|
|
//ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatDecimal(totaleFinanziario.ToString(),3) + "</B>", "<B>100,0%</B>");
|
|
|
|
}
|
|
#endregion
|
|
|
|
else
|
|
|
|
#region Immobiliare Online
|
|
{
|
|
var assetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass.distribuzione.elencoSlice;
|
|
var displayInfo = datiSeiUnico.displayInfos().macroAssetDisplayInfos.ToList();
|
|
|
|
// CALCOLO PER COMPOSIZIONE PATRIMONIO
|
|
decimal nTotalePatrimonio = 0;
|
|
foreach (var itemDistribuzione in assetClass)
|
|
{
|
|
if (itemDistribuzione.sliceRappresentabile)
|
|
{
|
|
//var percentuale = (itemDistribuzione.peso) * 100;
|
|
var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
nTotalePatrimonio = nTotalePatrimonio + Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(percentuale).ToString(), 1));
|
|
}
|
|
}
|
|
bMax = false;
|
|
bMin = false;
|
|
|
|
if (nTotalePatrimonio > 100)
|
|
bMax = true;
|
|
else
|
|
{
|
|
if (nTotalePatrimonio < 100 && nTotalePatrimonio != 0)
|
|
bMin = true;
|
|
}
|
|
|
|
//foreach (var itemDistribuzione in assetClass)
|
|
//{
|
|
// if (itemDistribuzione.sliceRappresentabile)
|
|
// {
|
|
// var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
|
|
// var ordinamento = mapDisplayInfo.order;
|
|
// if (itemDistribuzione.ctvCC > 0)
|
|
// {
|
|
// var controvalore = itemDistribuzione.ctvCC;
|
|
// var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
// totaleFinanziario += controvalore;
|
|
// ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
foreach (var itemDistribuzione in assetClass)
|
|
{
|
|
if (itemDistribuzione.sliceRappresentabile)
|
|
{
|
|
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
|
|
var ordinamento = mapDisplayInfo.order;
|
|
|
|
var controvalore = itemDistribuzione.ctvCC;
|
|
var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
if (bMax == true)
|
|
{
|
|
percentuale = percentuale - Convert.ToDecimal(0.1);
|
|
bMax = false;
|
|
}
|
|
else
|
|
{
|
|
if (bMin == true)
|
|
{
|
|
percentuale = percentuale + Convert.ToDecimal(0.1);
|
|
bMin = false;
|
|
}
|
|
}
|
|
totaleFinanziario += controvalore;
|
|
ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
}
|
|
}
|
|
//ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
if (datiSeiUnico.CASA_CCN != 0)
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
else
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
}
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
#region Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino
|
|
protected DataSet GetDataSetNew()
|
|
{
|
|
RecuperaPatrimonioTotale();
|
|
|
|
DataSet _ds = RecuperaDatiPatrimonioImmobiliare();
|
|
|
|
List<DettaglioPatrimonioImmobiliare> _listaDettaglioImmobili = ConvertTo<DettaglioPatrimonioImmobiliare>(_ds.Tables[1]);
|
|
|
|
decimal _totaleDettaglio = _listaDettaglioImmobili.Sum(s => s.totale);
|
|
|
|
// Calcolo il peso per ogni elemento della lista di dettaglio degli immobili
|
|
foreach (DettaglioPatrimonioImmobiliare item in _listaDettaglioImmobili)
|
|
{
|
|
|
|
//item.peso = (item.totale / _totaleDettaglio) * 100;
|
|
|
|
item.peso = (item.totale / _clsDatiPatrimonioGenerali.totale) * 100;
|
|
|
|
if ((item.totale / _clsDatiPatrimonioGenerali.totale) == 1)
|
|
{
|
|
string tmp = item.peso.ToString();
|
|
item.peso = Convert.ToDecimal(string.Concat(tmp, ",00"));
|
|
|
|
}
|
|
}
|
|
|
|
#region Lista Finale Patrimonio
|
|
// Per ogni tipologia di patrimonio riempio le relative liste finali del Patrimonio
|
|
List<Patrimonio> _listaPatrimonio = new List<Patrimonio>();
|
|
|
|
|
|
if (_clsDatiPatrimonioGenerali.finanziarioFideuram != 0)
|
|
{
|
|
_listaPatrimonio.Add(new Patrimonio()
|
|
{
|
|
Descrizione = "<B>Patrimonio finanziario Fideuram" + (getNota2().Length > 0 ? "*" : "") + "</B>",
|
|
Valore = string.Concat("<B>", Helper.FormatCurrency(Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.finanziarioFideuram, 2, MidpointRounding.ToEven))), "</B>"),
|
|
Peso = string.Concat("<B>", Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.pesoFideuram, 2, MidpointRounding.ToEven)), "</B>"),
|
|
Percentuale = Math.Round(_clsDatiPatrimonioGenerali.pesoFideuram, 2, MidpointRounding.ToEven)
|
|
});
|
|
}
|
|
|
|
if (_clsDatiPatrimonioGenerali.finanziarioTerzi != 0)
|
|
{
|
|
_listaPatrimonio.Add(new Patrimonio()
|
|
{
|
|
Descrizione = "<B>Patrimonio finanziario altri Istituti" + (getNota3().Length <= 0 ? "" : (getNota2().Length > 0 ? "**" : "*")) + "</B>",
|
|
Valore = string.Concat("<B>", Helper.FormatCurrency(Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.finanziarioTerzi, 2, MidpointRounding.ToEven))), "</B>"),
|
|
Peso = string.Concat("<B>", Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.pesoTerzi, 2, MidpointRounding.ToEven)), "</B>"),
|
|
Percentuale = Math.Round(_clsDatiPatrimonioGenerali.pesoTerzi, 2, MidpointRounding.ToEven)
|
|
});
|
|
}
|
|
|
|
if (_clsDatiPatrimonioGenerali.immobiliare != 0)
|
|
{
|
|
_listaPatrimonio.Add(new Patrimonio()
|
|
{
|
|
Descrizione = "<B>Patrimonio immobiliare</B>",
|
|
Valore = string.Concat("<B>", Helper.FormatCurrency(Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.immobiliare, 2, MidpointRounding.ToEven))), "</B>"),
|
|
Peso = string.Concat("<B>", Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.pesoImmobiliare, 2, MidpointRounding.ToEven)), "</B>"),
|
|
Percentuale = Math.Round(_clsDatiPatrimonioGenerali.pesoImmobiliare, 2, MidpointRounding.ToEven),
|
|
TipologiaPatrimonio = "MasterImmobiliare",
|
|
});
|
|
}
|
|
|
|
decimal sommaPesoImmobiliare = 0;
|
|
foreach (DettaglioPatrimonioImmobiliare item in _listaDettaglioImmobili)
|
|
{
|
|
_listaPatrimonio.Add(new Patrimonio()
|
|
{
|
|
Descrizione = getTipologia(item.codFinalita),
|
|
Valore = Helper.FormatCurrency(Convert.ToString(Math.Round(item.totale, 2, MidpointRounding.ToEven))),
|
|
Peso = Convert.ToString(Math.Round(item.peso, 2, MidpointRounding.ToEven)),
|
|
Percentuale = Math.Round(item.peso, 2, MidpointRounding.ToEven),
|
|
TipologiaPatrimonio = "Dettaglio"
|
|
});
|
|
|
|
sommaPesoImmobiliare += item.peso;
|
|
}
|
|
|
|
var listaNormalizzata = NormalizzoPesi<Patrimonio>(_listaPatrimonio.ToList());
|
|
|
|
_listaPatrimonio.Clear();
|
|
|
|
_listaPatrimonio = listaNormalizzata;
|
|
|
|
//_listaPatrimonio.Find(f => f.Descrizione == "<B>Patrimonio immobiliare</B>").Peso = string.Concat("<B>", Convert.ToString(sommaPesoImmobiliare), "</B>");
|
|
|
|
#endregion
|
|
|
|
#region Lista Patrimonio Footer
|
|
// Riempio la lista Footer del patrimonio
|
|
decimal pesoTotale = _clsDatiPatrimonioGenerali.pesoFideuram + _clsDatiPatrimonioGenerali.pesoTerzi + sommaPesoImmobiliare;
|
|
List<PatrimonioFooter> _listaPatrimonioFooter = new List<PatrimonioFooter>();
|
|
_listaPatrimonioFooter.Add(new PatrimonioFooter()
|
|
{
|
|
Descrizione = "<B>Totale</B>",
|
|
Valore =string.Concat("<B>", Helper.FormatCurrency(Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.totale, 2, MidpointRounding.ToEven))),"</B>"),
|
|
Peso = string.Concat("<B>",Convert.ToString(Math.Round(pesoTotale, 2, MidpointRounding.ToEven)),"</B>")
|
|
});
|
|
#endregion
|
|
|
|
#region Lista Finale Torta
|
|
List<Torta> _listaTorta = new List<Torta>();
|
|
if (_clsDatiPatrimonioGenerali.pesoFideuram != 0)
|
|
_listaTorta.Add(new Torta()
|
|
{
|
|
indice = "PF",
|
|
tipologia = "<B>Patrimonio finanziario Fideuram</B>",
|
|
peso = Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.pesoFideuram, 2, MidpointRounding.ToEven)),
|
|
ordine = 5
|
|
});
|
|
|
|
if (_clsDatiPatrimonioGenerali.pesoTerzi != 0)
|
|
_listaTorta.Add(new Torta()
|
|
{
|
|
indice = "PT",
|
|
tipologia = "<B>Patrimonio finanziario altri Istituti</B>",
|
|
peso = Convert.ToString(Math.Round(_clsDatiPatrimonioGenerali.pesoTerzi, 2, MidpointRounding.ToEven)),
|
|
ordine = 6
|
|
});
|
|
|
|
foreach (DettaglioPatrimonioImmobiliare item in _listaDettaglioImmobili)
|
|
{
|
|
_listaTorta.Add(new Torta()
|
|
{
|
|
indice = item.codFinalita,
|
|
tipologia = getTipologia(item.codFinalita),
|
|
peso = Convert.ToString(Math.Round(item.peso, 2, MidpointRounding.ToEven)),
|
|
ordine = Convert.ToInt16(item.ordine)
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
// Converto le liste Finali in un DataTable
|
|
var _dtTMPPatrimonio = ToDataTable<Patrimonio>(_listaPatrimonio);
|
|
_dtTMPPatrimonio.TableName = "patrimonio";
|
|
var _dtTMPFooter = ToDataTable<PatrimonioFooter>(_listaPatrimonioFooter);
|
|
_dtTMPFooter.TableName = "patrimonioFooter";
|
|
var _dtTMPTorta = ToDataTable<Torta>(_listaTorta);
|
|
_dtTMPTorta.TableName = "torta";
|
|
|
|
//// Inserisco il datatable nel dataset
|
|
DataSet ds = new DataSet();
|
|
ds.Tables.Add(_dtTMPPatrimonio);
|
|
ds.Tables.Add(_dtTMPFooter);
|
|
ds.Tables.Add(_dtTMPTorta);
|
|
|
|
#region Nuova Sezione per la Tabella Composizione Patrimonio Finanziario
|
|
ds.Tables.Add(new DataTable("composizionePatrimonio"));
|
|
ds.Tables.Add(new DataTable("composizionePatrimonioFooter"));
|
|
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Composizione", typeof(string)));
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Composizione", typeof(string)));
|
|
ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
|
|
if (bFlag == true)
|
|
{
|
|
#region Immobiliare Batch
|
|
List<PatrimonioFinanziario> _lista = RecuperoPatrimonioFinanziario();
|
|
|
|
if ((_lista == null) || (_lista.Count == 0)) return ds;
|
|
|
|
GC_AssetClass = (Convert.ToDecimal(_lista.Select(s=> s.PatrimonioFinanziarioCTV).First()) / (_clsDatiPatrimonioGenerali.finanziarioFideuram + _clsDatiPatrimonioGenerali.finanziarioTerzi)) * 100;
|
|
|
|
foreach (PatrimonioFinanziario itemDistribuzione in _lista)
|
|
{
|
|
ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.AssetClassName, Helper.FormatCurrency(itemDistribuzione.Controvalore.ToString()), Convert.ToString(itemDistribuzione.NuovoPercentuale), itemDistribuzione.Ordinamento);
|
|
}
|
|
|
|
var _listaNormalizzate = NormalizzoPesi<PatrimonioFinanziario>(_lista);
|
|
|
|
decimal totalePesi = _lista.Sum(su => su.NuovoPercentuale);
|
|
|
|
if (totalePesi == 100.01M)
|
|
totalePesi = 100.00M;
|
|
|
|
if (getNota2().Length > 0)
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatCurrency(_lista.Select(s => s.PatrimonioFinanziarioCTV).First().ToString()) + "</B>", "<B>" + totalePesi + "</B>"); // Originale
|
|
//ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatDecimal(totaleFinanziario.ToString(),3) + "</B>", "<B>100,0%</B>");
|
|
else
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatCurrency(_lista.Select(s => s.PatrimonioFinanziarioCTV).First().ToString()) + "</B>", "<B>" + totalePesi + "</B>"); // Originale
|
|
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
#region Immobiliare Online
|
|
{
|
|
bool bMax = false;
|
|
bool bMin = false;
|
|
decimal totaleFinanziario = 0;
|
|
|
|
var assetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass.distribuzione.elencoSlice;
|
|
var displayInfo = datiSeiUnico.displayInfos().macroAssetDisplayInfos.ToList();
|
|
|
|
// CALCOLO PER COMPOSIZIONE PATRIMONIO
|
|
decimal nTotalePatrimonio = 0;
|
|
foreach (var itemDistribuzione in assetClass)
|
|
{
|
|
if (itemDistribuzione.sliceRappresentabile)
|
|
{
|
|
//var percentuale = (itemDistribuzione.peso) * 100;
|
|
var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
nTotalePatrimonio = nTotalePatrimonio + Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(percentuale).ToString(), 1));
|
|
}
|
|
}
|
|
bMax = false;
|
|
bMin = false;
|
|
|
|
if (nTotalePatrimonio > 100)
|
|
bMax = true;
|
|
else
|
|
{
|
|
if (nTotalePatrimonio < 100 && nTotalePatrimonio != 0)
|
|
bMin = true;
|
|
}
|
|
|
|
foreach (var itemDistribuzione in assetClass)
|
|
{
|
|
if (itemDistribuzione.sliceRappresentabile)
|
|
{
|
|
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
|
|
var ordinamento = mapDisplayInfo.order;
|
|
|
|
var controvalore = itemDistribuzione.ctvCC;
|
|
var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
|
|
|
|
totaleFinanziario += controvalore;
|
|
/****************************** Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino *****************/
|
|
ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Convert.ToString(Math.Round(percentuale, 2, MidpointRounding.ToEven)), ordinamento);
|
|
//ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
/************************************************/
|
|
}
|
|
}
|
|
//ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
if (datiSeiUnico.CASA_CCN != 0)
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,00</B>");
|
|
else
|
|
ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,00</B>");
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Sezione per la Tabella Composizione Patrimonio Finanziario
|
|
//bool bMax = false;
|
|
//bool bMin = false;
|
|
//decimal totaleFinanziario = 0;
|
|
|
|
//ds.Tables.Add(new DataTable("composizionePatrimonio"));
|
|
//ds.Tables.Add(new DataTable("composizionePatrimonioFooter"));
|
|
|
|
//ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Composizione", typeof(string)));
|
|
//ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
//ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
//ds.Tables["composizionePatrimonio"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
|
|
|
|
//ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Composizione", typeof(string)));
|
|
//ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Valore", typeof(string)));
|
|
//ds.Tables["composizionePatrimonioFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
|
|
|
|
//if (bFlag == true)
|
|
|
|
//#region Immobiliare Batch
|
|
//{
|
|
// var parametriBatch = new List<Parametro>
|
|
// {
|
|
// new Parametro
|
|
// {
|
|
// Direction = ParameterDirection.Input,
|
|
// DbType = DbType.String,
|
|
// ParameterName = "Rete",
|
|
// Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
// },
|
|
// new Parametro
|
|
// {
|
|
// Direction = ParameterDirection.Input,
|
|
// DbType = DbType.String,
|
|
// ParameterName = "CodiceFiscale",
|
|
// Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
// }
|
|
|
|
// };
|
|
|
|
// //var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodico].[PL_D_S159PatrimonioFinanziario]", parametriBatch);
|
|
// var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_D_S154PatrimonioFinanziario]", parametriBatch);
|
|
// if (dsBatch.Tables[0].Rows.Count == 0)
|
|
// return ds;
|
|
|
|
// // CALCOLO PER COMPOSIZIONE PATRIMONIO
|
|
// decimal nTotalePatrimonio = 0;
|
|
// foreach (DataRow itemDistribuzione in dsBatch.Tables[0].Rows)
|
|
// {
|
|
// var percentuale = (Convert.ToDecimal(itemDistribuzione[5]));
|
|
// nTotalePatrimonio = nTotalePatrimonio + Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(percentuale).ToString(), 1));
|
|
// }
|
|
// bMax = false;
|
|
// bMin = false;
|
|
|
|
// if (nTotalePatrimonio > 100)
|
|
// bMax = true;
|
|
// else
|
|
// {
|
|
// if (nTotalePatrimonio < 100)
|
|
// bMin = true;
|
|
// }
|
|
|
|
// GC_AssetClass = (Convert.ToDecimal(dsBatch.Tables[0].Rows[0][6]) / (_clsDatiPatrimonioGenerali.finanziarioFideuram + _clsDatiPatrimonioGenerali.finanziarioTerzi)) * 100;
|
|
|
|
// #region Controllo per allineamento importi +/- decimale in data 28/03/2018
|
|
// decimal bCheckFinanziario = 0;
|
|
// foreach (DataRow itemDistribuzione in dsBatch.Tables[0].Rows)
|
|
// {
|
|
// var controvalore = Convert.ToDecimal(itemDistribuzione[4]);
|
|
// /********** Fix per limare 1 cent sul totale - Pino *********************/
|
|
// totaleFinanziario += Convert.ToDecimal(controvalore.ToString());
|
|
// //totaleFinanziario += Convert.ToDecimal(Helper.FormatCurrency(controvalore.ToString())); -- Riga Originale
|
|
// /*****************************************/
|
|
// }
|
|
// /*********** Pino ***************/
|
|
// //if ((finanziarioFideuram + finanziarioTerzi) > totaleFinanziario)
|
|
// //{
|
|
// // bCheckFinanziario = -Convert.ToDecimal(0.01);
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // if ((finanziarioFideuram + finanziarioTerzi) < totaleFinanziario)
|
|
// // {
|
|
// // bCheckFinanziario = Convert.ToDecimal(0.01);
|
|
// // }
|
|
// //}
|
|
|
|
// //totaleFinanziario = totaleFinanziario + bCheckFinanziario;
|
|
// /************************************/
|
|
// #endregion
|
|
|
|
// foreach (DataRow itemDistribuzione in dsBatch.Tables[0].Rows)
|
|
// {
|
|
// var ordinamento = Convert.ToInt32(itemDistribuzione[1]);
|
|
|
|
// var controvalore = Convert.ToDecimal(itemDistribuzione[4]);
|
|
// var percentuale = (Convert.ToDecimal(itemDistribuzione[5]));
|
|
|
|
// /****************************** Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino *****************/
|
|
// //if (bMax == true)
|
|
// //{
|
|
// // percentuale = percentuale - Convert.ToDecimal(0.1);
|
|
// // bMax = false;
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // if (bMin == true)
|
|
// // {
|
|
// // percentuale = percentuale + Convert.ToDecimal(0.1);
|
|
// // bMin = false;
|
|
// // }
|
|
// //}
|
|
// /************************************************/
|
|
|
|
// /******************* Fix per eliminare la gestione de decimali - Pino ********************/
|
|
// //if (bCheckFinanziario != 0)
|
|
// //{
|
|
// // controvalore = controvalore + bCheckFinanziario;
|
|
// // bCheckFinanziario = 0;
|
|
// //}
|
|
// /************************************************/
|
|
|
|
// // Commentato per Controllo 28/03/2018
|
|
// // totaleFinanziario += Convert.ToDecimal(Helper.FormatCurrency(controvalore.ToString()));
|
|
|
|
|
|
// /****************************** Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino *****************/
|
|
// ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione[3].ToString(), Helper.FormatCurrency(controvalore.ToString()), Convert.ToString(Math.Round(percentuale, 2, MidpointRounding.ToEven)), ordinamento);
|
|
// //ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione[3].ToString(), Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 2), ordinamento);
|
|
// //ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione[3].ToString(), Helper.FormatDecimal(controvalore.ToString(),3), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
// /************************************************/
|
|
// }
|
|
// //if (getNota4().Length > 0)
|
|
// // ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale *" + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
// //else
|
|
// // ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
|
|
// if (getNota2().Length > 0)
|
|
// ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,00</B>"); // Originale
|
|
// //ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatDecimal(totaleFinanziario.ToString(),3) + "</B>", "<B>100,0%</B>");
|
|
// else
|
|
// ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,00</B>"); // Originale
|
|
// //ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatDecimal(totaleFinanziario.ToString(),3) + "</B>", "<B>100,0%</B>");
|
|
|
|
//}
|
|
//#endregion
|
|
|
|
//else
|
|
|
|
//#region Immobiliare Online
|
|
//{
|
|
// var assetClass = datiSeiUnico.patrimonioUnit().patrimonioFinanziario.macroAssetClass.distribuzione.elencoSlice;
|
|
// var displayInfo = datiSeiUnico.displayInfos().macroAssetDisplayInfos.ToList();
|
|
|
|
// // CALCOLO PER COMPOSIZIONE PATRIMONIO
|
|
// decimal nTotalePatrimonio = 0;
|
|
// foreach (var itemDistribuzione in assetClass)
|
|
// {
|
|
// if (itemDistribuzione.sliceRappresentabile)
|
|
// {
|
|
// //var percentuale = (itemDistribuzione.peso) * 100;
|
|
// var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
// nTotalePatrimonio = nTotalePatrimonio + Convert.ToDecimal(Helper.FormatDecimal(Convert.ToDecimal(percentuale).ToString(), 1));
|
|
// }
|
|
// }
|
|
// bMax = false;
|
|
// bMin = false;
|
|
|
|
// if (nTotalePatrimonio > 100)
|
|
// bMax = true;
|
|
// else
|
|
// {
|
|
// if (nTotalePatrimonio < 100 && nTotalePatrimonio != 0)
|
|
// bMin = true;
|
|
// }
|
|
|
|
// //foreach (var itemDistribuzione in assetClass)
|
|
// //{
|
|
// // if (itemDistribuzione.sliceRappresentabile)
|
|
// // {
|
|
// // var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
|
|
// // var ordinamento = mapDisplayInfo.order;
|
|
// // if (itemDistribuzione.ctvCC > 0)
|
|
// // {
|
|
// // var controvalore = itemDistribuzione.ctvCC;
|
|
// // var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
// // totaleFinanziario += controvalore;
|
|
// // ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
// // }
|
|
// // }
|
|
// //}
|
|
|
|
// foreach (var itemDistribuzione in assetClass)
|
|
// {
|
|
// if (itemDistribuzione.sliceRappresentabile)
|
|
// {
|
|
// var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
|
|
// var ordinamento = mapDisplayInfo.order;
|
|
|
|
// var controvalore = itemDistribuzione.ctvCC;
|
|
// var percentuale = (itemDistribuzione.pesoCC) * 100;
|
|
|
|
// /****************************** Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino *****************/
|
|
// //if (bMax == true)
|
|
// //{
|
|
// // percentuale = percentuale - Convert.ToDecimal(0.1);
|
|
// // bMax = false;
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // if (bMin == true)
|
|
// // {
|
|
// // percentuale = percentuale + Convert.ToDecimal(0.1);
|
|
// // bMin = false;
|
|
// // }
|
|
// //}
|
|
// /************************************************/
|
|
|
|
// totaleFinanziario += controvalore;
|
|
// /****************************** Fix per la nuova gestione dei pesi in relazione alla fix per le 2 cifre decimali del 17/07/2020 - Pino *****************/
|
|
// ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Convert.ToString(Math.Round(percentuale, 2, MidpointRounding.ToEven)), ordinamento);
|
|
// //ds.Tables["composizionePatrimonio"].Rows.Add(itemDistribuzione.descrizione, Helper.FormatCurrency(controvalore.ToString()), Helper.FormatPercentage(Convert.ToDecimal(percentuale), 1), ordinamento);
|
|
// /************************************************/
|
|
// }
|
|
// }
|
|
// //ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,0%</B>");
|
|
// if (datiSeiUnico.CASA_CCN != 0)
|
|
// ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " **" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,00</B>");
|
|
// else
|
|
// ds.Tables["composizionePatrimonioFooter"].Rows.Add("<B>Totale" + (getNota4().Length > 0 ? " *" : "") + "</B>", "<B>" + Helper.FormatCurrency(totaleFinanziario.ToString()) + "</B>", "<B>100,00</B>");
|
|
//}
|
|
//#endregion
|
|
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
private void RecuperaPatrimonioTotale()
|
|
{
|
|
if (bFlag == true)
|
|
{
|
|
#region Immobiliare Batch
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_D_S152Patrimonio]", parametriBatch);
|
|
if (dsBatch.Tables[0].Rows.Count > 0)
|
|
{
|
|
// Lettura Dati da Procedura Batch
|
|
_clsDatiPatrimonioGenerali.finanziarioFideuram = Convert.ToDecimal(dsBatch.Tables[0].Rows[0][0]);
|
|
_clsDatiPatrimonioGenerali.finanziarioTerzi = Convert.ToDecimal(dsBatch.Tables[0].Rows[0][1]);
|
|
_clsDatiPatrimonioGenerali.immobiliare = Convert.ToDecimal(dsBatch.Tables[0].Rows[0][4]);
|
|
_clsDatiPatrimonioGenerali.totale = _clsDatiPatrimonioGenerali.finanziarioFideuram + _clsDatiPatrimonioGenerali.finanziarioTerzi + _clsDatiPatrimonioGenerali.immobiliare;
|
|
_clsDatiPatrimonioGenerali.pesoFideuram = _clsDatiPatrimonioGenerali.finanziarioFideuram * 100 / _clsDatiPatrimonioGenerali.totale;
|
|
_clsDatiPatrimonioGenerali.pesoTerzi = _clsDatiPatrimonioGenerali.finanziarioTerzi * 100 / _clsDatiPatrimonioGenerali.totale;
|
|
_clsDatiPatrimonioGenerali.pesoImmobiliare = _clsDatiPatrimonioGenerali.immobiliare * 100 / _clsDatiPatrimonioGenerali.totale;
|
|
|
|
if (_clsDatiPatrimonioGenerali.pesoImmobiliare == 100)
|
|
{
|
|
_clsDatiPatrimonioGenerali.pesoImmobiliare = Convert.ToDecimal("100,00");
|
|
}
|
|
|
|
_clsDatiPatrimonioGenerali.totaleFinanziario = 0;
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region Immobiliare Online
|
|
// Lettura Dati Normale
|
|
var datiSei = datiSeiUnico;
|
|
_clsDatiPatrimonioGenerali.finanziarioFideuram = datiSeiUnico.CASA_TOTALEPOSITIVO;
|
|
_clsDatiPatrimonioGenerali.finanziarioTerzi = datiSeiUnico.TRZ_TOTALE;
|
|
_clsDatiPatrimonioGenerali.immobiliare = datiSeiUnico.IMB_TOTALE;
|
|
_clsDatiPatrimonioGenerali.totale = _clsDatiPatrimonioGenerali.finanziarioFideuram + _clsDatiPatrimonioGenerali.finanziarioTerzi + _clsDatiPatrimonioGenerali.immobiliare;
|
|
_clsDatiPatrimonioGenerali.pesoFideuram = _clsDatiPatrimonioGenerali.finanziarioFideuram * 100 / _clsDatiPatrimonioGenerali.totale;
|
|
_clsDatiPatrimonioGenerali.pesoTerzi = _clsDatiPatrimonioGenerali.finanziarioTerzi * 100 / _clsDatiPatrimonioGenerali.totale;
|
|
_clsDatiPatrimonioGenerali.pesoImmobiliare = _clsDatiPatrimonioGenerali.immobiliare * 100 / _clsDatiPatrimonioGenerali.totale;
|
|
_clsDatiPatrimonioGenerali.totaleFinanziario = 0;
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
private DataSet RecuperaDatiPatrimonioImmobiliare()
|
|
{
|
|
var parametri = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.Int64,
|
|
ParameterName = "ChiaveClientePB",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
|
}
|
|
};
|
|
|
|
var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_AnalisiRischioSintesi", parametri);
|
|
if (dsOriginal.Tables[0].Rows.Count == 0)
|
|
return null;
|
|
else
|
|
return dsOriginal;
|
|
|
|
}
|
|
|
|
private List<PatrimonioFinanziario> RecuperoPatrimonioFinanziario()
|
|
{
|
|
DataTable _dt = new DataTable();
|
|
DataSet ds = null;
|
|
//String connString = ConfigurationManager.ConnectionStrings["SqlServerStampeC6"].ToString();
|
|
List<PatrimonioFinanziario> _listaDettaglioImmobili = new List<PatrimonioFinanziario>();
|
|
|
|
var parametriBatch = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.TipologiaContratto
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodiceFiscale",
|
|
Value = EnvironmentFacade.ReportEnvironment.Cliente.CodiceFiscale
|
|
}
|
|
|
|
};
|
|
|
|
//var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodico].[PL_D_S159PatrimonioFinanziario]", parametriBatch);
|
|
var dsBatch = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerStampeC6, "[C6MartPeriodicoImmobiliare].[PL_D_S154PatrimonioFinanziario]", parametriBatch);
|
|
if (dsBatch.Tables[0].Rows.Count == 0)
|
|
return _listaDettaglioImmobili;
|
|
|
|
if (dsBatch.Tables.Count > 0)
|
|
{
|
|
_listaDettaglioImmobili = ConvertTo<PatrimonioFinanziario>(dsBatch.Tables[0]);
|
|
|
|
_listaDettaglioImmobili = NormalizzoPesi<PatrimonioFinanziario>(_listaDettaglioImmobili);
|
|
}
|
|
|
|
return _listaDettaglioImmobili;
|
|
}
|
|
|
|
private List<T> NormalizzoPesi<T>(List<T> _listaDanormalizzare)
|
|
{
|
|
List<T> _listaNormalizzataT = new List<T>();
|
|
|
|
if (_listaDanormalizzare is List<PatrimonioFinanziario>)
|
|
{
|
|
// Arrotondo a 2 cifre decimali
|
|
foreach (PatrimonioFinanziario item in _listaDanormalizzare.Cast<PatrimonioFinanziario>())
|
|
{
|
|
item.Percentuale = Math.Round(item.Percentuale, 2, MidpointRounding.ToEven);
|
|
item.NuovoPercentuale = Math.Round(item.Percentuale, 2, MidpointRounding.ToEven);
|
|
};
|
|
|
|
// Calcolo il totale
|
|
decimal TotalePercentuale = _listaDanormalizzare.Cast<PatrimonioFinanziario>().Sum(s => s.Percentuale);
|
|
|
|
_listaNormalizzataT = _listaDanormalizzare;
|
|
|
|
// Determino l'errore Err = Desi - Eff
|
|
decimal Desi = 100.00M;
|
|
decimal error = Desi - TotalePercentuale;
|
|
|
|
if (error != 0)
|
|
{
|
|
// Determino se l'errore è dell'ordine delle decine o delle centinaie
|
|
if ((Math.Abs(error) * 100) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.05)
|
|
foreach (var item in _listaNormalizzataT.Cast<PatrimonioFinanziario>())
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(1, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
}
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
|
|
if (_listaNormalizzataT.Cast<PatrimonioFinanziario>().Sum(s => s.NuovoPercentuale) == 100.00M) break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((Math.Abs(error) * 10) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.5)
|
|
foreach (var item in _listaNormalizzataT.Cast<PatrimonioFinanziario>())
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(0, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
}
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
|
|
if (_listaNormalizzataT.Cast<PatrimonioFinanziario>().Sum(s => s.NuovoPercentuale) == 100.00M) break;
|
|
}
|
|
|
|
//Utility.ShowMessageBox("Decine", "Patrimonio finanziario", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
// Arrotondo a 2 cifre decimali
|
|
foreach (Patrimonio item in _listaDanormalizzare.Cast<Patrimonio>())
|
|
{
|
|
item.Percentuale = Math.Round(item.Percentuale, 2, MidpointRounding.ToEven);
|
|
item.NuovoPercentuale = Math.Round(item.Percentuale, 2, MidpointRounding.ToEven);
|
|
};
|
|
|
|
|
|
List<T> _listaDettaglioNormalizzata = NormalizzoPesiDettaglioImmobiliare<T>(_listaDanormalizzare.Cast<T>().ToList());
|
|
|
|
_listaDanormalizzare = _listaDettaglioNormalizzata;
|
|
|
|
/******** Recupera in numero di intestazioni delle tabelle 28/04/2021 -- Pino **************************************/
|
|
int contaIntestazione = _listaDanormalizzare.Cast<Patrimonio>().Where(f => f.Descrizione.Contains("<B>")).Count();
|
|
/*******************************************************************************************************************/
|
|
|
|
// Calcolo il totale
|
|
decimal TotalePercentuale = _listaDanormalizzare.Cast<Patrimonio>().Take(contaIntestazione).Sum(s => s.Percentuale);
|
|
|
|
_listaNormalizzataT = _listaDanormalizzare;
|
|
|
|
// Determino l'errore Err = Desi - Eff
|
|
decimal Desi = 100.00M;
|
|
decimal error = Desi - TotalePercentuale;
|
|
|
|
if (error != 0)
|
|
{
|
|
// Determino se l'errore è dell'ordine delle decine o delle centinaie
|
|
if ((Math.Abs(error) * 100) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.05)
|
|
foreach (var item in _listaNormalizzataT.Cast<Patrimonio>().Take(2))
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(1, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
|
|
item.Peso = string.Concat("<B>", Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven)), "</B>");
|
|
}
|
|
else
|
|
{
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
item.Peso = string.Concat("<B>", Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven)), "</B>");
|
|
}
|
|
|
|
if (_listaNormalizzataT.Cast<Patrimonio>().Take(contaIntestazione).Sum(s => s.NuovoPercentuale) == 100.00M) break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((Math.Abs(error) * 10) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.5)
|
|
foreach (var item in _listaNormalizzataT.Cast<Patrimonio>().Take(2))
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(0, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
|
|
item.Peso = string.Concat("<B>", Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven)), "</B>");
|
|
}
|
|
else
|
|
{
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
item.Peso = string.Concat("<B>", Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven)), "</B>");
|
|
}
|
|
|
|
|
|
if (_listaNormalizzataT.Cast<Patrimonio>().Take(contaIntestazione).Sum(s => s.NuovoPercentuale) == 100.00M) break;
|
|
}
|
|
|
|
//Utility.ShowMessageBox("Decine", "Patrimonio finanziario", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return _listaNormalizzataT;
|
|
}
|
|
|
|
private List<T> NormalizzoPesiDettaglioImmobiliare<T>(List<T> _listaDanormalizzare)
|
|
{
|
|
List<T> _listaNormalizzataT = new List<T>();
|
|
|
|
if (_listaDanormalizzare is List<Patrimonio>)
|
|
{
|
|
|
|
// Trovo il totale
|
|
decimal TotalePercentuale = _listaDanormalizzare.Cast<Patrimonio>().Where(f=> f.TipologiaPatrimonio== "MasterImmobiliare").Sum(s => s.Percentuale);
|
|
|
|
// Calcolo il totale del Dettaglio
|
|
decimal totalePercentualeDettaglio = _listaDanormalizzare.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").Sum(s => s.Percentuale);
|
|
|
|
_listaNormalizzataT = _listaDanormalizzare;
|
|
|
|
// Determino l'errore Err = Desi - Eff
|
|
decimal Desi = TotalePercentuale;
|
|
decimal error = Desi - totalePercentualeDettaglio;
|
|
|
|
if (error != 0)
|
|
{
|
|
// Determino se l'errore è dell'ordine delle decine o delle centinaie
|
|
if ((Math.Abs(error) * 100) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.05)
|
|
foreach (var item in _listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio"))
|
|
{
|
|
if (item.Percentuale != 0)
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(1, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
|
|
item.Peso = Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven));
|
|
}
|
|
else
|
|
{
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
item.Peso = Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven));
|
|
}
|
|
|
|
if (_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").Sum(s => s.NuovoPercentuale) == Desi) break;
|
|
}
|
|
else
|
|
{
|
|
if (error < 0)
|
|
_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().NuovoPercentuale = _listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().Percentuale - Math.Abs(error);
|
|
else
|
|
_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().NuovoPercentuale = _listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().Percentuale + Math.Abs(error);
|
|
|
|
_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().Peso = Convert.ToString(Math.Round(_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().NuovoPercentuale, 2, MidpointRounding.ToEven));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((Math.Abs(error) * 10) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.5)
|
|
foreach (var item in _listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio"))
|
|
{
|
|
|
|
if (item.Percentuale != 0)
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(0, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
|
|
item.Peso = Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven));
|
|
}
|
|
else
|
|
{
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
item.Peso = Convert.ToString(Math.Round(item.NuovoPercentuale, 2, MidpointRounding.ToEven));
|
|
}
|
|
|
|
|
|
if (_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").Sum(s => s.NuovoPercentuale) == Desi) break;
|
|
}
|
|
else
|
|
{
|
|
if (error < 0)
|
|
_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().NuovoPercentuale = _listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().Percentuale - Math.Abs(error);
|
|
else
|
|
_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().NuovoPercentuale = _listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().Percentuale + Math.Abs(error);
|
|
|
|
_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().Peso = Convert.ToString(Math.Round(_listaNormalizzataT.Cast<Patrimonio>().Where(f => f.TipologiaPatrimonio == "Dettaglio").First().NuovoPercentuale, 2, MidpointRounding.ToEven));
|
|
}
|
|
}
|
|
|
|
//Utility.ShowMessageBox("Decine", "Patrimonio finanziario", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return _listaNormalizzataT;
|
|
}
|
|
|
|
private List<PatrimonioFinanziario> NormalizzoPesi(List<PatrimonioFinanziario> _listaDanormalizzare)
|
|
{
|
|
List<PatrimonioFinanziario> _listaNormalizzata = new List<PatrimonioFinanziario>();
|
|
|
|
// Arrotondo a 2 cifre decimali
|
|
foreach (var item in _listaDanormalizzare)
|
|
{
|
|
item.Percentuale = Math.Round(item.Percentuale, 2, MidpointRounding.ToEven);
|
|
item.NuovoPercentuale = Math.Round(item.Percentuale, 2, MidpointRounding.ToEven);
|
|
};
|
|
|
|
_listaNormalizzata = _listaDanormalizzare;
|
|
|
|
// Calcolo il totale
|
|
decimal TotalePercentuale = _listaDanormalizzare.Sum(s => s.Percentuale);
|
|
|
|
// Determino l'errore Err = Desi - Eff
|
|
decimal Desi = 100.00M;
|
|
decimal error = Desi - TotalePercentuale;
|
|
|
|
if (error != 0)
|
|
{
|
|
// Determino se l'errore è dell'ordine delle decine o delle centinaie
|
|
if ((Math.Abs(error) * 100) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.05)
|
|
foreach (var item in _listaNormalizzata)
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(1, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
}
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
|
|
if (_listaNormalizzata.Sum(s => s.NuovoPercentuale) == 100.00M) break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((Math.Abs(error) * 10) >= 1)
|
|
{
|
|
// ciclo sulla lista dei valori percentuali e individuo quelli che posso modificare ( > 0.5)
|
|
foreach (var item in _listaNormalizzata)
|
|
{
|
|
if (Convert.ToInt16(item.Percentuale.ToString().Split(',')[1].Substring(0, 1)) >= 5)
|
|
{
|
|
// Se l'errore è negativo allora diminuisco un valore percentuale della quantita individuata nella variabile valore
|
|
if (error < 0)
|
|
item.NuovoPercentuale = item.Percentuale + Math.Abs(error);
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale - Math.Abs(error);
|
|
}
|
|
else
|
|
item.NuovoPercentuale = item.Percentuale;
|
|
|
|
if (_listaNormalizzata.Sum(s => s.NuovoPercentuale) == 100.00M) break;
|
|
}
|
|
|
|
//Utility.ShowMessageBox("Decine", "Patrimonio finanziario", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|
|
|
|
return _listaNormalizzata;
|
|
}
|
|
|
|
public List<T> ConvertTo<T>(DataTable datatable) where T : new()
|
|
{
|
|
List<T> Temp = new List<T>();
|
|
try
|
|
{
|
|
List<string> columnsNames = new List<string>();
|
|
foreach (DataColumn DataColumn in datatable.Columns)
|
|
columnsNames.Add(DataColumn.ColumnName);
|
|
Temp = datatable.AsEnumerable().ToList().ConvertAll<T>(row => getObject<T>(row, columnsNames));
|
|
return Temp;
|
|
}
|
|
catch
|
|
{
|
|
return Temp;
|
|
}
|
|
|
|
}
|
|
|
|
public T getObject<T>(DataRow row, List<string> columnsName) where T : new()
|
|
{
|
|
T obj = new T();
|
|
try
|
|
{
|
|
string columnname = "";
|
|
string value = "";
|
|
PropertyInfo[] Properties;
|
|
Properties = typeof(T).GetProperties();
|
|
foreach (PropertyInfo objProperty in Properties)
|
|
{
|
|
columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower());
|
|
if (!string.IsNullOrEmpty(columnname))
|
|
{
|
|
value = row[columnname].ToString();
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null)
|
|
{
|
|
value = row[columnname].ToString().Replace("$", "").Replace(",", "");
|
|
objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())), null);
|
|
}
|
|
else
|
|
{
|
|
value = row[columnname].ToString().Replace("%", "");
|
|
objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
catch
|
|
{
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
private DataTable ToDataTable<T>(IList<T> data)
|
|
{
|
|
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
|
|
DataTable table = new DataTable();
|
|
for (int i = 0; i < props.Count; i++)
|
|
{
|
|
PropertyDescriptor prop = props[i];
|
|
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
|
|
}
|
|
object[] values = new object[props.Count];
|
|
foreach (T item in data)
|
|
{
|
|
for (int i = 0; i < values.Length; i++)
|
|
values[i] = props[i].GetValue(item) ?? DBNull.Value;
|
|
table.Rows.Add(values);
|
|
}
|
|
return table;
|
|
}
|
|
#endregion
|
|
|
|
public string getTipologia(string tipologia)
|
|
{
|
|
switch (tipologia)
|
|
{
|
|
case "U":
|
|
return "Immobili d'uso abitativo";
|
|
case "I":
|
|
return "Immobili d'investimento";
|
|
case "S":
|
|
return "Immobili strumentali";
|
|
case "NS":
|
|
return "Finalità non specificata";
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public ColorPDF getColor(string tipologia)
|
|
{
|
|
|
|
switch (tipologia)
|
|
{
|
|
case "Immobili d'uso abitativo":
|
|
return new ColorPDF(207, 220, 210);
|
|
case "Immobili d'investimento":
|
|
return new ColorPDF(115, 152, 109);
|
|
case "Immobili strumentali":
|
|
return new ColorPDF(167, 192, 168);
|
|
case "Finalità non specificata":
|
|
return new ColorPDF(245, 245, 220);
|
|
case "<B>Patrimonio finanziario Fideuram</B>":
|
|
return new ColorPDF(174, 150, 81);
|
|
case "<B>Patrimonio finanziario altri Istituti</B>":
|
|
return new ColorPDF(215, 206, 169);
|
|
default:
|
|
return new ColorPDF(255, 255, 255);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public class DatiPatrimonioGenerali
|
|
{
|
|
public decimal finanziarioFideuram { get; set; }
|
|
public decimal finanziarioTerzi { get; set; }
|
|
public decimal immobiliare { get; set; }
|
|
public decimal totale { get; set; }
|
|
public decimal pesoFideuram { get; set; }
|
|
public decimal pesoTerzi { get; set; }
|
|
public decimal pesoImmobiliare { get; set; }
|
|
public decimal totaleFinanziario { get; set; }
|
|
}
|
|
|
|
public class DettaglioPatrimonioImmobiliare
|
|
{
|
|
public string codFinalita { get; set; }
|
|
public decimal totale { get; set; }
|
|
public decimal peso { get; set; }
|
|
public string ordine { get; set; }
|
|
}
|
|
|
|
public class Patrimonio
|
|
{
|
|
public string Descrizione { get; set; }
|
|
public string Valore { get; set; }
|
|
public string Peso { get; set; }
|
|
public decimal Percentuale { get; set; }
|
|
public decimal NuovoPercentuale { get; set; }
|
|
public string TipologiaPatrimonio { get; set; }
|
|
}
|
|
|
|
public class PatrimonioFinanziario
|
|
{
|
|
public string Banca { get; set; }
|
|
public string AssetClassID { get; set; }
|
|
public string AssetClassName { get; set; }
|
|
public decimal Controvalore { get; set; }
|
|
public decimal Percentuale { get; set; }
|
|
public decimal NuovoPercentuale { get; set; }
|
|
public decimal PatrimonioFinanziarioCTV { get; set; }
|
|
public string Ordinamento { get; set; }
|
|
}
|
|
|
|
public class PatrimonioFooter
|
|
{
|
|
public string Descrizione { get; set; }
|
|
public string Valore { get; set; }
|
|
public string Peso { get; set; }
|
|
}
|
|
|
|
public class Torta
|
|
{
|
|
public string indice { get; set; }
|
|
public string tipologia { get; set; }
|
|
public string peso { get; set; }
|
|
public int ordine { get; set; }
|
|
}
|
|
|
|
}
|