From 71db745a935866e594d33a305b49b046d9b925c2 Mon Sep 17 00:00:00 2001 From: MLopez Date: Mon, 12 Dec 2022 19:39:53 -0700 Subject: [PATCH] E172 Rep Indicador, CxC recuperado, links en encabezado tabla, grafica recuperado, normalizar moneda en MXN --- General/RepIndicadorResumen.aspx | 44 +++++++++++++---- General/RepIndicadorResumen.aspx.vb | 76 ++++++++++++++++++++++------- 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/General/RepIndicadorResumen.aspx b/General/RepIndicadorResumen.aspx index bec0e8afd..7d48d762e 100644 --- a/General/RepIndicadorResumen.aspx +++ b/General/RepIndicadorResumen.aspx @@ -353,8 +353,9 @@ CssClass="table table-striped table-advance table-hover ScrollAD Widthall " ShowHeader="True" EmptyDataText="No se encontraron resultados." ShowHeaderWhenEmpty="true" AutoGenerateColumns="False" AllowPaging="False" ShowFooter="False"> - - + + + @@ -368,7 +369,7 @@
- Cuentas por cobrar - Gráfica + Cuentas por cobrar - Gráfica Saldo(MXN)
@@ -384,8 +385,32 @@
+ +
+ + +
+
+ + Cuentas por cobrar - Gráfica Recuperado +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
- + @@ -448,10 +473,10 @@ tooltip: { formatter: function (tooltip) { var tooltiptext = tooltip.defaultFormatter.call(this, tooltip); - var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(/(.*?)<\/b>/.exec(tooltiptext)); - if (isCurrency) { - tooltiptext = tooltiptext.replace("", "$"); - } + //var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(/(.*?)<\/b>/.exec(tooltiptext)); + //if (isCurrency) { + // tooltiptext = tooltiptext.replace("", "$"); + //} tooltiptext = tooltiptext.replace("", " " + this.point.unit + ""); console.log(tooltiptext) return tooltiptext @@ -496,8 +521,7 @@ $('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], type: 'pie', data: customAccessor(json["CxP192"]) }] }) $('#' + "chartdiv_cxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP"]) }] }) $('#' + "chartdiv_cxpa").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxPA"]) }] }) - $('#' + "chartdiv_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }] }) - + $('#' + "chartdiv_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }, { type: 'line', keys: ['name', 'y', 'ignore', 'unit'], data: customAccessor(json["CxCR"]) }] }) //AmCharts.makeChart("chartdiv_cxp192", { ...chartconfig, dataProvider: json["CxP192"] }); // Compras x Producto ProveedorClasificacion 192 //AmCharts.makeChart("chartdiv_cxc", { ...chartconfig, dataProvider: json["CxC"] }); // Cuentas por Cobrar x Cliente diff --git a/General/RepIndicadorResumen.aspx.vb b/General/RepIndicadorResumen.aspx.vb index 5e2c0a4ce..8e6e21eef 100644 --- a/General/RepIndicadorResumen.aspx.vb +++ b/General/RepIndicadorResumen.aspx.vb @@ -83,11 +83,11 @@ Partial Class General_RepIndicadorResumen Dim FechaCorte As String = $"31/12/{Now.Year}" - If ObjMovtos.GetCxC(TxtFechaI.Text, TxtFechaF.Text, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, "-1", UsuarioActual.CveEmpresa, 5, -1, 1, -1, - "-1", "-1", "-1", FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then - ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC" - GvCxC.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable - End If + 'If ObjMovtos.GetCxC(TxtFechaI.Text, TxtFechaF.Text, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, "-1", UsuarioActual.CveEmpresa, 5, -1, 1, -1, + ' "-1", "-1", "-1", FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + ' ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC" + ' GvCxC.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable + 'End If 'If ObjMovtos.GetCxP(MinFecha, TxtFechaF.Text, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, 5, -1, 1, ' FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then @@ -105,6 +105,9 @@ Partial Class General_RepIndicadorResumen 'Gastos (Compras acreedores) ObjCitrus.DTSetResultados.Tables(2).DefaultView.Sort = "Moneda,SubTotal DESC" GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(2).DefaultView.ToTable + 'Cuentas x Cobrar + ObjCitrus.DTSetResultados.Tables(3).DefaultView.Sort = "SaldoMN DESC" + GvCxC.DataSource = ObjCitrus.DTSetResultados.Tables(3).DefaultView.ToTable End If ObjVentas.Dispose() @@ -119,6 +122,7 @@ Partial Class General_RepIndicadorResumen GvCxC.DataBind() If GvCxC.DataSource IsNot Nothing Then GvCxC.HeaderRow.Cells(1).Text = "Saldo" + GvCxC.HeaderRow.Cells(2).Text = "Recuperado" End If 'Mostrar gráficos solo si hay datos en su respectiva tabla @@ -139,8 +143,10 @@ Partial Class General_RepIndicadorResumen End If If GvCxC.Rows.Count > 0 Then UPGraficaCxC.Visible = True + 'UPGraficaCxCRec.Visible = True Else UPGraficaCxC.Visible = False + 'UPGraficaCxCRec.Visible = False End If If GvCxP.Rows.Count > 0 Then UPGraficaCxP.Visible = True @@ -155,7 +161,7 @@ Partial Class General_RepIndicadorResumen 'Si no había datos en ninguna tabla no cargar función de gráficos If (GvVxP.Rows.Count = 0 AndAlso GvComprasAcreed.Rows.Count = 0 AndAlso GvCxP192.Rows.Count = 0 AndAlso GvCxC.Rows.Count = 0 AndAlso GvCxP.Rows.Count = 0) Then Exit Sub - GraficasPastel() + Graficas() 'GraficasBarras() End Sub Protected Sub GvVxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvVxP.RowDataBound @@ -191,13 +197,14 @@ Partial Class General_RepIndicadorResumen End If End If End Sub - Protected Sub GvCCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound + Protected Sub GvCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("Orden") = "" Then + If e.Row.DBCampo("CveCliente") = "" Then e.Row.CssClass = "Totales" + ' End If + ' 'TODO: Sería mejor usar la Abreviatura de la tabla, pero habría que extender PA_Comp_RepCxP para incluir la columna Abreviatura + e.Row.Cells(0).Text = $"Total {GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Moneda").ToString}" End If - 'TODO: Sería mejor usar la Abreviatura de la tabla, pero habría que extender PA_Comp_RepCxP para incluir la columna Abreviatura - ' e.Row.Cells(2).Text = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" End If End Sub Private Sub CreaDataTableColor() @@ -273,9 +280,9 @@ Partial Class General_RepIndicadorResumen DtColor.Rows.Add(RowColor) End Sub - Private Sub GraficasPastel() + Private Sub Graficas() - Dim DtVxP, DtCxP192, DtCxP, DtCxPA, DtCxC As New DataTable + Dim DtVxP, DtCxP192, DtCxP, DtCxPA, DtCxC, DtCxCR As New DataTable Dim RowColorIndex As Integer = 0 'Ventas x Producto @@ -412,7 +419,7 @@ Partial Class General_RepIndicadorResumen }) Dim query_cxpa = top_cxpa.Union(group_resto_cxpa) - 'Cuentas por cobrar x Cliente + 'Cuentas por cobrar x Cliente -- Saldo DtCxC.Reset() DtCxC.Columns.Add("Texto") DtCxC.Columns.Add("Valor") @@ -420,13 +427,13 @@ Partial Class General_RepIndicadorResumen DtCxC.Columns.Add("Unidad") RowColorIndex = 0 For Each Dr As DataRow In GvCxC.DataSource.Rows - If Not Dr("Orden").ToString = "" Then + If Not Dr("CveCliente").ToString = "" Then Dim Row As DataRow = Nothing Row = DtCxC.NewRow() - Row("Texto") = Dr("GPO").ToString - Row("Valor") = Dr("Saldo").ToString.FormatoNumero + Row("Texto") = Dr("RazonSocial").ToString + Row("Valor") = Dr("SaldoMN").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" DtCxC.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then @@ -443,12 +450,45 @@ Partial Class General_RepIndicadorResumen .Unidad = "MXN" }) Dim query_cxc = top_cxc.Union(group_resto_cxc) + + 'Cuentas por cobrar x Cliente -- Recuperado + DtCxCR.Reset() + DtCxCR.Columns.Add("Texto") + DtCxCR.Columns.Add("Valor") + DtCxCR.Columns.Add("Color") + DtCxCR.Columns.Add("Unidad") + RowColorIndex = 0 + For Each Dr As DataRow In GvCxC.DataSource.Rows + If Not Dr("CveCliente").ToString = "" Then + Dim Row As DataRow = Nothing + Row = DtCxCR.NewRow() + Row("Texto") = Dr("RazonSocial").ToString + Row("Valor") = Dr("RecuperadoMN").ToString.FormatoNumero + Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString + Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + DtCxCR.Rows.Add(Row) + RowColorIndex += 1 + If RowColorIndex = 17 Then + RowColorIndex = 0 + End If + End If + Next + Dim top_cxcr = From s In DtCxCR.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim resto_cxcr = From s In DtCxCR.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim group_resto_cxcr = resto_cxcr.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { + .Texto = "Otros", + .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), + .Color = "#000000", + .Unidad = "MXN" + }) + Dim query_cxcr = top_cxcr.Union(group_resto_cxcr) + 'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CxC.Rows)) 'TODO: Indicadores x Proveedor -- Determinar qué poner en la gráfica con E172 'Serializar datos agrupándolos por su respectivo DataTable, todos en un solo JSON - Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxP192 = query_cxp192, .CxP = query_cxp, .CxPA = query_cxpa, .CxC = query_cxc}) + Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxP192 = query_cxp192, .CxP = query_cxp, .CxPA = query_cxpa, .CxC = query_cxc, .CxCR = query_cxcr}) 'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxC = New String() {}}) 'Alert(json) RegistraScript($"CargaGraficas({json})", "sdkp24223")