--Correciones de generacion de remision

This commit is contained in:
2024-02-19 16:27:17 -07:00
parent 871266e601
commit 84f691f2c8
2 changed files with 97 additions and 50 deletions

View File

@@ -1274,7 +1274,7 @@ Namespace Modelos
ObjFactura.FechaEjecucion = DateTime.Today
ObjFactura.UsuarioCreo = UsuarioActual.Usuario
ObjFactura.CondicionesPago = 0
ObjFactura.TipoDocumento = "Factura"
ObjFactura.TipoDocumento = ObjFactura.TipodeComprobante
'Totales, Y se llena TmpDTImpuestos
'CLIENTE

View File

@@ -79,11 +79,13 @@ Partial Class Boletos
Dim ObjViaje As New ClsTransportes
If ObjContratos.GetContratos(CveViaje, UsuarioActual.CveEmpresa) Then
Contrato = ObjContratos.DtResultados
Contrato = ObjContratos.DtResultados.Copy()
If ObjContratos.DtResultados IsNot Nothing AndAlso ObjContratos.DtResultados.Rows.Count > 0 Then
TxtRuta.Text = Contrato.Rows(0)("SubProyecto").ToString
TxtFecha.Text = Contrato.Rows(0)("FechaInicial").ToString.ToDate.ToShortDateString
DtPasajeros = New DataTable
DtPasajeros.Columns.Add("CveViajePasajero", GetType(Integer))
DtPasajeros.Columns.Add("Numero", GetType(Integer))
DtPasajeros.Columns.Add("Nombre", GetType(String))
DtPasajeros.Columns.Add("Visa", GetType(String))
@@ -115,6 +117,9 @@ Partial Class Boletos
End If
End If
ObjContratos.Dispose()
ObjViaje.Dispose()
Else
ObjContratos.Dispose()
ObjViaje.Dispose()
@@ -122,8 +127,6 @@ Partial Class Boletos
Response.Redirect($"~/Transportes/RepContratos.aspx")
End If
ObjContratos.Dispose()
ObjViaje.Dispose()
'Boletos Vendidos
@@ -172,16 +175,16 @@ Partial Class Boletos
ImporteR = ObjDestinos.DtResultados.FiltroPrimeroValor("Importe").ToDecimal.RoundSQL
End If
If ImporteR > 0 Then
ViewState("Importe") = ImporteR
LbCostos.Text = $"El precio de su boleto es ${ImporteR.FormatoNumero}"
LbCostos.Visible = True
BtnAgregarPasajero.Visible = True
Else
ViewState("Importe") = 0
BtnAgregarPasajero.Visible = False
LbCostos.Visible = False
Alert("No se encontro una tarifa para estos destinos", TipoMensaje.MsgAdvertencia)
End If
ViewState("Importe") = ImporteR
LbCostos.Text = $"El precio de su boleto es ${ImporteR.FormatoNumero}"
LbCostos.Visible = True
BtnAgregarPasajero.Visible = True
Else
ViewState("Importe") = 0
BtnAgregarPasajero.Visible = False
LbCostos.Visible = False
Alert("No se encontro una tarifa para estos destinos", TipoMensaje.MsgAdvertencia)
End If
ObjDestinos.Dispose()
@@ -231,9 +234,18 @@ Partial Class Boletos
Sexo = dr("CveSexo").ToString.ToBool
Obs = dr("Observaciones").ToString
If ObjTransporte.AddViajesPasajeros(CveViaje, CveDestinoOrigen, CveDestinoFinal, Importe, Asiento.ToEntero, Nombre, Visa, Celular, Sexo, Obs, UsuarioActual.CveUsuario, UsuarioActual.CveVendedor) > 1 Then
ObjTransporte.Commit()
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
SbAlert.Append("Ocurrió un error al generar el viaje")
Exit For
End If
dr("CveViajePasajero") = CveViajePasajero
Next
@@ -245,8 +257,11 @@ Partial Class Boletos
TieneError = Retorno.TieneError
If Not TieneError Then
If Retorno.CveVenta > 0 AndAlso Not Retorno.TieneError Then
SbAlert.AppendFormat("{0}", Retorno.Mensajes(Retorno.Mensajes.Count - 1))
If Not Retorno.TieneError Then
If Retorno.CveVenta <= 0 Then
Retorno.TieneError = True
End If
Else
TieneError = True
SbAlert.Append("Ocurrió un error al generar la factura")
@@ -259,6 +274,12 @@ Partial Class Boletos
Else
TieneError = True
End If
Else
If Retorno.Mensajes IsNot Nothing AndAlso Retorno.Mensajes.Count > 0 Then
For Each Mensaje As String In Retorno.Mensajes
SbAlert.AppendFormat("{0} <br/>", Mensaje)
Next
End If
End If
Else
TieneError = True
@@ -278,19 +299,26 @@ Partial Class Boletos
ObjTransporte.RollBack()
ObjTransporte.Dispose()
Else
SbAlert.Append("El boleto se genero correctamente.")
DtPasajeros.Clear()
ObjTransporte.Commit()
ObjTransporte.Dispose()
DdlPartida.SelectedValueExist("-1")
DdlDestino.SelectedValueExist("-1")
SbAlert.Append("El boleto se genero correctamente.")
DtPasajeros.Clear()
GvB.DataSource = DtPasajeros
GvB.DataBind()
DdlPartida.SelectedIndex = -1
'DdlPartida.SelectedValueExist("-1")
DdlDestino.SelectedIndex = -1
'DdlDestino.SelectedValueExist("-1")
AsientoSeleccionado = ""
CargaDatos()
End If
Alert(SbAlert.ToString(), If(TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), ShowCloseButton:=False)
End Try
UpPanel.Update()
@@ -369,50 +397,69 @@ Partial Class Boletos
End Sub
Private Function CrearRemision(ByRef objTrans As ClsTransportes) As Modelos.Factura.MMensajeFactura
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
Dim Retorno As New Modelos.Factura.MMensajeFactura
Dim CveCliente As Integer = 1154164
Dim CveMoneda As Integer = 2
Dim CveSubProyecto As Integer = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero()
Dim CveSubProyecto As Integer = -1
Dim CvePSBoleto As Integer = 912720
If EsProduccion Then
CvePSBoleto = 986337
CveCliente = 1172306
End If
If CveCliente <= 0 Then
Retorno.Mensajes.Add("No se pudo cargar el cliente")
Return Retorno
End If
If CveSubProyecto <= 0 Then
Retorno.Mensajes.Add("No se pudo cargar el subproyecto")
Return Retorno
End If
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, -1, CveCliente, CveMoneda, "Rem")
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyecto, CveCliente, CveMoneda, "Rem")
If ObjFactura IsNot Nothing Then
'TOMA EL SUBPROYECTO DEL CLIENTE
CveSubProyecto = ObjFactura.Cliente.CveSubProyecto
Dim CvePSBoleto As Integer = 912720
For Each Dr As DataRow In DtPasajeros.Rows
Dim Obs = Dr("Nombre").ToString
Dim Importe = Dr("Importe").ToString.ToDecimal()
If Importe <= 0 Then
Retorno.Mensajes.Add("El importe debe ser mayor a 0")
If CveSubProyecto <= 0 Then
Retorno.Mensajes.Add("No se pudo cargar el subproyecto")
Return Retorno
End If
ObjFactura.AgregarPS(CvePSBoleto, 1, Importe, 0, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=0)
Next
ObjFactura.CveSubProyecto = CveSubProyecto
ObjFactura.CveSubProyectoCobranza = CveSubProyecto
ObjFactura.CveSubProyectoEjecucion = CveSubProyecto
ObjFactura.SetSubProyecto()
ObjFactura.SetSubProyectoMatriz()
ObjFactura.CalculaTotales()
For Each Dr As DataRow In DtPasajeros.Rows
Dim Obs = Dr("Nombre").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
Try
Retorno = ObjFactura.EmitirFactura(False, Transac:=objTrans.IniciaTransacSQL())
Catch ex As Exception
Retorno = Nothing
GuardaLog(ex.ToString())
End Try
ObjFactura.AgregarPS(CvePSBoleto, 1, Importe, 0, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=0, CveViajePasajero:=Dr("CveViajePasajero").ToString().ToEntero())
Next
If ObjFactura IsNot Nothing Then
ObjFactura.Dispose()
ObjFactura.CalculaTotales()
Try
Retorno = ObjFactura.EmitirFactura(False, Transac:=objTrans.IniciaTransacSQL())
Catch ex As Exception
Retorno = Nothing
GuardaLog(ex.ToString())
End Try
If ObjFactura IsNot Nothing Then
ObjFactura.Dispose()
End If
Else
Retorno.Mensajes.Add("No se pudo generar la factura")
End If
Return Retorno
End Function