--Cancelacion parcial de remison cuando se tiene varios boletos
This commit is contained in:
@@ -1666,6 +1666,7 @@ Namespace Modelos
|
||||
Me.RetIVA = Me.DtDetalle.SUMD("ImporteRetIVA")
|
||||
Me.RetISR = Me.DtDetalle.SUMD("ImporteRetISR")
|
||||
Me.IEPS = Me.DtDetalle.SUMD("ImporteIEPS")
|
||||
Me.Descuento = Me.DtDetalle.SUMD("Descuento")
|
||||
|
||||
Me.Total = Me.SubTotal + Me.IVA + Me.IEPS - (Me.RetIVA + Me.RetISR)
|
||||
End Sub
|
||||
@@ -5226,6 +5227,69 @@ Namespace Modelos
|
||||
Public Function CancelarBoleto(CveViajePasajero As Integer) As Boolean
|
||||
Dim TieneError As Boolean = False
|
||||
|
||||
If Me.CveVenta > 0 Then
|
||||
Dim ObjVentas As New ClsVentas()
|
||||
Dim ObjTransportes As New ClsTransportes(ObjVentas.IniciaTransacSQL())
|
||||
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
||||
|
||||
Try
|
||||
Dim Row As DataRow = Me.DtDetalle.Select($"CveViajePasajero={CveViajePasajero}").FirstOrDefault()
|
||||
If Row IsNot Nothing Then
|
||||
Row("Descuento") = Row("Total")
|
||||
Row("Obs") = "CANCELADO"
|
||||
|
||||
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
If Not ObjTransportes.UpdateViajesPasajeros(CveViajePasajero, Activar:=False, Estatus:=False) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
Me.CalculaTotales()
|
||||
|
||||
If Not TieneError Then
|
||||
If Not ObjVentas.UpdateVentas(Me.SubTotal, Me.Descuento, Me.IVA, Me.IEPS, Me.Total, Me.CveMoneda, Me.TipoCambio, Me.Fecha, Me.Observaciones,
|
||||
UsuarioActual.CveEmpresa, Me.CveVenta, TipoDocto:=Me.TipoDocto) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
TieneError = Not RegenerarPrePolizas(ObjVentas.IniciaTransacSQL())
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
If ObjConta.ValidacionesPrePoliza(-1, UsuarioActual, Opcion:=2, CveVenta:=CveVenta) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
If ObjConta.ValorPolizaDescuadre = 2 Then
|
||||
TieneError = True
|
||||
Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
GuardaLog(ex.ToString())
|
||||
End Try
|
||||
|
||||
If TieneError Then
|
||||
ObjVentas.RollBack()
|
||||
Else
|
||||
ObjVentas.Commit()
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
ObjTransportes.Dispose()
|
||||
ObjConta.Dispose()
|
||||
|
||||
End If
|
||||
|
||||
Return Not TieneError
|
||||
End Function
|
||||
|
||||
|
||||
@@ -235,9 +235,6 @@ Partial Class Boletos
|
||||
Obs = dr("Observaciones").ToString
|
||||
|
||||
Dim CveViajePasajero = ObjTransporte.AddViajesPasajeros(CveViaje, CveDestinoOrigen, CveDestinoFinal, Importe, Asiento.ToEntero, Nombre, Visa, Celular, Sexo, Obs, UsuarioActual.CveUsuario, UsuarioActual.CveVendedor)
|
||||
If Not CveViajePasajero > 1 Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If CveViajePasajero < 1 Then
|
||||
TieneError = True
|
||||
@@ -433,14 +430,18 @@ Partial Class Boletos
|
||||
ObjFactura.SetSubProyectoMatriz()
|
||||
|
||||
For Each Dr As DataRow In DtPasajeros.Rows
|
||||
Dim Obs = Dr("Nombre").ToString
|
||||
Dim Obs = Dr("Observaciones").ToString
|
||||
Dim Importe = Dr("Importe").ToString.ToDecimal()
|
||||
|
||||
If Importe <= 0 Then
|
||||
Retorno.Mensajes.Add("El importe debe ser mayor a 0")
|
||||
Return Retorno
|
||||
End If
|
||||
|
||||
ObjFactura.AgregarPS(CvePSBoleto, 1, Importe, 0, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=0, CveViajePasajero:=Dr("CveViajePasajero").ToString().ToEntero())
|
||||
If Not ObjFactura.AgregarPS(CvePSBoleto, 1, Importe, 0, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=0, CveViajePasajero:=Dr("CveViajePasajero").ToString().ToEntero()) Then
|
||||
Retorno.Mensajes.Add("No se pudo agregar el producto")
|
||||
Return Retorno
|
||||
End If
|
||||
Next
|
||||
|
||||
ObjFactura.CalculaTotales()
|
||||
@@ -459,7 +460,6 @@ Partial Class Boletos
|
||||
Retorno.Mensajes.Add("No se pudo generar la factura")
|
||||
End If
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
@@ -77,35 +77,40 @@ Partial Class ListadoBoletos
|
||||
|
||||
Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim CveViajePasajero As String = GvRow.DataKey("CveViajePasajero")
|
||||
Dim CveViajePasajero As Integer = GvRow.DataKey("CveViajePasajero").ToEntero()
|
||||
Dim Estatus As String = GvRow.DataKey("Estatus")
|
||||
Dim cambiarEstatus As Boolean = Not Estatus.ToBool
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
|
||||
Dim cambiarEstatus As Boolean = Not Estatus.ToBool
|
||||
|
||||
|
||||
Dim TieneError As Boolean = False
|
||||
Try
|
||||
Dim DtRem As DataTable = Nothing
|
||||
If ObjTransportes.GetRemisionBoleto(CveViajePasajero.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
DtRem = ObjTransportes.DtResultados.Copy()
|
||||
|
||||
Dim ObjTran As New ClsTransportes
|
||||
If ObjTran.GetRemisionBoleto(CveViajePasajero.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
DtRem = ObjTran.DtResultados.Copy()
|
||||
End If
|
||||
ObjTran.Dispose()
|
||||
|
||||
If DtRem IsNot Nothing Then
|
||||
If DtRem.Rows.Count > 0 Then
|
||||
Dim CveVenta As Integer = DtRem.Rows(0)("CveVenta").ToString().ToEntero()
|
||||
Dim BoletosVigentes As Integer = DtRem.Rows(0)("BoletosVigentes").ToString().ToEntero()
|
||||
|
||||
If CveVenta > 0 Then
|
||||
Dim ObjRem As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False)
|
||||
|
||||
If ObjRem.DtDetalle.Rows.Count > 0 Then
|
||||
'SI SOLO TIENE UNA PARTIDA CANCELAR LA REMISION
|
||||
If ObjRem.DtDetalle.Rows.Count = 1 Then
|
||||
Dim RespCancelacion = ObjRem.CancelarFactura(False, ValidarSAT:=False, CancelarBoletos:=True)
|
||||
If ObjRem.DtDetalle.Rows.Count = 1 OrElse BoletosVigentes <= 1 Then
|
||||
Dim RespCancelacion = ObjRem.CancelarFactura(False, ValidarSAT:=False, CancelarBoletos:=True, ListaRemisionesCancelar:=New List(Of Integer))
|
||||
If RespCancelacion IsNot Nothing Then
|
||||
TieneError = RespCancelacion.HuboError
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = Not ObjRem.CancelarBoleto(CveViajePasajero.ToEntero)
|
||||
TieneError = Not ObjRem.CancelarBoleto(CveViajePasajero)
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
@@ -114,23 +119,24 @@ Partial Class ListadoBoletos
|
||||
End If
|
||||
Else
|
||||
'SI NO TIENE VENTA, SOLO CANCELAR EL BOLETO
|
||||
If Not ObjTransportes.UpdateViajesPasajeros(CveViajePasajero.ToEntero, Activar:=cambiarEstatus, Estatus:=cambiarEstatus) Then
|
||||
Dim ObjTran2 As New ClsTransportes
|
||||
If Not ObjTran2.UpdateViajesPasajeros(CveViajePasajero, Activar:=cambiarEstatus, Estatus:=cambiarEstatus) Then
|
||||
TieneError = True
|
||||
End If
|
||||
ObjTran2.Dispose()
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
GuardaLog(ex.ToString())
|
||||
Finally
|
||||
If TieneError Then
|
||||
Alert($"El boleto ha sido cancelado correctamente.")
|
||||
Alert($"Ocurrió un error al cancelar el boleto.", TipoMensaje.MsgError)
|
||||
Else
|
||||
Alert($"Ocurrió un error al cancelar el boleto.")
|
||||
End If
|
||||
ObjTransportes.Dispose()
|
||||
Alert($"El boleto ha sido cancelado correctamente.")
|
||||
End If
|
||||
|
||||
CargaDatos()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user