From 11aef2f7dd5ab09a0ea172e5b5b5681c25974377 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 5 Jan 2022 13:04:48 -0700 Subject: [PATCH] =?UTF-8?q?activar=20autorizaciones=20em=20empresas=20acum?= =?UTF-8?q?uladoras=20--=20opci=C3=B3n=20de=20saldar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/Ventas.aspx.vb | 103 +++++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 32 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index d76cbee08..64856fa2c 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -802,7 +802,7 @@ Partial Class Ventas End Property Private ReadOnly Property IdCtaContClientes As Integer Get - Return ViewState("IdCtaContClientes").ToString().ToEntero() + Return IfNull(ViewState("IdCtaContClientes"), "").ToString().ToEntero() End Get End Property @@ -2080,6 +2080,13 @@ Partial Class Ventas Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then + + If IfNull(Request("Opcionx"), "").ToString = "Saldar" And UsuarioActual.CveUsuario = 100 Then + TxtFechaSaldarVenta.Text = "2021/12/31" + SaldarVenta() + Exit Sub + End If + Modalidad = "" Opcion = "" Index = 0 @@ -3048,6 +3055,8 @@ Partial Class Ventas End If MostrarOpcionesPaqueteria() + + 'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then 'If Not AjustarTotalCotizacionFacturada(ViewState("CveCotizacion").ToString().ToEntero(), TxtTotal.Text.ToDecimal) Then @@ -8042,7 +8051,7 @@ Partial Class Ventas Me.CveAutorizacion = -1 'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES - If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") AndAlso RBLPago.SelectedValue = "1" Then + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") AndAlso RBLPago.SelectedValue = "1" Then Dim TipoDocumentoAutorizacion As String = "" Dim ImporteAutorizacion As Decimal = 0 Dim TipoAutorizacion As Integer = 0 @@ -8699,10 +8708,6 @@ Partial Class Ventas DebeTimbrar = False End If - 'Si es BDH no debe timbrar - If UsuarioActual.CveEmpresa = 140 Then - DebeTimbrar = False - End If If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso UsuarioActual.Empresa.FacturaProduccion Then @@ -15500,11 +15505,6 @@ Partial Class Ventas Exit Sub End If - 'Si es BDH no debe timbrar - If UsuarioActual.CveEmpresa = 140 Then - Exit Sub - End If - If UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then If UsuarioActual.Empresa.EstatusFacturacion Then @@ -24741,6 +24741,8 @@ Partial Class Ventas 'RegistraScript("$('#ModalSaldarVenta').modal('hide')", "ModalSaldarVentaHidde") + + Dim ObjConta As New ClsContabilidad ObjConta.IniciaTransacSQL() Dim CvePrePoliza As Integer = 0 @@ -24774,19 +24776,55 @@ Partial Class Ventas 'End If ' ObjIE.Dispose() - - Dim IdCtaContable As Integer = IdCtaContClientes - Dim PorcentajePago As Decimal = SaldoVenta / TxtTotal.Text.ToDecimal - Dim Saldo As Decimal = SaldoVenta - Dim SubTotal As Decimal = PorcentajePago * TxtSubTotal.Text.ToDecimal - Dim IVA As Decimal = PorcentajePago * TxtIVA.Text.ToDecimal - Dim IEPS As Decimal = PorcentajePago * TxtIEPS.Text.ToDecimal - Dim TCVenta As Decimal = TxtTipoCambio.Text.ToDecimal - Dim FechaVenta As Date = TxtFecha.Text.ToDate - Dim FechaPago As Date = TxtFechaSaldarVenta.Text.ToDate - Dim tCveMoneda As Integer = DdlMoneda.SelectedValue.ToEntero() - Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaSaldarVenta.Text.ToDate).FormatoNumero(4).ToDecimal + Dim Total As Decimal = 0 + Dim Saldo As Decimal = 0 + Dim SubTotal As Decimal + Dim IVA As Decimal + Dim IEPS As Decimal + Dim Descuentos As Decimal + Dim TCVenta As Decimal + Dim FechaVenta As Date + Dim FechaPago As Date = Request("FechaSaldar").ToDate + Dim tCveMoneda As Integer + Dim PorcentajePago As Decimal + Dim SerieFolio As String = "" + Dim CveSubProyecto As Integer + Dim CveClasificacion As Integer + Dim PorcentajeImpuesto As Decimal = 0 + + ViewState("CveVenta") = IfNull(Request("CveVenta"), 0).ToString.ToEntero + + Dim Obj As New ClsVentas + If Obj.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then + Dim DbRowVenta As DataRow = Obj.DtResultados.FiltroPrimero("") + ViewState("SaldoVenta") = DbRowVenta("Saldo").ToString() + Total = DbRowVenta("Total").ToString.ToDecimal + SubTotal = DbRowVenta("Saldo").ToString.ToDecimal + SerieFolio = DbRowVenta("SerieFolio").ToString + Saldo = SaldoVenta + PorcentajePago = SaldoVenta / Total + + IVA = PorcentajePago * DbRowVenta("IVA").ToString.ToDecimal + IEPS = PorcentajePago * DbRowVenta("IEPS").ToString.ToDecimal + Descuentos = PorcentajePago * DbRowVenta("Descuento").ToString.ToDecimal + TCVenta = DbRowVenta("TipoCambio").ToString.ToDecimal + FechaVenta = DbRowVenta("Fecha").ToString.ToDate + ' FechaPago = TxtFechaSaldarVenta.Text.ToDate + tCveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero + ViewState("CveCliente") = DbRowVenta("CveCliente").ToString.ToEntero + CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero + PorcentajeImpuesto = DbRowVenta("PorcentajeIVA").ToString.ToDecimal + + If Obj.GetVentaDetalle(CveVenta) Then + CveClasificacion = Obj.DtResultados.MAX("CveClasificacion").ToEntero + End If + SubTotal = Saldo - IVA - IEPS + + End If + Obj.Dispose() + + Dim TCPago As Decimal = GlobalTipoCambio(FechaPago).FormatoNumero(4).ToDecimal Dim CveConceptoDeduccion As Integer = 211 @@ -24804,9 +24842,8 @@ Partial Class Ventas Dim CveConceptoCliente As Integer = 2 Dim ImpuestosMovto As Boolean = False Dim IdCuentaContableNoDeducible As Integer = 0 - Dim SerieFolio As String = LblSerie.Text & "-" & TxtFolio.Text Dim ConceptoPartida As String = "saldado " & SerieFolio - Dim CveSubProyecto As Integer = DdlSubProyectoDatos.SelectedValue.ToEntero() + If CveConceptoDeduccion = 255 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(266).ToEntero() If CveConceptoDeduccion = 211 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(559).ToEntero() @@ -24824,8 +24861,8 @@ Partial Class Ventas Dim UsaComplementaria As Boolean = True - If MsgError = "" Then - CvePrePoliza = ObjConta.AddPrePolizas("Ventas/Saldarr", 47, SaldoVenta, SaldoVenta, tCveMoneda, TxtFechaSaldarVenta.Text.ToDate, ConceptoPartida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If MsgError = "" AndAlso Saldo > 0 Then + CvePrePoliza = ObjConta.AddPrePolizas("Ventas/Saldarr", 47, SaldoVenta, SaldoVenta, tCveMoneda, FechaPago, ConceptoPartida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If tCveMoneda = 2 Then IdCtaContable = IdCtaContMonedaExtranjera @@ -24869,10 +24906,6 @@ Partial Class Ventas End If - - ' iva - Dim PorcentajeImpuesto As Decimal = DdlIVA.SelectedValue.ToEntero() - Dim IdCtaIVAXTrasladar As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then @@ -24889,10 +24922,14 @@ Partial Class Ventas End If 'al gasto,Subtotal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, SerieFolio, CveConceptoDeduccion, ConceptoPartida, FechaPago, IdCuentaContableNoDeducible, -1, CveCliente:=CveCliente, CveVenta:=CveVenta, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero()) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, SerieFolio, CveConceptoDeduccion, ConceptoPartida, FechaPago, IdCuentaContableNoDeducible, -1, CveCliente:=CveCliente, CveVenta:=CveVenta, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto) Then MsgError = "Ocurrio un error al saldar el movimiento" End If + 'If Descuentos > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not SubtotalMovto, Descuentos, SerieFolio, 103, ConceptoPartida, FechaPago, IdCuentaContableNoDeducible, -1, CveCliente:=CveCliente, CveVenta:=CveVenta, ImporteMX:=Descuentos, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveClasificacion:=CveClasificacion, CveSubProyecto:=CveSubProyecto) Then + ' MsgError = "Ocurrio un error al saldar el movimiento" + 'End If + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then If ObjConta.ValorPolizaDescuadre > 0 Then MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia @@ -24900,6 +24937,8 @@ Partial Class Ventas End If End If + Else + MsgError = "Saldo Cero" End If