From da412a3701b438cdaa567c376c07b0f4d426cd5f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 9 Nov 2022 16:27:02 -0700 Subject: [PATCH] Tipo de cambio para comercio exterior --- Ventas/Ventas.aspx.vb | 47 +++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index aae7589be..e71bdf7eb 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6413,6 +6413,7 @@ Partial Class Ventas If ObjCliente.AplicaComercioExterior Then ChkEmitirComercioExterior.Checked = True + ChkEmitirComercioExterior_CheckedChanged(ChkEmitirComercioExterior, EventArgs.Empty) End If If ObjCliente.AplicaComercioExterior Then @@ -8577,6 +8578,10 @@ Partial Class Ventas Exit Sub End If End If + If ChkEmitirComercioExterior.Checked AndAlso DdlMoneda.SelectedValue.ToEntero() <> 2 Then + Alert("La moneda de la factura debe ser dolares cuando aplica comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If If UsuarioActual.Empresa.Funcionalidad(350) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Egs", "Dev") Then @@ -12201,15 +12206,14 @@ Partial Class Ventas Timbre.Complementos.ComercioExterior11.CertificadoOrigen = "0" Timbre.Complementos.ComercioExterior11.Incoterm = GlobalDTIncoterm.FiltroPrimeroValor("ClaveSATIncoterm", $"CveIncoterm={DdlIncoterm.SelectedValue}") Timbre.Complementos.ComercioExterior11.Subdivision = "0" - Timbre.Complementos.ComercioExterior11.TipoCambioUSD = If(Obj.CveMoneda = 1, 1, Obj.TipoCambio.ToString().ToDecimal) + + Timbre.Complementos.ComercioExterior11.TipoCambioUSD = If(Obj.CveMoneda = 1, 1, Obj.TipoCambio) If Timbre.Comprobante.TipoComprobante = "T" Then Timbre.Complementos.ComercioExterior11.MotivoTraslado = GlobalDTSATMotivoTraslado.FiltroPrimeroValor("ClaveSATMotivoTraslado", $"CveMotivoTraslado={DdlSATMotivoTraslado.SelectedValue}") Else Timbre.Complementos.ComercioExterior11.MotivoTraslado = "" End If - - 'EMISOR Dim Dr As DataRow Dr = Nothing @@ -13293,7 +13297,12 @@ Partial Class Ventas If UsuarioActual.CveEmpresa.Contiene(13, 83) Then tipoCambio = GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToString().ToDecimal Else - tipoCambio = GlobalTipoCambio(ObjFactura.Fecha).ToString().ToDecimal + If ChkEmitirComercioExterior.Checked Then + tipoCambio = GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToString().ToDecimal + Else + tipoCambio = GlobalTipoCambio(ObjFactura.Fecha).ToString().ToDecimal + End If + End If Else tipoCambio = 1 @@ -16951,7 +16960,7 @@ Partial Class Ventas If UsuarioActual.TienePermisoProceso(68) AndAlso Not PSCodigoSAT.Contiene("84111506", "80141610") Then TxtPrecio.Enabled = False - If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count = 0 Then + If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count = 0 AndAlso Not ChkEmitirComercioExterior.Checked Then DdlMoneda.SelectedValueExist(drPS("CveMoneda").ToString()) CambiaMoneda() End If @@ -21760,7 +21769,7 @@ Partial Class Ventas ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) Case "2" TxtTipoCambioDlls.Text = "1" - If UsuarioActual.CveEmpresa.Contiene(13, 83) Then + If UsuarioActual.CveEmpresa.Contiene(13, 83) OrElse ChkEmitirComercioExterior.Checked Then TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToString() Else TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString() @@ -21769,7 +21778,7 @@ Partial Class Ventas ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) Case Else - If UsuarioActual.CveEmpresa.Contiene(13, 83) Then + If UsuarioActual.CveEmpresa.Contiene(13, 83) OrElse ChkEmitirComercioExterior.Checked Then TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToString() Else TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString() @@ -24303,6 +24312,10 @@ Partial Class Ventas ChkDevAlm.Checked = True End If + If UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso ObjFacturaCancelacion.TipoDocto = "Rem" Then + ChkDevAlm.Checked = True + End If + resp = ObjFacturaCancelacion.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar, CveMotivoCancelacion:=DdlMotivoCancelacion.SelectedValue.ToEntero(), Motivo:=TxtMotivoCancelacion.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion) strMensaje.Append(resp.Mensaje) Dim DtBonificaciones As DataTable = Nothing @@ -28360,7 +28373,7 @@ Partial Class Ventas If DdlMoneda.SelectedValue <> "1" Then - If UsuarioActual.CveEmpresa.Contiene(13, 83) Then + If UsuarioActual.CveEmpresa.Contiene(13, 83) OrElse ChkEmitirComercioExterior.Checked Then TxtTipoCambio.Text = GlobalTipoCambio(Now.AddDays(-1)).ToString() Else TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString() @@ -28454,7 +28467,7 @@ Partial Class Ventas 'verifica el tipo de cambio que se actualice If DdlMoneda.SelectedValue <> "1" Then - If UsuarioActual.CveEmpresa.Contiene(13, 83) Then + If UsuarioActual.CveEmpresa.Contiene(13, 83) OrElse ChkEmitirComercioExterior.Checked Then TxtTipoCambio.Text = GlobalTipoCambio(Now.AddDays(-1)).ToString() Else TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString() @@ -29571,7 +29584,7 @@ Partial Class Ventas End If - If UsuarioActual.CveEmpresa.Contiene(13, 83) Then + If UsuarioActual.CveEmpresa.Contiene(13, 83) OrElse ChkEmitirComercioExterior.Checked Then TxtTipoCambio.Text = GlobalTipoCambio(Now.AddDays(-1)).ToString() Else TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString() @@ -33294,7 +33307,7 @@ Partial Class Ventas End If ObjFactura.SetSubProyecto() - EnviarPolizaVentaWS(obj, CvePolizaVirtual, ObjFactura.SubProyecto.Acum_PortalUsuario, ObjFactura.SubProyecto.Acum_PortalContrasena) + 'EnviarPolizaVentaWS(obj, CvePolizaVirtual, ObjFactura.SubProyecto.Acum_PortalUsuario, ObjFactura.SubProyecto.Acum_PortalContrasena) End If Next @@ -35512,6 +35525,18 @@ Partial Class Ventas End Function Protected Sub ChkEmitirComercioExterior_CheckedChanged(sender As Object, e As EventArgs) + If CveVenta <= 0 OrElse EsCreaApartirDe Then + If ChkEmitirComercioExterior.Checked Then + DdlMoneda.SelectedValueExist("2") + CambiaMoneda() + TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToString() + Alert("El tipo de cambio va ser el del dia anterior a la fecha de la factura cuando se utiliza comercio exterior") + Else + TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString() + End If + + UpPS.Update() + End If End Sub