diff --git a/App_Code/ClsPuntoVenta.vb b/App_Code/ClsPuntoVenta.vb index 6a0112680..79f8f82ed 100644 --- a/App_Code/ClsPuntoVenta.vb +++ b/App_Code/ClsPuntoVenta.vb @@ -243,6 +243,29 @@ Public Class ClsPuntoVenta Return Retorno End Function + Public Function GetCortesPorCuenta(CveCuenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_CuentaCorteGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCorte", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + CveCorte = Integer.Parse(SqlAdapter.SelectCommand.Parameters("@CveCorte").Value.ToString) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los cuenta de corte", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetVta_ReporteCortes(CveEmpresa As Integer, FechaI As Date, FechaF As Date, Optional CveSubProyecto As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_ReporteCortesGet") diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 1dead2777..732c68020 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -4407,63 +4407,79 @@ Namespace Modelos If ObjFactura.FolioFiscal <> "" Then If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Dev", "Egs") Then - Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion) + 'VERIFICA SI DEBE VALIDAR ANTE EL SAT + If Not (UsuarioActual.Empresa.Funcionalidad(529) = "1") Then - If Vigencia IsNot Nothing Then - If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then - Retorno.Mensaje = "Esta factura no es cancelable." + Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion) + + If Vigencia IsNot Nothing Then + If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then + Retorno.Mensaje = "Esta factura no es cancelable." + Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + + Return Retorno + End If + If Vigencia.Estado.ToUpper().Contains("CANCELADO") Then + ContinuarCancelacion = False + ObtenerAcuse = True + Dim solicitud = New WSGF.Service1SoapClient() + Dim acuse = solicitud.GetAcuse(UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx", "rene2018", FolioFiscal) + + If acuse.Estado = 0 Then + Dim xmlAcuse = New System.Xml.XmlDocument() + xmlAcuse.LoadXml(DecodeBase64(acuse.CfdiB64)) + CancelacionAcuse = xmlAcuse.GetElementsByTagName("SignatureValue")(0).InnerText + CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate() + CveEstatus = 5 + Else + CancelacionFecha = Now.Date + CancelacionAcuse = "" + CveEstatus = 5 + End If + + ElseIf Vigencia.Estado.ToUpper().Contains("VIGENTE") Then + + If Vigencia.EstatusCancelacion.ToUpper() = "EN PROCESO" Then + CveEstatus = 20 + ContinuarCancelacion = False + ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE CON ACEPTACIÓN" Then + CveEstatus = 20 + ContinuarCancelacion = True + RequiereAceptacion = True + ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then + ContinuarCancelacion = True + CveEstatus = 5 + End If + + Else + If Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then + ContinuarCancelacion = True + CveEstatus = 5 + Else + CveEstatus = 20 + ContinuarCancelacion = False + CancelacionFecha = Now.Date + CancelacionAcuse = "" + End If + End If + Else + Retorno.Mensaje = "SAT - No se pudo verificar el estatus de la factura." Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia Return Retorno End If - If Vigencia.Estado.ToUpper().Contains("CANCELADO") Then - ContinuarCancelacion = False - ObtenerAcuse = True - Dim solicitud = New WSGF.Service1SoapClient() - Dim acuse = solicitud.GetAcuse(UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx", "rene2018", FolioFiscal) - - If acuse.Estado = 0 Then - Dim xmlAcuse = New System.Xml.XmlDocument() - xmlAcuse.LoadXml(DecodeBase64(acuse.CfdiB64)) - CancelacionAcuse = xmlAcuse.GetElementsByTagName("SignatureValue")(0).InnerText - CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate() - CveEstatus = 5 - Else - CancelacionFecha = Now.Date - CancelacionAcuse = "" - CveEstatus = 5 - End If - - ElseIf Vigencia.Estado.ToUpper().Contains("VIGENTE") Then - - If Vigencia.EstatusCancelacion.ToUpper() = "EN PROCESO" Then - CveEstatus = 20 - ContinuarCancelacion = False - ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE CON ACEPTACIÓN" Then - CveEstatus = 20 - ContinuarCancelacion = True - RequiereAceptacion = True - ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then - ContinuarCancelacion = True - CveEstatus = 5 - End If - - Else - If Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then - ContinuarCancelacion = True - CveEstatus = 5 - Else - CveEstatus = 20 - ContinuarCancelacion = False - CancelacionFecha = Now.Date - CancelacionAcuse = "" - End If - End If Else - Retorno.Mensaje = "SAT - No se pudo verificar el estatus de la factura." - Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + ObtenerAcuse = False + ContinuarCancelacion = True + CancelacionFecha = Now.Date + CancelacionAcuse = "" + + Dim diasTimbrado As Decimal = DateDiff(DateInterval.Day, ObjFactura.FechaCP, Now) + + If ObjFactura.Total < 5000D OrElse diasTimbrado <= 3 OrElse ObjFactura.Cliente.RFC.Contiene("XAXX010101000", "XEXX010101000") Then + RequiereAceptacion = False + End If - Return Retorno End If If Not ObtenerAcuse Then diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index e4cda96bc..56fce0da2 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -59,18 +59,20 @@ Public Class Timbrado Public Function CFDICancelar(Empresa As Empresa, FolioFiscal As String, Total As Decimal, RFCReceptor As String, RFCEmisor As String, Optional CvePACCancelacion As Integer = 2, Optional ValidaFactura As Boolean = True) As Boolean Dim Retorno As Boolean = False Dim MsgCancelacion As New StringBuilder - If ValidaFactura Then - Dim Vigencia = VerificarVigenciaSAT(FolioFiscal, RFCEmisor, RFCReceptor, Total.ToString(), True) - If Vigencia IsNot Nothing Then - If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then + + If Not (Empresa.Funcionalidad(529) = "1") Then + If ValidaFactura Then + Dim Vigencia = VerificarVigenciaSAT(FolioFiscal, RFCEmisor, RFCReceptor, Total.ToString(), True) + If Vigencia IsNot Nothing Then + If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then + Return False + End If + Else Return False End If - Else - Return False End If End If - MsgCancelacion.AppendFormat("CvePAC:{0}", CvePACCancelacion) Select Case CvePACCancelacion @@ -654,6 +656,12 @@ Public Class Timbrado If Ret <> "" Then MensajeErrorCFDI = Ret Retorno = If(Ret = "", True, False) + Case 5 + + Dim Ret As String = TimbrarFacturaPADEv33(Ventas, UsuarioActual, CvePACEspecial) + If Ret <> "" Then MensajeErrorCFDI = Ret + Retorno = If(Ret = "", True, False) + End Select @@ -2185,6 +2193,604 @@ Public Class Timbrado GuardaLogTimbrado(swTiempo.ToString, CvePACEspecial) Return Retorno End Function + + Public Function TimbrarFacturaPADEv33(Ventas As Modelos.Factura, UsuarioActual As Usuario, Optional CvePACEspecial As Integer = -1) As String + If CvePACEspecial = -1 Then + CvePACEspecial = UsuarioActual.Empresa.CvePAC + End If + Dim sw As New Diagnostics.Stopwatch + Dim swmili As Long = 0 + Dim swTiempo As New StringBuilder + sw.Start() + Dim Retorno As String = "" + Dim ObjCFDITimbre As CFDITimbre = Ventas.Timbre + ' 'Sucursal matriz de la empresa + Dim ArchivoLLave As String = String.Format("{0}Certificados\{1}", UsuarioActual.Empresa.Ruta, UsuarioActual.Empresa.ArchivoKey) + Dim ArchivoCertificado As String = String.Format("{0}Certificados\{1}", UsuarioActual.Empresa.Ruta, UsuarioActual.Empresa.ArchivoCer) + Dim UsuarioServicio As String = If(CvePACEspecial = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") + Dim ClaveServicio As String = If(CvePACEspecial = 2, UsuarioActual.Empresa.RFC.ToLower, "rene2018") + Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey + Dim EmisorRFC As String = UsuarioActual.Empresa.RFC + Dim UrlServicio As String = "" ' Produccion + Dim RutaArchivo As String = String.Format("{0}XML\{1}\", UsuarioActual.Empresa.Ruta, Ventas.TipoDocto) + Dim NombreArchivoXML As String = ObjCFDITimbre.Comprobante.SerieFolio + Dim SubTotal As Decimal = 0 + Dim TimbraProduccion As Boolean = True + If Not Directory.Exists(RutaArchivo) Then Directory.CreateDirectory(RutaArchivo) + Select Case CvePACEspecial + Case 2 + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" 'productivo + Case 4 + 'UrlServicio = "http://juancalderon-001-site1.ftempurl.com/timbrado.asmx?WSDL" + UrlServicio = "http://alterno.gofac.com.mx/cfdi/timbrado.asmx?WSDL" ' alterno + End Select + + If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then + + EmisorRFC = "AAA010101AAA" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + Clave = "12345678a" + TimbraProduccion = False + Select Case CvePACEspecial + Case 2 + UsuarioServicio = "fgomez" + ClaveServicio = "12121212" + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" '"http://108.60.211.43/rvltimbrado/service1.asmx" + Case 4 + UsuarioServicio = "UserTest" + ClaveServicio = "1234567890" + UrlServicio = "http://juancalderon-001-site1.ftempurl.com/timbrado.asmx?WSDL" + End Select + End If + +#Region "Valida" + If Not File.Exists(ArchivoCertificado) Then + Alert("El archivo de certificado no existe", TipoMensaje.MsgError) + Return "El archivo de certificado no existe" + End If + If Not File.Exists(ArchivoLLave) Then + Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) + Return "El archivo de llave privada no existe" + End If + If UsuarioActual.Empresa.ContraseñaKey = "" Then + Alert("La clave no puede ser vacía", TipoMensaje.MsgError) + Return "La clave no puede ser vacía" + End If +#End Region + +#Region "Variables" + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String, certBase64 As String + Dim cfdi As New GoFac.GoCfdi() + Dim complemento As String = "" + Dim complementoConcepto As String = "" + +#End Region + +#Region "Verifica" + Try + llaveByte = System.IO.File.ReadAllBytes(ArchivoLLave) + llaveBase64 = Convert.ToBase64String(llaveByte) + Catch ex As Exception + Alert($"Error al leer la llave privada: {ex.Message}", TipoMensaje.MsgError) + Return "Error al leer la llave privada" + End Try + + + Try + certByte = System.IO.File.ReadAllBytes(ArchivoCertificado) + certBase64 = Convert.ToBase64String(certByte) + Catch ex As Exception + Alert($"Error al leer el certificado: {ex.Message}", TipoMensaje.MsgError) + Return "Error al leer el certificado" + + End Try +#End Region + + + sw.Stop() + swTiempo.AppendFormat("Verificado : ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + + ' cfdi.saltarValidacion("bNtMuvZockPVhEjaPj0E") + ' cfdi.Decimales = 4 +#Region "Certificado" + cfdi.CertificadoArchivo(ArchivoCertificado) +#End Region + + + sw.Stop() + swTiempo.AppendFormat("Certificado : ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + +#Region "Comprobante" + + cfdi.Comprobante33( + ObjCFDITimbre.Comprobante.Serie, + ObjCFDITimbre.Comprobante.Folio, + ObjCFDITimbre.Comprobante.Fecha.ToString("yyyy-MM-ddTHH:mm:ss"), + ObjCFDITimbre.Comprobante.FormadePago, + ObjCFDITimbre.Comprobante.CondicionesdePago, + ObjCFDITimbre.Comprobante.Subtotal, + ObjCFDITimbre.Comprobante.Descuentos, + ObjCFDITimbre.Comprobante.Moneda, + ObjCFDITimbre.Comprobante.TipoCambio.ToString, + ObjCFDITimbre.Comprobante.Total, + ObjCFDITimbre.Comprobante.TipoComprobante, + ObjCFDITimbre.Comprobante.MetodoPago, + ObjCFDITimbre.Comprobante.LugarExpedicion, + ObjCFDITimbre.Comprobante.Confirmacion) + + If ObjCFDITimbre.CFDIRelacionados.TipoRelacion <> "" Then + cfdi.CfdiRelacionados(ObjCFDITimbre.CFDIRelacionados.TipoRelacion) + For Each uid As String In ObjCFDITimbre.CFDIRelacionados.UUID + cfdi.CfdiRelacionado(uid) + Next + End If +#Region "Emisor" + ' cfdi.agregarCfdiRelacionados() + cfdi.Emisor(EmisorRFC, UsuarioActual.Empresa.Empresa, UsuarioActual.Empresa.CodigoRegimenFiscal) + +#End Region + +#Region "Receptor" + + cfdi.Receptor(ObjCFDITimbre.Receptor.RFC, ObjCFDITimbre.Receptor.Nombre, ObjCFDITimbre.Receptor.ResidenciaFiscal, ObjCFDITimbre.Receptor.NumeroRegistroTributario, ObjCFDITimbre.Receptor.UsoCFDI) + +#End Region + +#End Region + +#Region "Conceptos" + + 'Nodo conceptos, se agregan los PS + + If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then + For Each concep As CFDIConceptos In ObjCFDITimbre.Conceptos + cfdi.Concepto(concep.ClaveProdServ, concep.Noidentificacion, concep.Cantidad, concep.ClaveUnidad, concep.Unidad, concep.Descripcion, concep.ValorUnitario, concep.Importe, concep.Descuento) + For Each imp As CFDIConceptosImpuestos In concep.Impuestos + If imp.TrasladooRetencion = "T" Then + cfdi.ImpuestoConceptoTraslado(imp.Base, imp.Impuesto, imp.TipoFactor, imp.TasaOCuota, imp.Importe) + Else + cfdi.ImpuestoConceptoRetenido(imp.Base, imp.Impuesto, imp.TipoFactor, imp.TasaOCuota, imp.Importe) + End If + Next + If concep.CuentaPredial <> "" Then cfdi.CuentaPredial(concep.CuentaPredial) + If concep.NumeroPedimento <> "" Then cfdi.InformacionAduanera(concep.NumeroPedimento) + Next + End If + +#End Region + + If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then + +#Region "Impuestos" + 'SI NO ES FACTURA EN 0 AGREGA LOS IMPUESTOS + If Ventas.Total <> 0 OrElse (ObjCFDITimbre.TotalImpuestosRetenidos > 0 OrElse ObjCFDITimbre.TotalImpuestosTrasladados > 0) Then + cfdi.Impuestos(ObjCFDITimbre.TotalImpuestosRetenidos, ObjCFDITimbre.TotalImpuestosTrasladados) + End If +#End Region +#Region " Traslados y Retenciones" + + + If ObjCFDITimbre.Retenciones.Sum(Function(x) x.Importe) > 0 Then + ''se acumulan los importes + For Each Ret In ObjCFDITimbre.Retenciones + cfdi.Retencion(Ret.Impuesto, Ret.Importe) + Next + End If + + ''se acumulan los importes + For Each Tras In ObjCFDITimbre.Traslados + cfdi.Traslado(Tras.Impuesto, Tras.TipoFactor, Tras.TasaOCuota, Tras.Importe) + Next +#End Region + +#Region "Impuestos Locales" + + If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 OrElse ObjCFDITimbre.TrasladosLocales.Sum(Function(x) x.Importe) > 0 Then + + cfdi.ImpuestosLocales(ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe), ObjCFDITimbre.TrasladosLocales.Sum(Function(x) x.Importe)) + + For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales + If ret.Importe > 0 Then + cfdi.RetencionLocal(ret.ImpuestoLocalRetenido, ret.TasaRetencion, ret.Importe) + End If + Next + + For Each ret As CFDITrasladosLocales In ObjCFDITimbre.TrasladosLocales + If ret.Importe > 0 Then + cfdi.TrasladoLocal(ret.ImpuestoLocalTraslado, ret.TasaTraslado, ret.Importe) + End If + Next + End If + + If Ventas.CveComplementoTimbrado > 0 Then + + Select Case Ventas.CveComplementoTimbrado + Case 5 'INE Proceso Ordinario Directivo Estatal" + cfdi.Ine11("Ordinario", "Directivo Estatal", "0") + + cfdi.IneEntidad(Ventas.ComplementoINE.INEEntidad, "") + cfdi.IneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) + Case 6 'INE Proceso Ordinario Ejecutivo Estatal" + cfdi.Ine11("Ordinario", "Ejecutivo Estatal", "0") + + cfdi.IneEntidad(Ventas.ComplementoINE.INEEntidad, "") + cfdi.IneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) + Case 7 'INE Proceso Ordinario Ejecutivo Nacional" + + cfdi.Ine11("Ordinario", "Ejecutivo Nacional", Ventas.ComplementoINE.INEIdContabilidad.ToString) + Case 8 'INE PreCampaña + cfdi.Ine11(Ventas.ComplementoINE.INETipoProceso, "", "0") + + cfdi.IneEntidad(Ventas.ComplementoINE.INEEntidad, Ventas.ComplementoINE.INETipoComite) + cfdi.IneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) + End Select + + End If + + + +#End Region + + +#Region "Comercio Exterior" + + If Ventas.Cliente.AplicaComercioExterior And ObjCFDITimbre.Complementos.ComercioExterior11.AplicaComercioExteriorSubProyecto Then + If ObjCFDITimbre.Complementos.ComercioExterior11 IsNot Nothing Then + + 'DATOS GENERALES + cfdi.ComercioExterior11(ObjCFDITimbre.Complementos.ComercioExterior11.MotivoTraslado, + ObjCFDITimbre.Complementos.ComercioExterior11.TipoOperacion, + ObjCFDITimbre.Complementos.ComercioExterior11.ClavedePedimento, + ObjCFDITimbre.Complementos.ComercioExterior11.CertificadoOrigen, + ObjCFDITimbre.Complementos.ComercioExterior11.NumCertificadoOrigen, + ObjCFDITimbre.Complementos.ComercioExterior11.NumeroExportadorConfiable, + ObjCFDITimbre.Complementos.ComercioExterior11.Incoterm, + ObjCFDITimbre.Complementos.ComercioExterior11.Subdivision, + ObjCFDITimbre.Complementos.ComercioExterior11.Observaciones, + ObjCFDITimbre.Complementos.ComercioExterior11.TipoCambioUSD, + ObjCFDITimbre.Complementos.ComercioExterior11.TotalUSD) + 'EMISOR + cfdi.ComercioExterior11Emisor(If(EmisorRFC.Length >= 12, "", ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CURP)) + cfdi.ComercioExterior11Domicilio(ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Calle, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.NumeroExterior, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.NumeroInterior, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Colonia, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Localidad, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Referencia, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Municipio, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Estado, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Pais, + ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CP) + 'RECEPTOR + cfdi.ComercioExterior11Receptor(ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib) + cfdi.ComercioExterior11DomicilioReceptor(ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Calle, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroExterior, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroInterior, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Colonia, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Localidad, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Referencia, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Municipio, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Estado, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Pais, + ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.CP) + cfdi.ComercioExterior11Destinatario(ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Nombre, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Calle, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Colonia, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Localidad, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Referencia, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Municipio, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Estado, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Pais, + ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.CP) + 'MERCANCIAS + If ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias IsNot Nothing AndAlso ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias.Count > 0 Then + For Each concep As CFDIComercioExterior11Mercancias In ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias + cfdi.ComercioExterior11Mercancia(concep.NoIdentificacion, concep.FraccionArancelaria, concep.CantidadAduana, concep.UnidadAduana, concep.ValorUnitarioAduana, concep.ValorDolares) + If concep.DescripcionesEspecificas.Marca <> "" Then + cfdi.ComercioExterior11MercanciaDescripcionesEspeciales(concep.DescripcionesEspecificas.Marca, + concep.DescripcionesEspecificas.Modelo, + concep.DescripcionesEspecificas.SubModelo, + concep.DescripcionesEspecificas.NumeroSerie) + End If + Next + + End If + + + End If + End If + +#End Region + + + End If + +#Region "Complemento Pago" + + If ObjCFDITimbre.Comprobante.TipoComprobante = "P" Then + + cfdi.Pago(ObjCFDITimbre.ComplementoPagos.FechaPago.ToString("yyyy-MM-ddTHH:mm:ss"), + ObjCFDITimbre.ComplementoPagos.FormaDePagoP, + ObjCFDITimbre.ComplementoPagos.MonedaP, + ObjCFDITimbre.ComplementoPagos.TipoCambioP, + ObjCFDITimbre.ComplementoPagos.Monto, + ObjCFDITimbre.ComplementoPagos.NumOperacion, + ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaOrd, + ObjCFDITimbre.ComplementoPagos.NomBancoOrdExt, + ObjCFDITimbre.ComplementoPagos.CtaOrdenante, + ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaBen, + ObjCFDITimbre.ComplementoPagos.CtaBeneficiario, + ObjCFDITimbre.ComplementoPagos.TipoCadPago, + ObjCFDITimbre.ComplementoPagos.CertPago, + ObjCFDITimbre.ComplementoPagos.CadPago, + ObjCFDITimbre.ComplementoPagos.SelloPago) + + + If ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados.Count > 0 Then + + + For Each doc As CFDIComplementoPagosDocsRelacionados In ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados + cfdi.PagoDoctoRelacionado(doc.IdDocumento, + doc.Serie, + doc.Folio, + doc.MonedaDR, + doc.TipoCambioDR, + doc.MetodoDePagoDR, + doc.NumParcialidad, + doc.ImpSaldoAnt, + doc.ImpPagado, + doc.ImpSaldoInsoluto) + + Next + + 'Estos impuestos aplicarían para anticipos + If ObjCFDITimbre.ComplementoPagos.TotalImpuestosRetenidos > 0 OrElse ObjCFDITimbre.ComplementoPagos.TotalImpuestosTrasladados > 0 Then + + cfdi.PagoImpuestos(ObjCFDITimbre.ComplementoPagos.TotalImpuestosRetenidos, ObjCFDITimbre.ComplementoPagos.TotalImpuestosTrasladados) + If (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "R").Count > 0 Then + For Each Ret As CFDIConceptosImpuestos In (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "R") + cfdi.PagoRetencion(Ret.Impuesto, Ret.Importe) + Next + End If + If (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "T").Count > 0 Then + For Each Tra As CFDIConceptosImpuestos In (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "T") + cfdi.PagoTraslado(Tra.Impuesto, Tra.TipoFactor, Tra.TasaOCuota, Tra.Importe) + Next + End If + + End If + + + + End If + + End If +#End Region + + + +#Region "Nomina12" + If ObjCFDITimbre.Comprobante.TipoComprobante = "N" Then + + 'cfdi.Esquema.AgregarEsquema("http://www.sat.gob.mx/nomina12 http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd") + cfdi.Nomina12(ObjCFDITimbre.Nomina.TipoNomina, ObjCFDITimbre.Nomina.FechaPago.ToString("yyyy-MM-dd"), ObjCFDITimbre.Nomina.FechaInicio.ToDate().ToString("yyyy-MM-dd"), ObjCFDITimbre.Nomina.FechaFin.ToDate().ToString("yyyy-MM-dd"), ObjCFDITimbre.Nomina.NumDiasPagados, If(ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0, ObjCFDITimbre.Nomina.TotalPercepciones, 0), If(ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0, ObjCFDITimbre.Nomina.TotalDeducciones, 0), If(ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0, ObjCFDITimbre.Nomina.TotalOtrosPagos, 0)) + + cfdi.Nomina12Emisor(ObjCFDITimbre.Emisor.CURP, If(ObjCFDITimbre.Nomina.Receptor.TipoContrato = "99", "", ObjCFDITimbre.Emisor.RegistroPatronal), ObjCFDITimbre.Emisor.RFC) + + If UsuarioActual.Empresa.UsaAC Then cfdi.Nomina12EntidadSNCF("IF", 90) + + +#Region "Receptor" + + cfdi.Nomina12Receptor(ObjCFDITimbre.Nomina.Receptor.CURP, + ObjCFDITimbre.Nomina.Receptor.NSS, + ObjCFDITimbre.Nomina.Receptor.FechaInicioContrato.ToDate().ToString("yyyy-MM-dd"), + ObjCFDITimbre.Nomina.Receptor.Antiguedad, + ObjCFDITimbre.Nomina.Receptor.TipoContrato, + ObjCFDITimbre.Nomina.Receptor.Sindicalizado, + ObjCFDITimbre.Nomina.Receptor.CodigoTipoJornada, + ObjCFDITimbre.Nomina.Receptor.CodigoRegimenContratacion, + ObjCFDITimbre.Nomina.Receptor.CodigoEmpleado, + ObjCFDITimbre.Nomina.Receptor.Departamento, + ObjCFDITimbre.Nomina.Receptor.Puesto, + ObjCFDITimbre.Nomina.Receptor.CodigoRiesgoPuesto, + If(ObjCFDITimbre.Nomina.TipoNomina = "E", "99", ObjCFDITimbre.Nomina.Receptor.TipoPeriodo), + ObjCFDITimbre.Nomina.Receptor.CodigoBanco, + ObjCFDITimbre.Nomina.Receptor.NumeroCuenta, + ObjCFDITimbre.Nomina.Receptor.SBC, + ObjCFDITimbre.Nomina.Receptor.SDI, + ObjCFDITimbre.Nomina.Receptor.CodigoEntidadFederativa) + 'cfdi.Nomina12SubContratacion("", "0") + 'cfdi.agregarNominaPercepcionesPercepcionAccionesOTitulos12("100", "200"); + 'cfdi.agregarNominaPercepcionesSeparacionIndemnizacion12("100", "10", "1000", "100", "50"); + 'cfdi.agregarNominaPercepcionesJubilacionPensionRetiro12("50", "100", "10", "100", "0"); + + + End If +#End Region + If ObjCFDITimbre.Nomina IsNot Nothing Then + + If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then + cfdi.Nomina12Percepciones(ObjCFDITimbre.Nomina.TotalSueldos, ObjCFDITimbre.Nomina.TotalIndemnizacion, ObjCFDITimbre.Nomina.TotalJubilacion, ObjCFDITimbre.Nomina.TotalPercepcionesGravado, ObjCFDITimbre.Nomina.TotalPercepcionesExento) + For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones + cfdi.Nomina12Percepcion(percep.TipoPercepcion, percep.Clave, percep.Concepto, Math.Round(percep.ImporteGravado, 2), Math.Round(percep.ImporteExento, 2)) + Next + End If + + 'deducciones al final + If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then + cfdi.Nomina12Deducciones(ObjCFDITimbre.Nomina.TotalDeduccionesOtras, Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2)) + For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones + cfdi.Nomina12Deduccion(deduc.TipoDeduccion, deduc.Clave, deduc.Concepto, Math.Round(deduc.Importe, 2)) + Next + End If + + If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then + For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras + cfdi.Nomina12HorasExtra(HoraExtra.Dias.ToEntero, HoraExtra.TipoHoras, HoraExtra.HorasExtra, HoraExtra.ImportePagado) + Next + End If + + If ObjCFDITimbre.Nomina.Incapacidades IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Incapacidades.Count > 0 Then + For Each Incap As CFDINominaIncapacidades In ObjCFDITimbre.Nomina.Incapacidades + cfdi.Nomina12Incapacidad(Incap.DiasIncapacidad.ToEntero, Incap.TipoIncapacidad, Incap.Importe) + Next + End If + + If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing Then + ' cfdi.agregarNominaOtrosPagosOtroPago12("002", "002", "Subsidio", "10.00"); + ' cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12("10.00"); + If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0 Then + For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos + cfdi.Nomina12OtroPago(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe) + If otpag.TipoOtroPago = "002" Then + cfdi.Nomina12SubsidioAlEmpleo(otpag.Subsidiocausado) + End If + + Next + End If + End If + End If +#End Region + + sw.Stop() + swTiempo.AppendFormat("Armado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() +#Region "Genera XML" + Dim ArchivoGenerado As Boolean = False + Try + cfdi.GenerarXMLB64(llaveBase64, Clave) + ArchivoGenerado = True + Catch ex As Exception + Retorno = cfdi.MensajeError + If Retorno = "" OrElse IsNothing(Retorno) Then + Retorno = $"llaveBase64 ={llaveBase64}
Clave ={Clave}
{ex.ToString()}" + End If + MensajeErrorCFDI = Retorno + End Try + +#End Region + sw.Stop() + swTiempo.AppendFormat("Genera: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + +#Region "Timbra" + If ArchivoGenerado Then + + 'cfdi.TimbrarCfdi(UsuarioServicio, ClaveServicio, UrlServicio, TimbraProduccion) + + 'sw.Stop() + 'swTiempo.AppendFormat("Timbrado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + 'swmili = sw.ElapsedMilliseconds + 'sw.Start() + ''Verifica el error + 'If cfdi.CodigoError = 0 Then + + ' Dim FolioFiscal As String + + ' UUID = cfdi.UUID + ' FolioFiscal = cfdi.UUID 'obtenerAtributo(cfdi.XmlTimbrado, "TimbreFiscalDigital", "UUID") 'XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText + + ' If FolioFiscal <> "" Then + + ' cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) + + ' sw.Stop() + ' swTiempo.AppendFormat("Guardado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + ' swmili = sw.ElapsedMilliseconds + ' sw.Start() + + ' If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then + + ' 'Actualiza Estatus Factura + ' If Ventas.CveVenta > 0 Then + + ' Using ObjVentas As New ClsVentas() + + ' If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=CvePACEspecial) Then + ' Retorno = "" + ' Else + ' Retorno = "Error" + ' End If + ' End Using + + ' 'Genero la addenda Ford + ' If Ventas.Cliente.Ford_GSDB <> "" Then + + ' Dim RutaCadena As String = String.Format("{0}{1}.xml", RutaArchivo, NombreArchivoXML) 'If(UsuarioActual.Empresa.FacturaProduccion, String.Format("{0}XML\{1}\{2}.xml", Ruta, Ventas.SerieFolio), String.Format("{0}XML\{1}\{2}.xml", Ruta, Ventas.TipoDocto, Ventas.SerieFolio)) + + ' Dim FolioFactura As String = "" + ' If UsuarioActual.CveEmpresa = 8 Then FolioFactura = Ventas.Folio.ToString ' sogo, pordefault manda el folio de la factura + ' GeneraAddendaFord(RutaCadena, FolioFactura, Ventas.FordASN, Ventas.FordGSDB) + + ' End If + + ' End If + + ' If ObjCFDITimbre.Comprobante.TipoComprobante = "N" Then + ' Using ObjNomina2 As New ClsNominas() + + ' If ObjNomina2.UpdateEstatusNomNominas(3, CvePACEspecial, FolioFiscal, "", ("01/01/2000").ToDate, ObjCFDITimbre.Nomina.CveNomina, 0, 0, 0, 0, 0) Then + ' Retorno = "" + ' Else + ' Retorno = "Error" + ' End If + ' End Using + ' End If + + ' If ObjCFDITimbre.Comprobante.TipoComprobante = "T" Then + ' Using ObjInv As New ClsInventarios() + ' If ObjInv.UpdateMovimientoTimbrado(Ventas.Inv_CveMovimiento, 1, FolioFiscal, MinFecha) Then + ' Retorno = "" + ' Else + ' Retorno = "Error" + ' End If + ' End Using + ' End If + ' End If + + ' If Not IO.Directory.Exists($"{UsuarioActual.Empresa.Ruta}CBB\") Then IO.Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}CBB\") + + ' Try + ' Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" + ' Dim b As Byte() = cfdi.QrCode($"?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={FolioFiscal}") + ' File.WriteAllBytes(RutaCBB, b) + ' Catch ex As Exception + ' OnError("Ocurrió un error al generar el QR", ex) + ' End Try + ' Retorno = "" + ' Else + ' Retorno = "No se pudo timbrar ante el SAT. UUID no generado." + ' End If + ' sw.Stop() + ' swTiempo.AppendFormat("Actualizado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + ' swmili = sw.ElapsedMilliseconds + ' sw.Start() + + 'Else + ' Retorno = cfdi.MensajeError + ' MensajeErrorCFDI = cfdi.MensajeError + ' If cfdi.Xml <> "" Then cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) + + ' End If + End If + +#End Region + GuardaLogTimbrado(swTiempo.ToString, CvePACEspecial) + Return Retorno + End Function + Public Sub GuardaLogTimbrado(Str As String, CvePAC As Integer) Dim ArchivoW As StreamWriter Dim strLineaTMP As String diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 63a198a2d..598bfd446 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -1261,13 +1261,14 @@ Partial Class Bancos_IE GvRH.DataBind() UpGvRH.Update() End Sub - Private Sub CargaCorteCaja() + Private Sub CargaCorteCaja(CveCuenta As Integer) 'Checar si hay un Turno Abierto Dim ObjPVenta As New ClsPuntoVenta - If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then - If ObjPVenta.DtResultados.Rows.Count > 0 Then - CveCorte = ObjPVenta.CveCorte - End If + + If ObjPVenta.GetCortesPorCuenta(CveCuenta, UsuarioActual.CveEmpresa) Then + + CveCorte = ObjPVenta.CveCorte + End If ObjPVenta.Dispose() End Sub @@ -1637,8 +1638,8 @@ Partial Class Bancos_IE End If 'PAGAR NC CON C.CH DEBE DESCONTAR EN EL CORTE - If UsuarioActual.TienePermisoProceso(160) AndAlso Opcion IsNot Nothing AndAlso Opcion = "DevDinV" AndAlso dr("CveTipoCuenta").ToString.ToEntero = 1 Then - CargaCorteCaja() + If Opcion IsNot Nothing AndAlso Opcion = "DevDinV" AndAlso dr("CveTipoCuenta").ToString.ToEntero = 1 Then + CargaCorteCaja(DdlCuenta.SelectedValue.ToEntero) End If If dr("UsaTarjeta").ToString = "True" Then diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index b5bfea7dd..9d90e76a0 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -5158,7 +5158,7 @@ - - + --%> + + + + + + + + @@ -6292,14 +6396,80 @@ } - //function ScrollVentanaAddProducto() { - // let wh = $(window).height(); - - // if (wh <= 770) { - // // $('#DVBodyAddProducto').css("max-height", 450); - // } - //} - + function ValidateCant(ncss, SubtotalValidar) { + + let SubTotal = 0.0; + + let CantidadS = $(".CssCantidad" + ncss).val(); + let PuS = $(".CssPU" + ncss).val(); + + let Cantidad = 0.0; + let Pu = 0.0; + + try{ + + if (CantidadS.length > 0 && PuS.length > 0) { + + Cantidad = parseFloat(CantidadS); + Pu = parseFloat(PuS); + + $(".CssImporte" + ncss).val(Cantidad * Pu); + + + }else{ + $(".CssImporte" + ncss).val("0"); + } + + + } catch (error) { + $(".CssImporte" + ncss).val("0"); + } + + //$('.ImporteCSS').each(function () { + + + // if(! isNaN(parseFloat($(this).val()) )){ + // SubTotal = SubTotal + parseFloat($(this).val()) + // } + + //}); + + ValidaBotonContrato(SubtotalValidar); + + + + //if (SubtotalValidar == SubTotal) { + // $('#BtnAplicarContrato').prop('disabled', false); + //} else { + // $('#BtnAplicarContrato').prop('disabled', true); + //} + + } + + function ValidaBotonContrato(SubtotalValidar) { + + let SubTotal = 0.0; + + + + $('.ImporteCSS').each(function () { + + if (!isNaN(parseFloat($(this).val()))) { + SubTotal = SubTotal + parseFloat($(this).val()) + } + }); + + + + if (SubtotalValidar == SubTotal) { + $('#BtnAplicarContrato').prop('disabled', false); + } else { + $('#BtnAplicarContrato').prop('disabled', true); + } + + $('#LblTotalContrato').text(SubTotal); + + } diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 596aa860d..4f8101173 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -1181,6 +1181,37 @@ Partial Class Compras_Compras + Private Property MaxIVAProcentaje As Decimal + Get + If ViewState("MaxIVAProcentaje") Is Nothing Then + Return 0 + Else + Return ViewState("MaxIVAProcentaje").ToString.ToDecimal + End If + End Get + Set(value As Decimal) + ViewState("MaxIVAProcentaje") = value + End Set + End Property + + + Private Property MAXRetIVAPorcentaje As Decimal + Get + If ViewState("MAXRetIVAPorcentaje") Is Nothing Then + Return 0 + Else + Return ViewState("MAXRetIVAPorcentaje").ToString.ToDecimal + End If + End Get + Set(value As Decimal) + ViewState("MAXRetIVAPorcentaje") = value + End Set + End Property + + + + + @@ -1206,7 +1237,7 @@ Partial Class Compras_Compras CveConceptoContableAlmacen = 0 EsNoDeducible = False CveTipoConcepto = 1 - CargaContratos() + 'CargaContratos() '******** Prorrateo ******************************************** If UsuarioActual.Empresa.Funcionalidad(117) <> "" Then btnProrateo.Visible = True @@ -1781,31 +1812,42 @@ Partial Class Compras_Compras Xml.Append(Replace(Replace(Replace(nodeconceptos.OuterXml, " 0 Then + MaxIVAProcentaje = ObjeFacturas.DtResultados.MAX("IVAPorcentaje").ToDecimal + MAXRetIVAPorcentaje = ObjeFacturas.DtResultados.MAX("RetIVAPorcentaje").ToDecimal + Else + MaxIVAProcentaje = 0 + End If + + + + 'TmpDT.Columns.Add("IVAPorcentaje") 'TmpDT.Columns.Add("RetIVAPorcentaje") 'TmpDT.Columns.Add("RetISRPorcentaje") 'TmpDT.Columns.Add("IEPSPSPorcentaje") 'TmpDT.Columns.Add("IEPSPSIVAPorcentaje") SubTotalConceptos = Math.Round(TmpDT.SUM("Total"), 2).ToDecimal - AddPS2(False) + AddPS2(False) - 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101 - Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") - For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows + 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101 + Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") + For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows - ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", drr("PS")) + ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", drr("PS")) - Next + Next - If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then - Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:

{0}", ProductosCodigoSATNoPermitidos.ToString) - Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) + If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then + Dim mensajeAdvertencia As String = String.Format("El comprobante contiene productos con código SAT '01010101', revise los productos:

{0}", ProductosCodigoSATNoPermitidos.ToString) + Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) + + End If End If - - End If - Else + Else CargaConceptosXML(XMLDoc) End If @@ -1831,7 +1873,7 @@ Partial Class Compras_Compras DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9")) DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11")) - + LiAccionesContratos.Visible = True End Select 'DIV ALIAS @@ -20475,22 +20517,183 @@ Partial Class Compras_Compras End Function - Private Sub CargaContratos() - DdlContrato.DataSource = GlobalDTContratos.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveContratoTipo IN(30,31) ") - DdlContrato.DataBind() - DdlContrato.Items.Insert(0, New System.Web.UI.WebControls.ListItem("Todos", "-1")) - End Sub + 'Private Sub CargaContratos() + ' DdlContrato.DataSource = GlobalDTContratos.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveContratoTipo IN(30,31) ") + ' DdlContrato.DataBind() + ' DdlContrato.Items.Insert(0, New System.Web.UI.WebControls.ListItem("Todos", "-1")) + 'End Sub - Protected Sub BtnModalContratos_Click(sender As Object, e As EventArgs) + 'Protected Sub BtnModalContratos_Click(sender As Object, e As EventArgs) - RegistraScript("$('#DvModalContratos').modal('hide');") - CveContratoObra = DdlContrato.SelectedValue.ToEntero + ' RegistraScript("$('#DvModalContratos').modal('hide');") + ' CveContratoObra = DdlContrato.SelectedValue.ToEntero + + + 'End Sub - End Sub Protected Sub LnkContratos_Click(sender As Object, e As EventArgs) - RegistraScript("$('#DvModalContratos').modal('show');") + + 'RegistraScript("$('#DvModalContratos').modal('show');") + + DdlContratosObra.Items.Clear() + DdlContratosObra.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}")) + DdlContratosObra.DataBind() + 'DdlContratosObra.Items.Insert(0, New ListItem("Seleccione", "-1")) + + + DdlTipoGastoObra.Items.Clear() + DdlTipoGastoObra.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + DdlTipoGastoObra.DataBind() + DdlTipoGastoObra.Items.Insert(0, New ListItem("Seleccione", "-1")) + + + + RegistraScript($"$('#DivmodalConmtrato').modal('show'); $( '#BtnAplicarContrato' ).prop( 'disabled', true ); ValidaBotonContrato({TxtSubTotal2.Text.ToDecimal});") + UpModalContrato.Update() + + End Sub + + + Protected Sub DdlContratosCompras_SelectedIndexChanged(sender As Object, e As EventArgs) + + + If DdlContratosObra.SelectedValue.ToEntero > 0 Then + Dim ObjContratos As New ClsContratos() + + If ObjContratos.GetContratosObraCompras(DdlContratosObra.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + + If ObjContratos.DtResultados.Rows.Count > 0 Then + GvContratosControl.DataSource = ObjContratos.DtResultados + 'BtnAplicarContrato.Visible = True + Else + GvContratosControl.DataSource = Nothing + 'BtnAplicarContrato.Visible = False + End If + + End If + + + ObjContratos.Dispose() + + GvContratosControl.DataBind() + + UpModalContrato.Update() + End If + + RegistraScript("$( '#BtnAplicarContrato' ).prop( 'disabled', true );") + + End Sub + + + Protected Sub BtnAplicarContrato_Click(sender As Object, e As EventArgs) + + + TmpDT.Rows.Clear() + + Dim CveTipoGastoObra As Integer = DdlTipoGasto.SelectedValue.ToEntero + + For Each GvRow As GridViewRow In GvContratosControl.Rows + + Dim CveContratoDetalle As Integer = GvRow.DataKey("CveContratoDetalle").ToEntero + + Dim Cantidad As Double = GvRow.FCTextBox("TxtCantidad").Text.ToDouble + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero + Dim PS As String = GvRow.DataKey("PS") + Dim PU As Double = GvRow.FCTextBox("TxtPU").Text.ToDouble + Dim TotalPS As Double = GvRow.FCTextBox("TxtImporte").Text.ToDouble + Dim CveUnidadMedida As Integer = GvRow.DataKey("CveUnidadMedida").ToEntero + Dim UMAbreviatura As String = GvRow.DataKey("Abreviatura").ToString + + Dim SubProyecto As String = GvRow.DataKey("SubProyecto") + Dim CveSubProyecto As Integer = GvRow.DataKey("CveSubProyecto").ToEntero + Dim Codigo As String = "" 'GvRow.DataKey("Codigo") + + Dim Proyecto As String = GvRow.DataKey("Proyecto") + Dim CveProyecto As Integer = GvRow.DataKey("CveProyecto").ToEntero + + Dim RetISR As Double = GvRow.DataKey("RetISR").ToString.ToDouble + Dim RetIVA As Double = MAXRetIVAPorcentaje 'GvRow.DataKey("RetIVA").ToString.ToDouble + + Dim IvaPS As Double = MaxIVAProcentaje + + Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = GvRow.DataKey("Clasificacion") + + + Dim IEPSPS As Double = GvRow.DataKey("IEPSPorcentaje").ToString.ToDouble + Dim IEPSPSIVA As Double = If(GvRow.DataKey("IEPSGrabaIVA").ToString = "True", IEPSPS, 0) + + + Dim CveTipoPS As Integer = GvRow.DataKey("CveTipoPS").ToEntero + + Dim CveSATPS As Integer = GvRow.DataKey("CveSATPS").ToEntero + + + Dim IdCuentaPorEjercer As Integer = -1 + Dim IdCuentaComprometido As Integer = -1 + + Dim TotalRow As Decimal = (PU * Cantidad).RoundSQL(2).ToDecimal + + If Cantidad > 0 Then + + + AddPS(Cantidad, CveUnidadMedida, UMAbreviatura, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyecto.ToString, SubProyecto, Proyecto, CveProyecto.ToString, "", PU, TotalRow, IvaPS, RetIVA, RetISR, IEPSPS, IEPSPSIVA, 0, -1, False, + CantidadF:=0, EntregaDirecta:=0, CveSATPS:=CveSATPS, CveTipoGasto:=DdlTipoGastoObra.SelectedValue.ToEntero, TipoGasto:=DdlTipoGastoObra.SelectedItem.Text, CveContratoDetalle:=CveContratoDetalle, CveCultivoCuadroDetalle:=-1) + + + 'AddPS(Cantidad, CvePS, PS, PS, PU, 0, TotalPS, + 'CveUnidadMedida, IvaPS, IEPSPS, IEPSPSIVA, CveClasificacion, UMAbreviatura, Clasificacion, CveProyecto, Proyecto, + 'CveSubProyecto, SubProyecto, Codigo, -1, 0, -1, -1, IdCuentaPorEjercer, + 'IdCuentaComprometido, -1, -1, -1, -1, + '-1, RetIVA, RetISR, CveContratoDetalle:=CveContratoDetalle, CveTipoGastoObra:=CveTipoGastoObra, CveCultivoCuadroDetalle:=-1, Cuadro:="") + + + '' ContratoObraAplciado = True + + End If + + Next + + 'CargaSuperior() + 'CargaDatosDetalles() + + + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + RegistraScript("$('#DivmodalConmtrato').modal('hide')") + ' UPPDetalle.Update() + + + End Sub + + Private Sub GvContratosControl_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvContratosControl.RowDataBound + + + If e.Row.RowType = DataControlRowType.DataRow Then + + Dim CveContratoDetalle As Integer = e.Row.DataKey("CveContratoDetalle").ToEntero + + e.Row.FCTextBox("TxtCantidad").CssClass = $"CssCantidad{CveContratoDetalle}" + e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"ValidateCant('{CveContratoDetalle}',{TxtSubTotal2.Text.ToDecimal})") + + e.Row.FCTextBox("TxtPU").CssClass = $"CssPU{CveContratoDetalle}" + e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", $"ValidateCant('{CveContratoDetalle}',{TxtSubTotal2.Text.ToDecimal})") + + + e.Row.FCTextBox("TxtImporte").CssClass = $"ImporteCSS CssImporte{CveContratoDetalle}" + + + + End If + + + End Sub + End Class Public Class MMensajeDevolucion diff --git a/Contratos/ContratoObra.aspx b/Contratos/ContratoObra.aspx index ef3d982e3..ea4c94e5d 100644 --- a/Contratos/ContratoObra.aspx +++ b/Contratos/ContratoObra.aspx @@ -1365,7 +1365,7 @@ @@ -1375,12 +1375,12 @@ - + - + @@ -2391,7 +2391,8 @@
- + + @@ -2401,6 +2402,18 @@ + + + + + + + + + + + +
diff --git a/Contratos/ContratoObra.aspx.vb b/Contratos/ContratoObra.aspx.vb index f627ea687..84bf44ec2 100644 --- a/Contratos/ContratoObra.aspx.vb +++ b/Contratos/ContratoObra.aspx.vb @@ -2299,7 +2299,7 @@ Partial Class Contratos_ContratoObra If e.Row.DBCampo("CveClasificacion").ToString.ToEntero = 0 Then e.Row.CssClass = "Totales white" - ElseIf e.Row.DBCampo("CvePS").ToString.ToEntero = 0 Then + ElseIf e.Row.DBCampo("CveContratoDetalle").ToString.Length = 0 And e.Row.DBCampo("CveClasificacion").ToString.ToEntero <> 0 Then e.Row.CssClass = "SubTotales" End If @@ -2313,10 +2313,13 @@ Partial Class Contratos_ContratoObra End If End Sub + Protected Sub MuestaModalVentasAvance(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow) + GvDatosVentasAvance.Visible = True + GvDatosVentasAvanceInterno.Visible = False 'Dim Btn = CType(sender, LinkButton) 'Dim Parametros = Btn.CommandArgument.Split("|"c) @@ -2347,6 +2350,43 @@ Partial Class Contratos_ContratoObra UpVentasAvance.Update() End Sub + + + Protected Sub MuestaModalVentasAvanceInterno(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow) + + + GvDatosVentasAvance.Visible = False + GvDatosVentasAvanceInterno.Visible = True + + + Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToEntero + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero + Dim CodigoPS As String = GvRow.DataKey("CodigoPS") + Dim Clasificacion As String = GvRow.DataKey("Clasificacion") + + Dim ObjContratos As New ClsContratos + + If ObjContratos.GetVentasAvanceObra(CveContrato, CveClasificacion, CvePS, 2) Then + GvDatosVentasAvanceInterno.DataSource = ObjContratos.DtResultados + RegistraScript("$('#ModalVentasAvance').modal('show');RecargaAvances = true;") + Else + Alert("Ocurrió un error al obtener el Listado de Ventas de Avance. Por favor vuelva a intentar", TipoMensaje.MsgError) + End If + + ObjContratos.Dispose() + GvDatosVentasAvanceInterno.DataBind() + + LbTituloModalVentasAvance.Text = "Compras de Avance" + + LbClasificacionVentasAvance.Text = Clasificacion + LbPSVentasAvance.Text = CodigoPS + + UpVentasAvance.Update() + + End Sub + #End Region #Region " TAB: REPORTE AVANCES POR DOCUMENTO " diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index b26306076..c46a48f5b 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -851,9 +851,9 @@ Partial Class General_SaldosIniciales Else - If Codigo.Length > 0 Then + 'If Codigo.Length > 0 Then - If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, + If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño, CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2, CveClasificacionDetalle:=CveClasificacionDetalle) <= 0 Then 'If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", "", Descripcion, 0, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, @@ -866,7 +866,7 @@ Partial Class General_SaldosIniciales ' DTPS = ObjPS.DtResultados ' End If End If - End If + 'End If End If Next diff --git a/Inventarios/EntradasSalidas.aspx b/Inventarios/EntradasSalidas.aspx index 7128c409a..8a4dca52d 100644 --- a/Inventarios/EntradasSalidas.aspx +++ b/Inventarios/EntradasSalidas.aspx @@ -83,7 +83,7 @@ Ver PrePóliza
  • -
  • diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 47d5174c7..b4a6d3302 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -363,6 +363,7 @@ Partial Class Inventarios_EntradasSalidas BtnEliminar.Enabled = PermiteEliminar() BtnContabilizar.Enabled = PermiteContabilizar() BtnNuevo.Enabled = PermiteCrearNuevo() + LnkCambioInventarioFisico.Visible = UsuarioActual.TienePermisoProceso(312) If CveMovimiento > 0 Then PermisoVerImportes() diff --git a/Sistemas/UsuarioDetalle.aspx b/Sistemas/UsuarioDetalle.aspx index 065bfcd50..e8217723e 100644 --- a/Sistemas/UsuarioDetalle.aspx +++ b/Sistemas/UsuarioDetalle.aspx @@ -57,7 +57,11 @@
  • - Clonar Usuario + + <%--Clonar Usuario --%> + + Clonar Usuario +
  • Actualizar Gestor Cobranza @@ -2398,7 +2402,17 @@
    -
    +
    + + +
    +

    + +

    +
    + + +
    diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index 64e54fe8e..67eb0733e 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -3701,9 +3701,16 @@ Partial Class Sistemas_UsuarioDetalle End If - ObjUsuarios.Dispose() - End If - + ObjUsuarios.Dispose() + + LblClonarMensaje.Text = $"En el usuario {TxtUsuario.Text} se reemplazará la información del usuario {DdlUsuarioClonar.SelectedItem.Text} con las siguientes secciones que seleccione." + Else + LblClonarMensaje.Text = "" + End If + + + + UpClonarUsuario.Update() End Sub Protected Sub BtnClonar_Click(sender As Object, e As EventArgs) @@ -4832,5 +4839,14 @@ Partial Class Sistemas_UsuarioDetalle End Try Return resultado - End Function + End Function + + Protected Sub LnkClonarUsuario_Click(sender As Object, e As EventArgs) + + RegistraScript("$('#DivClonar').modal('show');") + LblClonarMensaje.Text = "" + UpClonarUsuario.Update() + + End Sub + End Class diff --git a/Ventas/ActualizarPrecios.aspx.vb b/Ventas/ActualizarPrecios.aspx.vb index 22ef5da09..03e1642c5 100644 --- a/Ventas/ActualizarPrecios.aspx.vb +++ b/Ventas/ActualizarPrecios.aspx.vb @@ -540,7 +540,7 @@ Partial Class Ventas_ActualizarPrecios For Each Franquicia In Franquicias Dim CveFranquicia As Integer = Franquicia.ToEntero - Dim CvePS As Integer = GlobalDTPS(CveFranquicia, Codigo:=Codigo).FiltroPrimeroValor("CvePS", "").ToEntero + Dim CvePS As Integer = GlobalDTPS(CveFranquicia, Codigo:=Codigo.ToUpper).FiltroPrimeroValor("CvePS", "").ToEntero Dim CvePrecioLisa As Integer = GlobalDTPrecioListas(CveFranquicia).FiltroPrimeroValor("CvePrecioLista", String.Format("PrecioLista = '{0}'", PrecioLista)).ToEntero If CvePS <= 0 Then diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 2f20bd2b4..e64276495 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -4257,6 +4257,7 @@ +
    diff --git a/Ventas/RepComisionesJAM.aspx b/Ventas/RepComisionesJAM.aspx index cf06867b3..b3192cfd5 100644 --- a/Ventas/RepComisionesJAM.aspx +++ b/Ventas/RepComisionesJAM.aspx @@ -84,9 +84,9 @@ -
    +
    -
    Esquema Nuevo:
    +
    ProForma:
    diff --git a/Ventas/RepComisionesJAM.aspx.cs b/Ventas/RepComisionesJAM.aspx.cs index 721d3f7cf..f40c9d27d 100644 --- a/Ventas/RepComisionesJAM.aspx.cs +++ b/Ventas/RepComisionesJAM.aspx.cs @@ -62,7 +62,7 @@ public partial class Ventas_RepComisionesJAM : ClsPaginas GvDatos.Columns[21].Visible = UsuarioActual.TienePermisoProceso(311); GvDatos.Columns[22].Visible = UsuarioActual.TienePermisoProceso(311); - + divProforma.Visible = UsuarioActual.TienePermisoProceso(311); } @@ -135,6 +135,10 @@ public partial class Ventas_RepComisionesJAM : ClsPaginas e.Row.FCLinkButton("LnkInfo").Visible = false; } + + e.Row.Cells[23].ToolTip = string.Format("Utilidad:{0}", e.Row.DBCampo("UtilidadDetalle").FormatoNumero()); + //e.Row.FCLabel("LblCostoDolares").Visible = false; + //if (e.Row.DBCampo("CveMoneda").ToEntero() != 1) //{ // e.Row.Cells[15].Text = $"{e.Row.DBCampo("Costo").FormatoNumero()}
    {e.Row.DBCampo("CostoDolares").FormatoNumero()}"; diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 06fa7fab1..940dd9a15 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -7220,7 +7220,7 @@ if (Chk.checked) { let SaldoMaximoUtilizable = ToDouble(HdnSaldoMaximoUsados.value) let ImportesAsignados = 0; - + $('.ImportesRNCCargo').each(function () { if ($(this).context.id != TxtImporte.id) { ImportesAsignados += ToDouble($(this).val()); @@ -7235,16 +7235,15 @@ TxtImporte.value = FormatoNumero(Saldo, 2); } } else { - TxtImporte.value = ""; - Chk.checked = false; - //if (SaldoMaximoUtilizable > 0) { - // TxtImporte.value = ""; - // Chk.checked = false; - //} else { - // TxtImporte.value = FormatoNumero(Saldo, 2); - //} - } + if (SaldoMaximoUtilizable > 0) { + TxtImporte.value = ""; + Chk.checked = false; + } else { + TxtImporte.value = FormatoNumero(Saldo, 2); + } + } + } else { TxtImporte.value = ""; } diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 69d5f99cf..52c048cd1 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2958,7 +2958,7 @@ Partial Class Ventas If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then If ObjPVenta.DtResultados.Rows.Count > 0 Then - Total = ObjPVenta.DtResultados(0)("ImporteInicial").ToString().ToDouble + ObjPVenta.DtResultados(0)("VentasEfectivo").ToString().ToDouble + ObjPVenta.DtResultados(0)("Propina").ToString().ToDouble + ObjPVenta.DtResultados(0)("Ingresado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Retirado").ToString().ToDouble + Total = ObjPVenta.DtResultados(0)("ImporteInicial").ToString().ToDouble + ObjPVenta.DtResultados(0)("VentasEfectivo").ToString().ToDouble + ObjPVenta.DtResultados(0)("Ingresado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Retirado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Devoluciones").ToString().ToDouble DineroCaja = Total LblEfectivoEsperado.Text = Total.FormatoNumero(2) @@ -2977,10 +2977,15 @@ Partial Class Ventas Dr2("Importe") = ObjPVenta.DtResultados(0)("VentasEfectivo").ToString().ToDouble Dt.Rows.Add(Dr2) - Dim Dr3 = Dt.NewRow - Dr3("Descripcion") = "Propinas" - Dr3("Importe") = ObjPVenta.DtResultados(0)("Propina").ToString().ToDouble - Dt.Rows.Add(Dr3) + Dim Dr21 = Dt.NewRow + Dr21("Descripcion") = "Devoluciones" + Dr21("Importe") = ObjPVenta.DtResultados(0)("Devoluciones").ToString().ToDouble + Dt.Rows.Add(Dr21) + + 'Dim Dr3 = Dt.NewRow + 'Dr3("Descripcion") = "Propinas" + 'Dr3("Importe") = ObjPVenta.DtResultados(0)("Propina").ToString().ToDouble + 'Dt.Rows.Add(Dr3) Dim Dr4 = Dt.NewRow Dr4("Descripcion") = "Entradas" @@ -6847,7 +6852,7 @@ Partial Class Ventas Dim ClienteRetIVA = Me.ClienteRetIVA If ClienteRetIVA <= 0 Then - If CBool(TmpDT.Rows(e.RowIndex)("EsOutSourcing").ToString()) Then + If TmpDT.Rows(e.RowIndex)("EsOutSourcing").ToString() <> "" AndAlso CBool(TmpDT.Rows(e.RowIndex)("EsOutSourcing").ToString()) Then ClienteRetIVA = 0.06D DdlTipoRetencion.SelectedValueExist("4") LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero @@ -10078,6 +10083,11 @@ Partial Class Ventas tPS = String.Format("{0} {1}", drr("PS"), drr("Obs")) End If End If + + If tPS.Length > 1000 Then + tPS = tPS.Remove(999, tPS.Length - 1) + End If + 'condicionante, especial If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" ' les comentan que no debe de ir la etiqueta de "unidad" en el producto @@ -16395,10 +16405,10 @@ Partial Class Ventas Return False End If - If (Obs.Length + PS.Length > 1000) AndAlso DdlTipoComprobante.SelectedValue <> "Cot" Then - Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) - Return False - End If + 'If (Obs.Length + PS.Length > 1000) AndAlso DdlTipoComprobante.SelectedValue <> "Cot" Then + ' Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) + ' Return False + 'End If 'VALIDA CONCEPTOS EN CERO - YA SE VALIDA ANTES CON FUNCIONALIDAD - A MIRAS DE ELIMINAR - IPP 28 AGOSTO 2017 If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "Ant") Then @@ -24888,6 +24898,7 @@ Partial Class Ventas For Each RNC In ListaNC Dim UltimoRenglonRNC As Integer = 1 Dim TotalAcumuladoRNC As Decimal = 0 + Dim Terminar As Boolean = False For Each RowUsado As DataRow In Me.TmpDTRNCDetalleSelecciondas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows @@ -24911,8 +24922,32 @@ Partial Class Ventas TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA) + + 'SI EL IMPORTE ES MAYOR REALIZA EL AJUSTE + If TotalAcumuladoRNC > RNC.TotalRemNCAplicado Then + Terminar = True + 'RESTA LO SUMANDO DEL ACUMULADO + TotalAcumuladoRNC -= (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + + Dim Diferencia As Decimal = RNC.TotalRemNCAplicado - TotalAcumuladoRNC + + Dim TotalPartida As Decimal = (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + + Dim PorcentajePorAplicar As Decimal = (Diferencia / TotalPartida) + + Cantidad = Cantidad * PorcentajePorAplicar + + TotalCalculableImpuestos = (Cantidad * ImportePU) + ImporteIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2) + + + ImporteTotal = TotalCalculableImpuestos + + TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR) + End If + 'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE - If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count Then + If UltimoRenglonRNC = Me.TmpDTRNCDetalleSelecciondas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows.Count OrElse Terminar Then Dim Ajuste As Decimal = 0 If Math.Abs(RNC.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then Ajuste = RNC.TotalRemNCAplicado - TotalAcumuladoRNC @@ -24927,6 +24962,10 @@ Partial Class Ventas Obs, Cantidad, ImportePU, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, 0, ImporteRetIVA, 0, ImporteRetISR, 0, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1, DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalleRNC").ToString().ToEntero()) + + If Terminar Then + Exit For + End If Next Next @@ -28043,7 +28082,7 @@ Partial Class Ventas End Select If ChkMostarProductosRNC.Checked Then - + Dim TotalAcumulado As Decimal = 0 Me.AplicaRNCXDetalle = True For Each GvRow As GridViewRow In GvRemisionesNCDetalle.Rows @@ -28051,12 +28090,13 @@ Partial Class Ventas If GvRow.FCCheckBox("ChkAplicar").Checked Then Dim Rows = TmpDTRNCDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}") For Each row In Rows - row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToEntero() + row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal() TmpDTRNCDetalleSelecciondas.Rows.Add(row.ItemArray) Next End If End If Next + Dim TerminarCiclo As Boolean = False For Each Dr As DataRow In TmpDTRNCDetalleSelecciondas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa) @@ -28082,6 +28122,14 @@ Partial Class Ventas End If Next + TotalAcumulado += TotalRNC + + 'SI SE EXECE RESTA AL ULTIMO + If TotalAcumulado > LtlSMU.Text.ToDecimal() Then + TerminarCiclo = True + TotalAcumulado -= TotalRNC + TotalRNC = LtlSMU.Text.ToDecimal() - TotalAcumulado + End If RemNC.TotalRemNCAplicado = TotalRNC 'MARCA LA VENTA QUE FUE USADA PARA EL FILTRO @@ -28095,6 +28143,10 @@ Partial Class Ventas End If ListaRemisionesNC.Add(RemNC) + + If TerminarCiclo Then + Exit For + End If Next Else