--Actualizar el TC de una venta no timbrada

This commit is contained in:
2023-05-26 10:56:26 -07:00
parent 1bc4cf726f
commit 153141d764
2 changed files with 62 additions and 15 deletions

View File

@@ -616,6 +616,24 @@ Public Class ClsVentas
Return Retorno
End Function
Public Function UpdateVentaTC(CveVenta As Integer, CveEmpresa As Integer, TipoCambio As Decimal) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_VentasTipoCambioUpdate")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@TipoCambio", SqlDbType.Decimal).Value = TipoCambio
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al actualizar el TC de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function UpdateFechaVencimientoVenta(CveVenta As Integer, FechaVencimiento As Date) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_VentasFechaVencimientoUpdate")

View File

@@ -33193,7 +33193,7 @@ Partial Class Ventas
ErrorTrans = True
End If
If Not ObjEventos.AddEventoBitacora($"Se actualizo la fecha de pago. Anterior:{FechaVencimientoAnterior} Actual:{TxtFechaPago.Text}.", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then
If Not ObjEventos.AddEventoBitacora($"Se actualizó la fecha de pago. Anterior:{FechaVencimientoAnterior} Actual:{TxtFechaPago.Text}.", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then
ErrorTrans = True
End If
@@ -34425,15 +34425,15 @@ Partial Class Ventas
TFuenteRecaudacion.Visible = False
End If
If UsuarioActual.CveRol = 1 Then
If ChkEmitirComercioExterior.Checked Then
TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToString()
Else
TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString()
End If
'If UsuarioActual.CveRol = 1 Then
' If ChkEmitirComercioExterior.Checked Then
' TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToString()
' Else
' TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString()
' End If
UpPS.Update()
End If
' UpPS.Update()
'End If
End Sub
@@ -34574,6 +34574,13 @@ Partial Class Ventas
DdlUsoCFDI.Enabled = True
End If
If LblSeTimbro.Text = "No" AndAlso DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso ChkEmitirComercioExterior.Checked AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then
TxtTipoCambio.Enabled = True
TxtTipoCambio.ReadOnly = False
UpPS.Update()
End If
UpParametros.Update()
UPObservaciones.Update()
UpFacturar.Update()
@@ -34581,18 +34588,42 @@ Partial Class Ventas
End Sub
Private Sub GuardarValoresEditados()
Dim TieneError As Boolean = False
Dim AplicaUpdateTC As Boolean = False
If LblSeTimbro.Text = "No" AndAlso DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso ChkEmitirComercioExterior.Checked AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then
AplicaUpdateTC = True
End If
Dim ObjVentas As New ClsVentas()
If ObjVentas.UpdateObservacionesVenta(CveVenta, UsuarioActual.CveEmpresa, DdlVendedor.SelectedValue.ToEntero(), TxtObsFact.Text, RblPaqueteria.SelectedValue.ToEntero(), TxtCorreoNotificaciones.Text,
ObjVentas.IniciaTransacSQL()
If Not ObjVentas.UpdateObservacionesVenta(Me.CveVenta, UsuarioActual.CveEmpresa, DdlVendedor.SelectedValue.ToEntero(), TxtObsFact.Text, RblPaqueteria.SelectedValue.ToEntero(), TxtCorreoNotificaciones.Text,
TxtObsAlmacen.Text, TxtPedidoContrato.Text, TxtOrdenCompra.Text, TxtFechaPago.Text) Then
CargaVenta()
TieneError = True
End If
If Not TieneError AndAlso AplicaUpdateTC Then
If Not ObjVentas.UpdateVentaTC(Me.CveVenta, UsuarioActual.CveEmpresa, TxtTipoCambio.Text.ToDecimal()) Then
TieneError = True
End If
End If
If Not TieneError Then
ObjVentas.Commit()
BtnEditar.Text = "Editar"
Alert("Actualizado correctamente")
Dim Liga = $"document.location.href=""/Ventas/Ventas.aspx?CveVenta={Me.CveVenta}"";"
Alert("La venta se actualizó correctamente", TipoMensaje.MsgInformacion, Liga, TextoConfirmacion:="Aceptar", TextoSegundoBoton:=Nothing, JSBtn2:=Nothing, ShowCloseButton:=False)
UpParametros.Update()
UPObservaciones.Update()
UpFacturar.Update()
Else
ObjVentas.RollBack()
End If
ObjVentas.Dispose()
ObjVentas.Dispose()
'REGENERAR EL PDF
Try
Dim CveEmpresaPDF As Integer = UsuarioActual.CveEmpresa
@@ -34600,8 +34631,6 @@ Partial Class Ventas
Dim strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port)
RegenerarPDF(CveVenta, CveEmpresaPDF, CveUsuarioPDF, strURLHOST)
'Dim Hilo As New System.Threading.Thread(Sub() )
'Hilo.Start()
Catch ex As Exception
OnError("Ocurrió un error al regenerar el PDF", ex)
End Try