From b48ca152d5b0961d29ac853266740934e39aab68 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 10 Jan 2025 16:47:52 -0700 Subject: [PATCH] =?UTF-8?q?--=200=20Dej=C3=B3=20de=20pedir=20autorizacion?= =?UTF-8?q?=20de=20aplicacion=20de=20anticipos.=20-=20poner=20bit=C3=A1cor?= =?UTF-8?q?a=20de=20autorizaci=C3=B3n.=20-=20una=20vez=20aplicado=20se=20p?= =?UTF-8?q?one=20estatus=20de=20bloqueado.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/Clientes.aspx.vb | 48 +++++++++++++++++++++++++++++-- Ventas/PVCobranza.aspx.vb | 59 +++++++++++++++++++++++++++++++++++---- 2 files changed, 98 insertions(+), 9 deletions(-) diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index e76f786b1..377e3e8d9 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -10764,17 +10764,34 @@ Partial Class Clientes Dim CveIE As Integer = GvRow.DataKey("CveIE").ToEntero() If CveVenta > 0 OrElse CveIE > 0 Then + Dim Actualizo As Boolean = False + Using ObjVentas As New ClsVentas If GvRow.DataKey("Tipo").Contiene("NC", "Ant") Then If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, True) Then Alert("El anticipo se autorizó correctamente") + Actualizo = True End If ElseIf GvRow.DataKey("Tipo").Contiene("IxC") Then If ObjVentas.UpdateIxCAnticipoAutorizado(CveIE, True) Then Alert("El anticipo se autorizó correctamente") + Actualizo = True End If End If End Using + + If Actualizo Then + Dim ObjEventoBitacora As New ClsOIEventos + If ObjEventoBitacora.AddEventoBitacora($"El folio '{GvRow.DataKey("Folio")}' ha sido autorizado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, CveCliente, -1, -1, -1, -1, -1) Then + GvEB.DataSource = ObjEventoBitacora.DtResultados + End If + ObjEventoBitacora.Dispose() + GvEB.DataBind() + + UPEventoBitacora.Update() + CargaEventoBitacora() + End If + End If CargaAnticipos() @@ -10783,13 +10800,38 @@ Partial Class Clientes Protected Sub LnkCancelarAnticipo_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) Dim CveVenta As Integer = GvRow.DataKey("CveVenta").ToEntero() - If CveVenta > 0 Then + Dim CveIE As Integer = GvRow.DataKey("CveIE").ToEntero() + + If CveVenta > 0 OrElse CveIE > 0 Then + Dim Actualizo As Boolean = False Using ObjVentas As New ClsVentas - If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, False) Then - Alert("El anticipo se desautorizó correctamente") + If GvRow.DataKey("Tipo").Contiene("NC", "Ant") Then + If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, False) Then + Alert("El anticipo se desautorizó correctamente") + Actualizo = True + End If + ElseIf GvRow.DataKey("Tipo").Contiene("IxC") Then + If ObjVentas.UpdateIxCAnticipoAutorizado(CveIE, False) Then + Alert("El anticipo se desautorizó correctamente") + Actualizo = True + End If End If End Using CargaAnticipos() + + If Actualizo Then + Dim ObjEventoBitacora As New ClsOIEventos + If ObjEventoBitacora.AddEventoBitacora($"El folio '{GvRow.DataKey("Folio")}' ha sido bloqueado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, CveCliente, -1, -1, -1, -1, -1) Then + GvEB.DataSource = ObjEventoBitacora.DtResultados + End If + ObjEventoBitacora.Dispose() + GvEB.DataBind() + + UPEventoBitacora.Update() + CargaEventoBitacora() + End If + + End If End Sub End Class diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index 6f7ec4a57..bb70f086f 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -589,11 +589,11 @@ Partial Class Ventas_PVCobranza Dim CveVentaRemision As Integer = -1 Dim DbRowVenta As DataRow = Nothing - Dim ObjVentas As New ClsVentas - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then - DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("") + Dim ObjVtaRemision As New ClsVentas + If ObjVtaRemision.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then + DbRowVenta = ObjVtaRemision.DtResultados.Copy().FiltroPrimero("") End If - ObjVentas.Dispose() + ObjVtaRemision.Dispose() If DbRowVenta IsNot Nothing Then Dim VentaActual As New Venta(UsuarioActual) @@ -634,6 +634,7 @@ Partial Class Ventas_PVCobranza Dim ObjIE As New ClsBancos(ObjVentas2.IniciaTransacSQL()) Dim ObjConta As New ClsContabilidad(ObjVentas2.IniciaTransacSQL()) Dim ObjClientes As New ClsClientes(ObjVentas2.IniciaTransacSQL()) + Dim ObjOIEventos As New ClsOIEventos(ObjVentas2.IniciaTransacSQL()) Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing Dim respNC As Modelos.Factura.MMensajeFactura = Nothing @@ -660,6 +661,14 @@ Partial Class Ventas_PVCobranza If respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then PagoAplicado += respFactura.Factura.DtAnticiposAplicados.SUM("Importe") SaldoPendiente = SaldoPendiente - PagoAplicado + + For Each RowAnt As DataRow In respFactura.Factura.DtAnticiposAplicados.Rows + If Not ActualizaAnticipos(RowAnt("CveIE").ToString().ToEntero(), RowAnt("CveVenta").ToString().ToEntero(), RowAnt("Tipo").ToString(), RowAnt("Folio").ToString(), ObjVentas2, ObjOIEventos) Then + MsgError = "Ocurrió un error al actualizar los anticipos" + Exit For + End If + Next + End If End If @@ -682,6 +691,14 @@ Partial Class Ventas_PVCobranza Else PagoAplicado += respNC.Factura.Total SaldoPendiente = SaldoPendiente - PagoAplicado + + For Each RowAnt As DataRow In respNC.Factura.DtAnticiposAplicados.Rows + If Not ActualizaAnticipos(RowAnt("CveIE").ToString().ToEntero(), RowAnt("CveVenta").ToString().ToEntero(), RowAnt("Tipo").ToString(), RowAnt("Folio").ToString(), ObjVentas2, ObjOIEventos) Then + MsgError = "Ocurrió un error al actualizar los anticipos" + Exit For + End If + Next + End If Else MsgError = "Ocurrió un error al generar la nota de crédito" @@ -884,6 +901,31 @@ Partial Class Ventas_PVCobranza End Sub + Private Function ActualizaAnticipos(CveIE As Integer, CveVenta As Integer, Tipo As String, Folio As String, ByRef ObjVentas As ClsVentas, ByRef ObjEventoBitacora As ClsOIEventos) As Boolean + Dim Retorno As Boolean = True + + If CveVenta > 0 OrElse CveIE > 0 Then + Dim Actualizo As Boolean = False + If Tipo.Contiene("NC", "Ant") Then + If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, False) Then + Alert("El anticipo se desautorizó correctamente") + Actualizo = True + End If + ElseIf Tipo.Contiene("IxC") Then + If ObjVentas.UpdateIxCAnticipoAutorizado(CveIE, False) Then + Alert("El anticipo se desautorizó correctamente") + Actualizo = True + End If + End If + + If Actualizo Then + Retorno = ObjEventoBitacora.AddEventoBitacora($"El folio '{Folio}' ha sido bloqueado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveIE, -1, CveCliente, -1, -1, -1, -1, -1, CveVenta:=CveVenta) + End If + End If + + Return Retorno + End Function + Private Sub LimpiarDatos() PnlContado.Visible = False TxtImporteEfectivo.Text = "" @@ -1017,6 +1059,7 @@ Partial Class Ventas_PVCobranza DtAnticipos.Columns.Add("Fecha", GetType(DateTime)) DtAnticipos.Columns.Add("TipoCambioPago", GetType(Decimal)) DtAnticipos.Columns.Add("Folio", GetType(String)) + DtAnticipos.Columns.Add("Tipo", GetType(String)) For Each GvRow As GridViewRow In GVAnticipos.Rows If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then @@ -1033,8 +1076,9 @@ Partial Class Ventas_PVCobranza Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() Dim Folio = GvRow.DataKey("Folio") + Dim Tipo = GvRow.DataKey("Tipo") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio) + DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) End If Next @@ -1173,6 +1217,7 @@ Partial Class Ventas_PVCobranza DtAnticipos.Columns.Add("Fecha", GetType(DateTime)) DtAnticipos.Columns.Add("TipoCambioPago", GetType(Decimal)) DtAnticipos.Columns.Add("Folio", GetType(String)) + DtAnticipos.Columns.Add("Tipo", GetType(String)) For Each GvRow As GridViewRow In GVAnticipos.Rows If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then @@ -1189,8 +1234,10 @@ Partial Class Ventas_PVCobranza Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() Dim Folio = GvRow.DataKey("Folio") + Dim Tipo = GvRow.DataKey("Tipo") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio) + + DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) End If Next