diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index a1ac6178e..0edbb82d6 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -1330,13 +1330,15 @@ Partial Class Ventas_ClientesAbonar If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso TxtAnticipo.Text.ToDecimal > 0 AndAlso MsgError = "" Then '' si es empresa GDiaz 'generar un anticipo y registrarle el pago. - Dim tCveMoneda As Integer = 1 + Dim tCveMoneda As Integer = Me.CveMoneda Dim tCveFormaPago As Integer = GlobalDTTipoTransacciones().FiltroPrimeroValor("CveFormaPago", $"CveTipoTransaccion={DdlTipoTransaccion.SelectedValue}").ToEntero Dim tCvePS As Integer Dim tCveUM As Integer = 0 Dim tCveSub As Integer = DdlSubProyectos.SelectedValue.ToEntero ObjFacturaAnt = Modelos.Factura.CrearVentaNueva(UsuarioActual, tCveSub, CveCliente, tCveMoneda, "Ant") ObjFacturaAnt.CveMoneda = tCveMoneda + ObjFacturaAnt.TipoCambio = If(tCveMoneda = 1, 1, TxtTCDolares.Text.ToDecimal()) + ObjFacturaAnt.TipoCambioDolares = If(tCveMoneda = 1, 1, TxtTCDolares.Text.ToDecimal()) ObjFacturaAnt.CveFormaPago = tCveFormaPago ObjFacturaAnt.CveMetodoPago = 1 ObjFacturaAnt.ClaveMetodoPagoSAT = "PUE" @@ -1355,7 +1357,7 @@ Partial Class Ventas_ClientesAbonar RespAnt = ObjFacturaAnt.EmitirFactura(False, Transac:=ObjMov.IniciaTransacSQL(), Modulo:="Ventas/ClientesAbonarAnt", MostrarURL:=True) RespAnt.Factura = ObjFacturaAnt - If RespAnt IsNot Nothing AndAlso RespAnt.Factura IsNot Nothing Then + If RespAnt IsNot Nothing AndAlso RespAnt.Factura IsNot Nothing AndAlso RespAnt.Factura.CveVenta > 0 Then Dim VentaActual As New Venta(UsuarioActual) VentaActual.CveVenta = RespAnt.Factura.CveVenta @@ -1365,7 +1367,7 @@ Partial Class Ventas_ClientesAbonar VentaActual.TipoDocto = "Ant" VentaActual.SerieFolio = RespAnt.Factura.SerieFolio VentaActual.ClienteNombre = NombreComercial - VentaActual.TC = 1 + VentaActual.TC = If(tCveMoneda = 1, 1, TxtTCDolares.Text.ToDecimal()) VentaActual.Total = TxtAnticipo.Text.ToDecimal VentaActual.IVA = (tPorIVA * tPU).RoundSQL(2) @@ -1381,6 +1383,8 @@ Partial Class Ventas_ClientesAbonar Pago.ImportePagoVenta = TxtAnticipo.Text.ToDecimal Pago.Referencia = TxtFolio.Text Pago.TipoPago = "XXX" + Pago.TCPago = If(tCveMoneda = 1, 1, TxtTCDolares.Text.ToDecimal()) + 'If RblTipoPago.SelectedValue = "3" Then ' Pago.TipoPago = "I" ' Pago.FechaDocumentoRelacionado = FechaIngreso @@ -1390,6 +1394,8 @@ Partial Class Ventas_ClientesAbonar If MsgError = "" AndAlso AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then MsgError = "No se pudo insertar la póliza" End If + Else + MsgError = "Ocurrió un error al generar el anticipo" End If End If