From 9805d316d62fa875dcdc814477c9f7f5ace2d6cc Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 21 Jan 2025 18:51:03 -0700 Subject: [PATCH 1/7] =?UTF-8?q?--=20correcci=C3=B3n=20de=20manejo=20de=20s?= =?UTF-8?q?aldos=20de=20venta,=20al=20aplicar=20anticipos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/Ventas.aspx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 4d0b8ade4..f81ffbb31 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1824,6 +1824,7 @@ + @@ -10847,7 +10848,7 @@ if (totalAnt > SaldoCompra) { txt.value = FormatoNumero(importe - (totalAnt - SaldoCompra), 2); - $get('HdnVentaSaldo').value = 0.00; + //$get('HdnVentaSaldo').value = 0.00; alert("El Importe no debe de exceder a el saldo"); } @@ -10857,7 +10858,7 @@ } else { - $get('HdnVentaSaldo').value = parseFloat(SaldoCompra) + parseFloat(txt.value); + //$get('HdnVentaSaldo').value = parseFloat(SaldoCompra) + parseFloat(txt.value); txt.value = ""; } @@ -10908,7 +10909,7 @@ $("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2)); - $get('HdnVentaSaldo').value = Total - FnSumaValoresAnt(); + //$get('HdnVentaSaldo').value = Total - FnSumaValoresAnt(); } function FnSumaValoresAnt() { From a8eca285834ecd46ce7846b08c17df978bc73b7d Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 22 Jan 2025 11:29:17 -0700 Subject: [PATCH 2/7] =?UTF-8?q?--=20consideraci=C3=B3n,=20para=20que=20no?= =?UTF-8?q?=20se=20elimine=20el=20movimiento=20relacionado=20cuando=20es?= =?UTF-8?q?=20el=20concepto=20de=20=20"devoluci=C3=B3n=20de=20pr=C3=A9stam?= =?UTF-8?q?o=20de=20proveedor"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inventarios/EntradasSalidas.aspx.vb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 9008ba63a..d6672b5bb 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -950,12 +950,19 @@ Partial Class Inventarios_EntradasSalidas TieneRelacionado = Mov.TieneRelacionado ConceptoRelacionado = Mov.ConceptoRelacionado + 'sino existe el movimiento If (DdlConcepto.Items.FindByValue(Mov.CveConcepto.ToString()) Is Nothing) Then Dim dr As DataRow = GlobalDTInvConceptos.FiltroPrimero(String.Format("CveConcepto = {0}", Mov.CveConcepto)) DdlConcepto.Items.Insert(0, New ListItem(dr("Concepto").ToString, dr("CveConcepto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString End If + 'CONDICION ESPECIAL , PARA DEVOLUCIONES DE PRÉSTAMO PROVEEDORES + If DdlConcepto.SelectedValue = "29" Then + TieneRelacionado = 0 'PARA ELIMINACIÓN NO LO RELACIONE, EN EL PA, TAMBIEN SE TIENE ESTA CONSIDERACIÓN + CveMovimientoRelacionado = 0 + End If + DdlConcepto.SelectedValue = Mov.CveConcepto.ToString ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty) From 93fa9eb3b3920949acfc1ea0157eb2929e62ab34 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 23 Jan 2025 12:12:44 -0700 Subject: [PATCH 3/7] =?UTF-8?q?--=20manejo=20de=20transacci=C3=B3n=20en=20?= =?UTF-8?q?cancelar=20ventas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/Modelos.vb | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 419794e5b..a80ace836 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5664,9 +5664,9 @@ Namespace Modelos ''' ''' ''' - Public Function CancelarFactura(RealizarDevolucionAlmacen As Integer, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing, Optional CveMotivoCancelacion As Integer = -1, Optional Motivo As String = "", Optional ValidarSAT As Boolean = True, Optional CveEstadoCancelacion As Integer = 0, Optional CancelarBoletos As Boolean = False, Optional ForzarDevolucion As Boolean = False, Optional CancelacionPagos As OpcionesCancelacionPagos = OpcionesCancelacionPagos.SinPagos, Optional CveEstatusFacturaAsignado As Integer = -1, Optional CvePACEspecifico As Integer = -1) As MCancelacionVentaMensaje + Public Function CancelarFactura(RealizarDevolucionAlmacen As Integer, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing, Optional CveMotivoCancelacion As Integer = -1, Optional Motivo As String = "", Optional ValidarSAT As Boolean = True, Optional CveEstadoCancelacion As Integer = 0, Optional CancelarBoletos As Boolean = False, Optional ForzarDevolucion As Boolean = False, Optional CancelacionPagos As OpcionesCancelacionPagos = OpcionesCancelacionPagos.SinPagos, Optional CveEstatusFacturaAsignado As Integer = -1, Optional CvePACEspecifico As Integer = -1, Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing) As MCancelacionVentaMensaje 'Comprobante emitido con errores sin relación - Return CancelarVenta(Me, Me.UsuarioActual, RealizarDevolucionAlmacen:=RealizarDevolucionAlmacen, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveMotivoCancelacion:=CveMotivoCancelacion, MotivoCancelacion:=Motivo, CveEstadoCancelacion:=CveEstadoCancelacion, CancelarBoletos:=CancelarBoletos, ForzarDevolucion:=ForzarDevolucion, CancelacionPagos:=CancelacionPagos, CveEstatusFacturaAsignado:=CveEstatusFacturaAsignado, ValidarSAT:=ValidarSAT, CvePACEspecifico:=CvePACEspecifico) + Return CancelarVenta(Me, Me.UsuarioActual, RealizarDevolucionAlmacen:=RealizarDevolucionAlmacen, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveMotivoCancelacion:=CveMotivoCancelacion, MotivoCancelacion:=Motivo, CveEstadoCancelacion:=CveEstadoCancelacion, CancelarBoletos:=CancelarBoletos, ForzarDevolucion:=ForzarDevolucion, CancelacionPagos:=CancelacionPagos, CveEstatusFacturaAsignado:=CveEstatusFacturaAsignado, ValidarSAT:=ValidarSAT, CvePACEspecifico:=CvePACEspecifico, TransaccionCompartida:=TransaccionCompartida) End Function Private Function CancelarVenta(ObjFactura As Modelos.Factura, UsuarioActual As Usuario, Optional EsRefacturacion As Boolean = False, Optional RealizarDevolucionAlmacen As Integer = 0, @@ -5674,7 +5674,8 @@ Namespace Modelos Optional AcuseCancelacion As String = "", Optional CveMotivoCancelacion As Integer = -1, Optional MotivoCancelacion As String = "", Optional FolioSustitucion As String = "", Optional ValidarSAT As Boolean = True, Optional CveEstadoCancelacion As Integer = 0, Optional CancelarBoletos As Boolean = False, Optional ForzarDevolucion As Boolean = False, Optional CancelacionPagos As OpcionesCancelacionPagos = OpcionesCancelacionPagos.SinPagos, - Optional CvePACEspecifico As Integer = -1) As MCancelacionVentaMensaje + Optional CvePACEspecifico As Integer = -1, + Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing) As MCancelacionVentaMensaje Dim Retorno As New MCancelacionVentaMensaje() Dim ErrorList As New List(Of String) @@ -6136,7 +6137,12 @@ Namespace Modelos End If End If - Dim ObjVentas As New ClsVentas() : ObjVentas.IniciaTransacSQL() + Dim ObjVentas As ClsVentas = Nothing + If TransaccionCompartida IsNot Nothing Then + ObjVentas = New ClsVentas(TransaccionCompartida) + Else + ObjVentas = New ClsVentas() : ObjVentas.IniciaTransacSQL() + End If Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL()) Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL()) @@ -6925,7 +6931,7 @@ Namespace Modelos OnError("Ocurrió un error al cancelar el documento", ex) Finally If Not ErrorCancelar Then - ObjVentas.Commit() + If TransaccionCompartida Is Nothing Then ObjVentas.Commit() If CveEstatus = 5 Then Dim MensajeAlert As New StringBuilder @@ -6954,12 +6960,14 @@ Namespace Modelos End If Retorno.CveEstatus = CveEstatus + If TransaccionCompartida Is Nothing Then + ObjVentas.Dispose() + ObjBancos.Dispose() + ObjInventario.Dispose() + ObjContrato.Dispose() + ObjConta.Dispose() + End If - ObjVentas.Dispose() - ObjBancos.Dispose() - ObjInventario.Dispose() - ObjContrato.Dispose() - ObjConta.Dispose() End Try Return Retorno From bf9d9fa2e9e0080c0333a3fc7663a1cd8fde30e9 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 23 Jan 2025 13:54:43 -0700 Subject: [PATCH 4/7] -- cobranza en cobro de caja --- App_Code/ClsPaginas.vb | 164 ++++++++++++++++---------------- Ventas/PVCobranza.aspx | 179 +++++++++++++++++++++++++++++------ Ventas/PVCobranza.aspx.vb | 191 ++++++++++++++++++++++++++++---------- 3 files changed, 376 insertions(+), 158 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 927c851d8..79de443d4 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -9544,91 +9544,93 @@ Public Class ClsPaginas If Pago.TipoPago = "NC" Then ConPreP.CveConcepto = If(VentaActual.CveMoneda <> 1, 301, 251) 'movimiento de pago cliente - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, Pago.ImportePagoVenta, ConPreP.CveConcepto, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada, Contabilizable:=Contabilizable) Then ErrorMovtos = True - 'movimiento de pago cliente Complementaria - If Not ErrorMovtos AndAlso VentaActual.CveMoneda > 1 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, (ImporteME * TCValuacionVenta - ImporteME).RoundSQL, CveConceptoContableComplementaria, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada, Contabilizable:=Contabilizable) Then ErrorMovtos = True - End If - - If Pago.AplicaTraslado Then - 'si tiene iva y su proporcion - If Not ErrorMovtos AndAlso VentaActual.IVA <> 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.IVA).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 13, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - - 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe - If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 61, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + If Pago.ImportePagoVenta > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, Pago.ImportePagoVenta, ConPreP.CveConcepto, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada, Contabilizable:=Contabilizable) Then ErrorMovtos = True + 'movimiento de pago cliente Complementaria + If Not ErrorMovtos AndAlso VentaActual.CveMoneda > 1 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, (ImporteME * TCValuacionVenta - ImporteME).RoundSQL, CveConceptoContableComplementaria, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada, Contabilizable:=Contabilizable) Then ErrorMovtos = True End If - 'si tiene RET IVA y su proporcion - If Not ErrorMovtos AndAlso VentaActual.RetIVA > 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.RetIVA).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 8, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe - If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 62, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + + + If Pago.AplicaTraslado Then + 'si tiene iva y su proporcion + If Not ErrorMovtos AndAlso VentaActual.IVA <> 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.IVA).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 13, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + + 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe + If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 61, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If + 'si tiene RET IVA y su proporcion + If Not ErrorMovtos AndAlso VentaActual.RetIVA > 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.RetIVA).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 8, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe + If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 62, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If + 'si tiene Ret ISR y su proporcion + If Not ErrorMovtos AndAlso VentaActual.RetISR > 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.RetISR).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 9, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe + If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 63, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If + 'si tiene IEPS y su proporcion + If Not ErrorMovtos AndAlso VentaActual.IEPS > 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.IEPS).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + Dim Ret As New ConceptosRetenciones + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 38, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe + If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * Pago.TCPago).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 39, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If End If - 'si tiene Ret ISR y su proporcion - If Not ErrorMovtos AndAlso VentaActual.RetISR > 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.RetISR).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 9, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe - If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 63, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - End If - 'si tiene IEPS y su proporcion - If Not ErrorMovtos AndAlso VentaActual.IEPS > 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.IEPS).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - Dim Ret As New ConceptosRetenciones - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 38, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - 'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe - If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * Pago.TCPago).RoundSQL - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 39, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + + If Pago.AplicaConceptoImpuestoPendiente Then + 'si tiene iva y su proporcion + If Not ErrorMovtos AndAlso VentaActual.IVA <> 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.IVA).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 13, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If + 'si tiene RET IVA y su proporcion + If Not ErrorMovtos AndAlso VentaActual.RetIVA > 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.RetIVA).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 8, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If + 'si tiene Ret ISR y su proporcion + If Not ErrorMovtos AndAlso VentaActual.RetISR > 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.RetISR).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 9, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If + 'si tiene IEPS y su proporcion + If Not ErrorMovtos AndAlso VentaActual.IEPS > 0 Then + ImporteMovimiento = (PorcentajePago * VentaActual.IEPS).RoundSQL + ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL + If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento + Dim Ret As New ConceptosRetenciones + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 38, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True + End If End If End If - - If Pago.AplicaConceptoImpuestoPendiente Then - 'si tiene iva y su proporcion - If Not ErrorMovtos AndAlso VentaActual.IVA <> 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.IVA).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 13, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - End If - 'si tiene RET IVA y su proporcion - If Not ErrorMovtos AndAlso VentaActual.RetIVA > 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.RetIVA).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 8, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - End If - 'si tiene Ret ISR y su proporcion - If Not ErrorMovtos AndAlso VentaActual.RetISR > 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.RetISR).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 9, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - End If - 'si tiene IEPS y su proporcion - If Not ErrorMovtos AndAlso VentaActual.IEPS > 0 Then - ImporteMovimiento = (PorcentajePago * VentaActual.IEPS).RoundSQL - ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL - If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento - Dim Ret As New ConceptosRetenciones - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 38, VentaActual.SerieFolio, Concepto, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True - End If - End If - 'concepto pago If Pago.TipoPago = "B" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' B A N C O S Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia) diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index bc0f38ce9..8283ede90 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -328,7 +328,7 @@ + DataKeyNames="CveVenta,CveCliente,TipoDocto,Saldo,AtencionA,CveFormaPago33,SerieFolio,CondicionesPago,PlazoCobranza"> <%----%> @@ -441,6 +441,7 @@
+
@@ -461,11 +462,11 @@
- +
-
- +
+
@@ -590,8 +591,22 @@
- + + +
+
+ + + + +
+
+ +
+ +
+
+
@@ -623,39 +638,45 @@
-
-
- -
- $ - - + + +
+
+ +
+ $ + + -
- -
- $ - - -
-
- -
- $ - - -
+
+ +
+ $ + + +
+
+ +
+ $ + + +
+
-
+ +
+ +
@@ -1305,6 +1326,105 @@
diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 347d43d1e..a91e1ca02 100644 --- a/OS/OrdenesServicios.aspx.vb +++ b/OS/OrdenesServicios.aspx.vb @@ -6,6 +6,7 @@ Imports System.IO Imports System.Data Imports System.Data.SqlClient Imports APP_Code_CSharp +Imports MoreLinq.Extensions Partial Class OS_OrdenesServicios Inherits ClsPaginas @@ -578,8 +579,6 @@ Partial Class OS_OrdenesServicios 'GvPS.DataSource = TmpDT 'GvPS.DataBind() - - Dim tmpTipoEstatus As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("TipoEstatus", $" CveEstatusOrdenServicio = {DdlEstatusOS.SelectedValue}").ToEntero Select Case tmpTipoEstatus Case 1, 2, 3 @@ -732,6 +731,10 @@ Partial Class OS_OrdenesServicios If TipoEstatus.Contiene(1, 2, 3) Then LnkAccionesMaterialUtilizado.Visible = True End If + If TipoEstatus.Contiene(4) Then 'finalizada + BtnCancelarRemision.Visible = True + End If + Else Alert("La Orden de Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) BtnGuardar.Enabled = False @@ -3530,7 +3533,7 @@ Partial Class OS_OrdenesServicios If PU > 0 Then CountDetalles = CountDetalles + 1 Else - Alert($"Prodcuto {CodigoPS} con precio unitario en cero.", TipoMensaje.MsgAdvertencia) + Alert($"Producto {CodigoPS} con precio unitario en cero.", TipoMensaje.MsgAdvertencia) PuEnCero = True End If End If @@ -3552,7 +3555,7 @@ Partial Class OS_OrdenesServicios Return Respuesta End If - If ObjVentas.GetVenta(CvePedido, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then + If ObjVentas.GetVenta(CvePedido, UsuarioActual.CveEmpresa) Then Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Copy().Rows(0) CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero CveSubProyectoPedido = DbRowVenta("CveSubProyecto").ToString().ToEntero() @@ -3585,6 +3588,14 @@ Partial Class OS_OrdenesServicios TmpDTMat.Columns.Add("Lote", GetType(String)) TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date)) TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer)) + 'unificar en un solo producto, y generar las salidas a esa relación + + + Respuesta.CveVenta = -1 + Respuesta.SerieFolio = "" + Respuesta.dtdetalle = New DataTable + Alert("Remision sin detalles.", TipoMensaje.MsgAdvertencia) + Return Respuesta For Each GvRow As GridViewRow In GvMU.Rows @@ -3594,7 +3605,6 @@ Partial Class OS_OrdenesServicios Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal Dim Obs As String = GvRow.DataKey("Observaciones") - If CantidadRegistro > 0 Then If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then Dim drp As DataRow = TmpDTMat.NewRow @@ -3635,6 +3645,38 @@ Partial Class OS_OrdenesServicios End Function + Private Function AgrupadoProductos(gridView As GridView) As DataTable + ' Filtrar y agrupar las filas por clave3 y clave5 + Dim groupedData = From row As GridViewRow In gridView.Rows.Cast(Of GridViewRow)() + Where row.RowType = DataControlRowType.DataRow + Group row By + CvePS = gridView.DataKeys(row.RowIndex)("CvePS").ToString(), + CveUM = gridView.DataKeys(row.RowIndex)("CveUM").ToString() + Into Group + Select New With { + .CvePS = CvePS, + .CveUM = CveUM, + .ValorAcumulado = Group.Sum(Function(r) Convert.ToDecimal(r.Cells(5).Text)) + } + + ' Crear un nuevo DataTable para almacenar los resultados agrupados + Dim resultTable As New DataTable() + resultTable.Columns.Add("CvePS") + resultTable.Columns.Add("CveUM") + resultTable.Columns.Add("Cantidad", GetType(Decimal)) + + For Each item In groupedData + Dim newRow As DataRow = resultTable.NewRow() + newRow("CvePS") = item.CvePS + newRow("CveUM") = item.CveUM + newRow("Cantidad") = item.ValorAcumulado + resultTable.Rows.Add(newRow) + Next + + Return resultTable + End Function + + Friend Class RespuestaFacturacion Public Property CveVenta As Integer = -1 Public Property SerieFolio As String = "-1" @@ -3786,4 +3828,77 @@ Partial Class OS_OrdenesServicios End Try End Sub + + Private Sub CancelarRemision(CveVenta As Integer, CveAlmacenDevolucion As Integer, CvePedido As Integer) + + Dim LigaRedirigir As String = "" + + Dim ObjFacturaCancelacion As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=True, VerificaAlmacen:=True) + Try + Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing + Dim strMensaje As New StringBuilder() + If ObjFacturaCancelacion IsNot Nothing AndAlso ObjFacturaCancelacion.CveVenta > 0 Then + + Dim ListaRemisionesCancelar As New List(Of Integer) + ObjFacturaCancelacion.CveAlmacenDevolucion = CveAlmacenDevolucion + Dim CancelacionPagos = Modelos.OpcionesCancelacionPagos.SinPagos + + 'PARA GENERAR LA DEVOLUCION DE ALMACEN SIN ESPERAR LA ACEPTACION DEL SAT + Dim GenerarDevolucionAnticipada As Boolean = True + Dim CveEstadoCancelacion As Integer = 1 + Dim objos As New ClsOS + Dim ObjVenta As New ClsVentas(objos.IniciaTransacSQL) + + resp = ObjFacturaCancelacion.CancelarFactura(1, ListaRemisionesCancelar, CveMotivoCancelacion:=1, Motivo:="Corrección de material utilizado", CveEstadoCancelacion:=CveEstadoCancelacion, ForzarDevolucion:=GenerarDevolucionAnticipada, CancelacionPagos:=CancelacionPagos, TransaccionCompartida:=objos.IniciaTransacSQL) + + Dim HuboError As Boolean = False + If Not resp.HuboError Then + + If resp.CveEstatus = 12 Then + Dim cveoo As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", $" TipoEstatus = 3").ToEntero + If objos.UpdateOrdenesServiciosEstatus(cveoo, UsuarioActual.CveUsuario, CveOS) Then + 'retornar el estatus de la OS, + If Not ObjVenta.UpdateVentasDevolucionAlmacen(0, CvePedido) Then + HuboError = True + End If + Else + HuboError = True + End If + Else + 'si tiene pagos + HuboError = True + End If + Else + HuboError = True + End If + strMensaje.Append(resp.Mensaje) + If Not HuboError Then + objos.Commit() + Alert(strMensaje.ToString(), resp.TipoMensaje) + Else + objos.RollBack() + Alert(strMensaje.ToString(), resp.TipoMensaje) + End If + + objos.Dispose() + ObjVenta.Dispose() + Else + Alert("Ocurrió un error al generar la cancelación", TipoMensaje.MsgError) + End If + + Catch ex As Exception + OnError("Ocurrió un error al cancelar", ex) + End Try + ObjFacturaCancelacion.Dispose() + UpEstatus.Update() + + If Not String.IsNullOrEmpty(LigaRedirigir) Then + Response.Redirect(LigaRedirigir) + End If + + End Sub + + Protected Sub BtnCancelarRemision_Click(sender As Object, e As EventArgs) + CancelarRemision(CveVenta, 1, CvePedido) + End Sub End Class