756 lines
39 KiB
C#

using System;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using Consulenza.ReportCommon;
using Consulenza.ReportWriter.Business.CHART_PDF;
using System.Collections.Generic;
using Consulenza.ReportWriter.Business.Entity;
using System.Linq;
using ceTe.DynamicPDF;
namespace Consulenza.ReportWriter.Manager.Section.Unica
{
/// <summary>
/// S18.PatrimonioFideuramMacroCategorieProdotto idSezione = 61
/// </summary>
public class S18 : Entity.Section
{
public S18(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S18", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
}
}
/// <summary>
///
/// </summary>
protected override sealed void Draw()
{
var dati = GetDataSet();
var listaOggettiDaRipetere = new List<ObjectPDF> { new SpacePDF(20) };
AddElement(new RepeaterPDF(listaOggettiDaRipetere));
AddElement(new SpacePDF(20));
if (dati.Tables["patrimonio"].Rows.Count > 0)
{
if (presenzaGrafico())
{
#region Testo introduttivo grafico
var testoGrafico = !isControvalore() ?
Helper.ReplaceVariables(GetText().Rows[0]["testo1"].ToString(), base.EnvironmentFacade.ReportEnvironment) :
Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), base.EnvironmentFacade.ReportEnvironment);
AddElement(new FormattedTextAreaPDF(testoGrafico, EnvironmentFacade.RendererFacade.XLeftLimit) { TextHorizontalAlign = TextAlign.Justify, FontSize = 7 });
AddElement(new SpacePDF(15));
#endregion
#region Tabella patrimonio
var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["patrimonio"])
{
Style = Style.ConsulenzaUnica,
Header = false,
Footer = false,
AlternateRow = false,
RowHeight = 25
};
tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 190, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty));
tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
AddElement(tabellaPatrimonio);
AddElement(new SpacePDF(20));
#endregion
if (Convert.ToDecimal(dati.Tables["patrimonio"].Rows[0]["valore"]) > 0)
{
#region Grafico a barre
if (presenzaGrafico())
{
//AddElement(new FormattedTextAreaPDF("Macro categoria", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
//AddElement(new FormattedTextAreaPDF(string.Format("Distribuzione ({0})", isControvalore() ? "€" : "%"), EnvironmentFacade.RendererFacade.XLeftLimit + 110, 410) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
//AddElement(new SpacePDF(17));
var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 110, 1F)
{
HeightSingleBar = 25,
Width = 400,
// LabelFormatAxisY = isControvalore() ? FormatType.Decimale2ConSeparatore : FormatType.Decimale2ConSeparatore,
LabelFormatAxisY = isControvalore() ? FormatType.Intero : FormatType.Decimale2,
ShowLineAxisX = true,
PageBreak = true,
DinamicFloatXEtichettaLateraleBarra = true,
MinorGridAxisY = true,
RemoveWhiteSpaceToTheRightAxisX = true,
RemoveWhiteSpaceBetweenChartAndAxisX = true,
MarginAxisY = 0,
MarginAxisYFromTop = 0
};
graficoBarre.Headers.Add(new FormattedTextAreaPDF("Macro categoria", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
graficoBarre.Headers.Add(new FormattedTextAreaPDF(string.Format("Distribuzione ({0})", isControvalore() ? "€" : "%"), EnvironmentFacade.RendererFacade.XLeftLimit + 110, 410) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
var serieCollezione = new List<Serie> { new Serie { Name = "MacroCategoria", Border = true } };
foreach (DataRow item in dati.Tables["macrocategorie"].Rows)
{
serieCollezione[0].Points.Add(new Point
{
ShowLabelAxisY = true,
LabelAxisY = isControvalore() ? Helper.FormatCurrency(item["Controvalore"].ToString()) : Helper.FormatDecimal(item["Percentuale"].ToString(), 2),
FontSizeLabelAxisY = 7,
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
Value = isControvalore() ? (Convert.ToDouble(item["Controvalore"].ToString()) == 0 ? 0.01 : Convert.ToDouble(item["Controvalore"].ToString())) : Convert.ToDouble(item["Percentuale"].ToString()) == 0 ? 0.01 : Convert.ToDouble(item["Percentuale"].ToString()), // Convert.ToDouble(Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
ShowLabelAxisX = true,
LabelAxisX = item["MacroCategoria"].ToString(),
FontSizeLabelAxisX = 7,
FontBoldLabelAxisY = false
});
}
graficoBarre.SeriesCollection = serieCollezione;
AddElement(graficoBarre);
#endregion
}
#region Nota del PatrimonioCasa
if (GetNote1().Length > 0)
{
AddElement(new SpacePDF(20));
AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = TextAlign.Justify });
}
#endregion
AddElement(new SpacePDF(20));
}
}
}
if (dati.Tables["prodottiPerMacroCategoria"].Rows.Count > 0)
{
if (presenzaTabella())
{
#region Testo introduttivo tabella prodotti
var testoTabellaProdotti = Helper.ReplaceVariables(GetText().Rows[0]["testo4"].ToString(), EnvironmentFacade.ReportEnvironment);
AddElement(new FormattedTextAreaPDF(testoTabellaProdotti, EnvironmentFacade.RendererFacade.XLeftLimit) { TextHorizontalAlign = TextAlign.Justify, FontSize = 7 });
AddElement(new SpacePDF(15));
#endregion
#region Tabella Prodotti X MacroCategoria
var tabellaProdottiPerMacroCategoria = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["prodottiPerMacroCategoria"], dati.Tables["prodottiPerMacroCategoriaFooter"])
{
Style = Style.ConsulenzaUnica,
Header = true,
Footer = true,
AlternateRow = false,
ShowSeparationLines = true,
HeaderHeight = 30,
HeaderMargin = 2,
ShowFooterSeparationLines = true
};
#region Columns e FooterColumns
// Modifica per Saving Map
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("SavingMap", 15, HorizontalAlignmentType.Sinistra, false, false, 6, ColumnType.Immagine, "SavingMap", string.Empty) { DeltaYContent = 8, ScaleColumnTypeImage = 0.50F });
// Fine Modifica
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Immagine", 15 + 210, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, string.Empty, "Prodotto") { HeaderFontSize = 7, HeaderFontBold = true, DeltaYContent = 4, PaddingLeft = 6 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Categoria", 120, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Categoria", "Categoria") { HeaderFontSize = 7, FontSize = 7 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Controvalore", 100, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "ControvaloreString", "Controvalore <br>attuale (€)") { HeaderFontSize = 7, FontSize = 7, HeaderPaddingRight = 10, HeaderPaddingLeft=15, PaddingRight = 4 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Peso", 60, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Peso", "Peso (%)") { HeaderFontSize = 7, FontSize = 7, PaddingRight = 4 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Patrimonio", 360, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { HeaderFontSize = 7, FontSize = 7 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Controvalore", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { HeaderFontSize = 7, FontSize = 7, PaddingRight = 4 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Peso", 60, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { HeaderFontSize = 7, FontSize = 7 });
int j = 0;
foreach (DataRow r in dati.Tables["prodottiPerMacroCategoria"].Rows)
{
tabellaProdottiPerMacroCategoria.Cells[4, j].HorizontalAlignment = HorizontalAlignmentType.Destra;
tabellaProdottiPerMacroCategoria.Cells[3, j].HorizontalAlignment = HorizontalAlignmentType.Destra;
j++;
}
#endregion
#region Cells
int i = 0;
foreach (DataRow row in dati.Tables["prodottiPerMacroCategoria"].Rows)
{
if (Convert.ToBoolean(row["IsTotal"]))
{
// Sfondo grigio per la riga identificata con IsTotal [quella di intestazione di macro categoria]
for (int c = 0; c < tabellaProdottiPerMacroCategoria.Columns.Count; c++)
{
tabellaProdottiPerMacroCategoria.Cells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
}
var listaOggetti = new List<ObjectPDF>
{
new RectanglePDF(8, 8, new ColorPDF(row["CodiceHexMacroCategoria"].ToString())){DeltaY = 1},
new FormattedTextAreaPDF
{
Text = row["Prodotto"].ToString(),
FontBold = true,
FontColor = ColorPDF.Nero,
DeltaX = 12F,
FontSize = 7,
},
};
tabellaProdottiPerMacroCategoria.Cells[1, i].ValueObjectList.AddRange(listaOggetti);
tabellaProdottiPerMacroCategoria.Cells[3, i].Value = Helper.FormatCurrency(row["ControvaloreString"].ToString());
}
else
{
var listaOggetti = new List<ObjectPDF>
{
new RectanglePDF(8, 8, ColorPDF.GetBy_AreaBisogno(row["CodiceAreaBisogno"].ToString())){DeltaY = 3},
new FormattedTextAreaPDF
{
Text = new AreaBisogno(row["CodiceAreaBisogno"].ToString()).Abbreviazione,
FontBold = true,
FontColor = ColorPDF.Bianco,
DeltaX = 2F,
FontSize = 7,
DeltaY = 1
},
new FormattedTextAreaPDF
{
Text = row["Prodotto"].ToString(),
FontBold = false,
FontColor = ColorPDF.Nero,
DeltaX = 12F,
FontSize=7,
DeltaY = 1
}
};
if (row[3].ToString() == "GP ET - Liquidità" && Convert.ToDecimal(row["Controvalore"]) < 0)
{
listaOggetti = new List<ObjectPDF>
{
new RectanglePDF(8, 8, ColorPDF.Bianco){DeltaY = 3},
new FormattedTextAreaPDF
{
Text = "-",
FontBold = true,
FontColor = ColorPDF.Nero,
DeltaX = 2F,
FontSize = 7,
DeltaY = 1
},
new FormattedTextAreaPDF
{
Text = row["Prodotto"].ToString(),
FontBold = false,
FontColor = ColorPDF.Nero,
DeltaX = 12F,
FontSize=7,
DeltaY = 1
}
};
}
tabellaProdottiPerMacroCategoria.Cells[1, i].ValueObjectList.AddRange(listaOggetti);
}
i++;
}
#endregion
i = 0;
foreach (DataRow row in dati.Tables["prodottiPerMacroCategoriaFooter"].Rows)
{
if (Convert.ToBoolean(row["IsTotal"]))
{
// Sfondo grigio per la riga identificata con IsTotal [quella di intestazione di macro categoria]
for (int c = 0; c < tabellaProdottiPerMacroCategoria.FooterColumns.Count; c++)
{
tabellaProdottiPerMacroCategoria.FooterCells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
tabellaProdottiPerMacroCategoria.FooterCells[c, i].FontBold = true;
}
}
i++;
}
AddElement(tabellaProdottiPerMacroCategoria);
#region Nota del PatrimonioCasa
if (GetNote2().Length > 0)
{
AddElement(new SpacePDF(10));
AddElement(new FormattedTextAreaPDF(GetNote2(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = TextAlign.Justify });
}
#endregion
#endregion
}
}
}
/// <summary>
/// Recupera i dati necessari alla Section restituendo un DataTable.
/// </summary>
/// <returns></returns>
protected sealed override DataTable GetDataTable()
{
return null;
}
/// <summary>
/// Recupera i dati necessari alla Section restituendo un DataSet.
/// </summary>
/// <returns></returns>
protected sealed override DataSet GetDataSet()
{
var ds = new DataSet();
ds.Tables.Add(new DataTable("patrimonio"));
ds.Tables.Add(new DataTable("macrocategorie"));
ds.Tables.Add(new DataTable("prodotti"));
ds.Tables.Add(new DataTable("prodottiPerMacroCategoriaFooter"));
string asteriscoNota1 = GetNote1().Length > 0 ? "*" : "";
string asteriscoNota2 = presenzaGrafico() ? (GetNote2().Length > 0 ? asteriscoNota1 + "*" : "") : (GetNote2().Length > 0 ? "*" : "");
//const string stringReplaceIfZero = " ";
const string stringReplaceIf = "0,00";
var patrimonioCasa = datiSeiUnico.patrimonioUnit().patrimonioCasa;
var dataMacroCategoria = patrimonioCasa.macroCategoria;
var dataDettaglioProdotti = patrimonioCasa.dettaglioProdotti.dettaglioProdotti;
var displayInfo = datiSeiUnico.displayInfos().macroCategoriaDisplayInfos;
var patrimoniofooter = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale;
#region Patrimonio casa
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
var testoPatrimonio = string.Format("Patrimonio {0} (€){1}", Helper.ReplaceVariables("$/Banca/$", EnvironmentFacade.ReportEnvironment), asteriscoNota1);
ds.Tables["patrimonio"].Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.CASA_TOTALEPOSITIVO.ToString()));
#endregion
#region Prodotti
ds.Tables["prodotti"].Columns.Add(new DataColumn("CodiceAreaBisogno", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("OrdinamentoMacroCategoria", typeof(int)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("CodiceHexMacroCategoria", typeof(string)));
// Modifica per Saving Map
ds.Tables["prodotti"].Columns.Add(new DataColumn("SavingMap", typeof(string)));
// Fine Modifica
ds.Tables["prodotti"].Columns.Add(new DataColumn("Prodotto", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("MacroCategoria", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("Categoria", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("ControvaloreString", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("Peso", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("FontBold", typeof(bool)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("ReplaceIfZero", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("CanLastRow", typeof(bool)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("IsTotal", typeof(bool)));
foreach (var itemMacroCategoria in dataMacroCategoria.distribuzionePerProdotti.listaProdotti)
{
if (itemMacroCategoria.rappresentabile)
{
var itemPosizione = dataDettaglioProdotti.FirstOrDefault(o => o.chiavePosizionePortafoglio.Equals(itemMacroCategoria.chiaveAggregazione));
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(dataMacroCategoria.distribuzione.elencoSlice.FirstOrDefault(l => l.descrizione.Equals(itemMacroCategoria.listaSlice[0].descrizione)).codice)).value;
var rowProdotti = ds.Tables["prodotti"].NewRow();
rowProdotti["CodiceAreaBisogno"] = itemPosizione.area;
rowProdotti["OrdinamentoMacroCategoria"] = mapDisplayInfo.order;
rowProdotti["CodiceHexMacroCategoria"] = mapDisplayInfo.fill;
rowProdotti["Prodotto"] = itemPosizione.prodotto.nomeProdotto;
rowProdotti["MacroCategoria"] = itemMacroCategoria.listaSlice[0].descrizione;
rowProdotti["Categoria"] = itemPosizione.prodotto.alberatura.livello2;
rowProdotti["Controvalore"] = Helper.FormatCurrency(itemMacroCategoria.listaSlice[0].ctv.ToString());
rowProdotti["ControvaloreString"] = Helper.FormatCurrency(itemMacroCategoria.listaSlice[0].ctv.ToString());
rowProdotti["Peso"] = Helper.FormatDecimal((itemMacroCategoria.listaSlice[0].pesoCC * 100).ToString(), 2);
if (itemPosizione.prodotto.codIsin == null)
rowProdotti["Peso"] = "-";
else
{
if ((itemPosizione.prodotto.codIsin.Equals("EURO10000007")
||itemPosizione.prodotto.codIsin.Equals("EURO20000005")
|| itemPosizione.prodotto.codIsin.Equals("EURO00000009")) && itemMacroCategoria.listaSlice[0].ctv<0)
{
rowProdotti["Peso"] = "-";
}
}
// Modifica per Saving Map
if (itemPosizione.prodotto.savingMap)
//if (itemPosizione.prodotto.nomeProdotto.Substring(0, 2).ToUpper() == "FV")
rowProdotti["SavingMap"] = "SavingMap.png";
else
rowProdotti["SavingMap"] = "";
// Fine Modifica
rowProdotti["FontBold"] = false;
rowProdotti["ReplaceIfZero"] = stringReplaceIf;
rowProdotti["CanLastRow"] = true;
rowProdotti["IsTotal"] = false;
ds.Tables["prodotti"].Rows.Add(rowProdotti);
}
}
#endregion
#region Macro Categorie di Prodotto
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("MacroCategoria", typeof(string)));
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Red", typeof(int)));
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Green", typeof(int)));
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Blue", typeof(int)));
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Percentuale", typeof(string)));
ds.Tables["macrocategorie"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
foreach (var valore in from c in displayInfo
join l in dataMacroCategoria.distribuzione.elencoSlice on c.key equals l.codice
orderby c.value.order
select new
{
l.descrizione,
new ColorPDF(c.value.fill).Red,
new ColorPDF(c.value.fill).Green,
new ColorPDF(c.value.fill).Blue,
l.ctvCC,
l.pesoCC
})
{
ds.Tables["macrocategorie"].Rows.Add(
valore.descrizione,
valore.Red,
valore.Green,
valore.Blue,
valore.ctvCC,
Helper.FormatDecimal((valore.pesoCC * 100).ToString(), 2)
);
}
#endregion
#region Prodotti raggruppati per MacroCategoria
DataTable dtcat = ds.Tables["prodotti"].Clone();
dtcat.TableName = "prodottiPerMacroCategoria";
ds.Tables.Add(dtcat);
var viewMacroCategoria = new DataView(ds.Tables["prodotti"]) { Sort = "OrdinamentoMacroCategoria" };
var dtMacroCategoria = viewMacroCategoria.ToTable(true, "MacroCategoria", "OrdinamentoMacroCategoria", "CodiceHexMacroCategoria");
var macroCategoria = string.Empty;
#region Prodotti delle Risorse Finanziarie
foreach (DataRow rowMacroCategoria in dtMacroCategoria.Rows)
{
macroCategoria = rowMacroCategoria["MacroCategoria"].ToString();
// subset di prodotti filtrati per Area
var dt = ds.Tables["prodotti"].Select("MacroCategoria='" + macroCategoria + "'").OrderByDescending(r => r.Field<decimal>("Controvalore")).CopyToDataTable();
#region riga con background grigio di intestazione per ogni macrocategoria
DataRow rowProdottiPerMacroCategoria = ds.Tables["prodottiPerMacroCategoria"].NewRow();
rowProdottiPerMacroCategoria["CodiceHexMacroCategoria"] = rowMacroCategoria["CodiceHexMacroCategoria"];
rowProdottiPerMacroCategoria["Prodotto"] = rowMacroCategoria["MacroCategoria"];
decimal controvalore = dataMacroCategoria.distribuzione.elencoSlice.FirstOrDefault(o => o.descrizione.Equals(rowMacroCategoria["MacroCategoria"].ToString())).ctvCC;
decimal var = dataMacroCategoria.distribuzione.elencoSlice.FirstOrDefault(o => o.descrizione.Equals(rowMacroCategoria["MacroCategoria"].ToString())).pesoCC * 100;
rowProdottiPerMacroCategoria["Controvalore"] = controvalore;
rowProdottiPerMacroCategoria["ControvaloreString"] = Helper.FormatCurrency(controvalore.ToString()) + (macroCategoria.Equals("Gestito finanziario") ? asteriscoNota2 : "");
rowProdottiPerMacroCategoria["Peso"] = Helper.FormatDecimal(var.ToString(), 2);
rowProdottiPerMacroCategoria["FontBold"] = true;
//rowProdottiPerMacroCategoria["ReplaceIfZero"] = stringReplaceIf;
rowProdottiPerMacroCategoria["CanLastRow"] = false;
rowProdottiPerMacroCategoria["IsTotal"] = true;
ds.Tables["prodottiPerMacroCategoria"].Rows.Add(rowProdottiPerMacroCategoria);
#endregion
// I prodotti della dtProdotti vengono mergiati sulla dtProdottiPerArea
ds.Tables["prodottiPerMacroCategoria"].Merge(dt);
}
#endregion
#region Footer Prodotti raggruppati per MacroCategoria
ds.Tables["prodottiPerMacroCategoriaFooter"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
ds.Tables["prodottiPerMacroCategoriaFooter"].Columns.Add(new DataColumn("Controvalore", typeof(string)));
ds.Tables["prodottiPerMacroCategoriaFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
ds.Tables["prodottiPerMacroCategoriaFooter"].Columns.Add(new DataColumn("FontBold", typeof(bool)));
ds.Tables["prodottiPerMacroCategoriaFooter"].Columns.Add(new DataColumn("CanLastRow", typeof(bool)));
ds.Tables["prodottiPerMacroCategoriaFooter"].Columns.Add(new DataColumn("IsTotal", typeof(bool)));
if (datiSeiUnico.CASA_CCN != 0 || datiSeiUnico.CASA_OC != 0)
{
ds.Tables["prodottiPerMacroCategoriaFooter"].Rows.Add(
"Totale risorse finanziarie",
Helper.FormatCurrency(datiSeiUnico.CASA_SUBTOTALE.ToString()) + asteriscoNota2,
Helper.FormatDecimal((dataMacroCategoria.distribuzione.pesoCCTot * 100).ToString(), 2),
true,
true,
true
);
#region Operazioni in corso
if (datiSeiUnico.CASA_OC != 0)
{
var rowProdottiPatrimonioAltro = ds.Tables["prodottiPerMacroCategoriaFooter"].NewRow();
rowProdottiPatrimonioAltro["Patrimonio"] = "Operazioni in corso";
rowProdottiPatrimonioAltro["Controvalore"] = Helper.FormatCurrency(datiSeiUnico.CASA_OC.ToString());
rowProdottiPatrimonioAltro["Peso"] = "";
rowProdottiPatrimonioAltro["FontBold"] = false;
rowProdottiPatrimonioAltro["CanLastRow"] = false;
rowProdottiPatrimonioAltro["IsTotal"] = false;
ds.Tables["prodottiPerMacroCategoriaFooter"].Rows.Add(rowProdottiPatrimonioAltro);
}
#endregion
#region CCN
foreach (var item in dataDettaglioProdotti.Where(x => x.area.ToLower().Equals("cc") && x.ctv != 0).OrderBy(x => x.area).ThenByDescending(x => x.ctv))
{
var rowProdottiPatrimonioAltro = ds.Tables["prodottiPerMacroCategoriaFooter"].NewRow();
rowProdottiPatrimonioAltro["Patrimonio"] = item.prodotto.nomeProdotto;
rowProdottiPatrimonioAltro["Controvalore"] = Helper.FormatCurrency(item.ctv.ToString());
rowProdottiPatrimonioAltro["Peso"] = " ";
rowProdottiPatrimonioAltro["FontBold"] = false;
rowProdottiPatrimonioAltro["CanLastRow"] = false;
rowProdottiPatrimonioAltro["IsTotal"] = false;
ds.Tables["prodottiPerMacroCategoriaFooter"].Rows.Add(rowProdottiPatrimonioAltro);
}
#endregion
}
// 20181010 AC
//decimal CASA_TOTALE = datiSeiUnico.CASA_TOTALE - datiSeiUnico.CASA_GPELIGO;
decimal CASA_TOTALE = datiSeiUnico.CASA_TOTALE - datiSeiUnico.CASA_GPELIGO - datiSeiUnico.CASA_TUOFOGLIO;
//--20181010 AC
ds.Tables["prodottiPerMacroCategoriaFooter"].Rows.Add(
Helper.ReplaceVariables("Patrimonio $/Banca/$", base.EnvironmentFacade.ReportEnvironment),
Helper.FormatCurrency(CASA_TOTALE.ToString()) + asteriscoNota2,
datiSeiUnico.CASA_CCN != 0 || datiSeiUnico.CASA_OC != 0 ?
" " :
Helper.FormatDecimal((dataMacroCategoria.distribuzione.pesoCCTot * 100).ToString(), 2),
true,
true,
true);
#endregion
#endregion
return ds;
}
public virtual bool isControvalore()
{
return !GetOption<Opzione3>().Valore;
}
public virtual bool presenzaContocorrenteInMonterio() { return true; }
public virtual bool presenzaGrafico()
{
return GetOption<Opzione4_1>().Valore;
}
public virtual bool presenzaTabella()
{
return GetOption<Opzione4_2>().Valore;
}
/// <summary>
/// Recupera la nota dinamica
/// </summary>
/// <param name="nota"></param>
/// <returns></returns>
public virtual string GetNote1()
{
string nota = "";
string token = "";
var macroCategoria = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroCategoria;
decimal CCN_CASA = datiSeiUnico.CASA_CCN;
decimal GPELIGOFONDI_CASA = datiSeiUnico.CASA_GPELIGOFONDI;
decimal GPELIGTITOLI_CASA = datiSeiUnico.CASA_GPELIGTITOLI;
// 20181009 AC
decimal TUOFOGLIO_CASA = datiSeiUnico.CASA_TUOFOGLIO;
//--20181009 AC
// 20181009 AC
//if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || TUOFOGLIO_CASA != 0)
//--20181009 AC
{
nota += token + "Il controvalore esclude il saldo negativo";
token = " ";
if (CCN_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("dei conti correnti ({0} €)", CCN_CASA);
token = ", ";
}
// 20181009 AC
if (TUOFOGLIO_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante Il Mio Foglio ({0} €)", TUOFOGLIO_CASA);
token = ", ";
}
//--20181009 AC
if (GPELIGOFONDI_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Fondi ({0} €)", GPELIGOFONDI_CASA);
token = ", ";
}
if (GPELIGTITOLI_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Titoli ({0} €)", GPELIGTITOLI_CASA);
token = ", ";
}
//token = " ";
//if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0)
//{
// nota += token + "del patrimonio $/Banca/$";
// token = ", ";
//}
nota += ".";
token = " ";
}
decimal GC = (presenzaContocorrenteInMonterio() ? macroCategoria.distribuzione.coverageCC : macroCategoria.distribuzione.coverage) * 100;
decimal OC_CASA = datiSeiUnico.CASA_OC;
decimal CC_CASA = presenzaContocorrenteInMonterio()? 0: datiSeiUnico.CASA_CC;
decimal PNR_CASA = macroCategoria.distribuzione.totaleNonRappr;
if (GC < 100)
{
nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro categorie pari a {0}", GC);
token = ": ";
if (PNR_CASA != 0 || CC_CASA != 0 || OC_CASA != 0)
{
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 = ", ";
}
}
}
nota += ".";
token = " ";
}
nota = !nota.Equals("") ? "(*) " + nota : nota;
return datiSeiUnico.FormatBanca(nota);
}
public virtual string GetNote2()
{
string nota = "";
string token = "";
string asterisco = "";
decimal GPELIGOFONDI_CASA = datiSeiUnico.CASA_GPELIGOFONDI;
decimal GPELIGTITOLI_CASA = datiSeiUnico.CASA_GPELIGTITOLI;
// 20181010 AC
decimal TUOFOGLIO_CASA = datiSeiUnico.CASA_TUOFOGLIO;
//--20181010 AC
// 20181010 AC
//if if (GPELIGTITOLI_CASA != 0 || GPELIGOFONDI_CASA != 0)
if (GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || TUOFOGLIO_CASA != 0)
//--20181010 AC
{
asterisco = GetNote1().Length > 0 && presenzaGrafico() ? "**" : "*";
nota += token + "("+ asterisco +") Il controvalore esclude il saldo negativo";
token = " ";
// 20181010 AC
if (TUOFOGLIO_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante Il Mio Foglio ({0} €)", TUOFOGLIO_CASA);
token = ", ";
}
//--20181010 AC
if (GPELIGOFONDI_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Fondi ({0} €)", GPELIGOFONDI_CASA);
token = ", ";
}
if (GPELIGTITOLI_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Titoli ({0} €)", GPELIGTITOLI_CASA);
token = ", ";
}
nota += ".";
}
return nota;
}
}
}