From 84034685c8768e7792a815a8a4965826cc69b933 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 15 Aug 2019 11:38:20 -0700 Subject: [PATCH 01/23] CORRECIONES DE IVA --- Ventas/Ventas.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 7d017af26..8c3cdd346 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -14405,7 +14405,7 @@ Partial Class Ventas If TotalAmortizacion > 0 AndAlso TotalSubTotal = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("3") Then For Each dr As DataRow In TmpDT.Rows - dr("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("ImporteRetISR") = 0 + dr("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("ImporteRetISR") = 0 : dr("PorcentajeIVA") = 0 : dr("IVA") = 0 Next If TmpDTImpuestos IsNot Nothing Then From daf307a0a9a02d61aa0d3c6d015a9c1c4fb4982d Mon Sep 17 00:00:00 2001 From: janeth arvizu Date: Thu, 15 Aug 2019 11:41:47 -0700 Subject: [PATCH 02/23] =?UTF-8?q?Se=20cambi=C3=B3=20DropDownList=20de=20Cl?= =?UTF-8?q?iente=20por=20DropDownLost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/RepVentasUtilidadPadre.aspx | 3 +-- Ventas/RepVentasUtilidadPadre.aspx.vb | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ventas/RepVentasUtilidadPadre.aspx b/Ventas/RepVentasUtilidadPadre.aspx index 8a2c8861e..290095da5 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx +++ b/Ventas/RepVentasUtilidadPadre.aspx @@ -139,8 +139,7 @@ Cliente:
- - +
Vendedor: diff --git a/Ventas/RepVentasUtilidadPadre.aspx.vb b/Ventas/RepVentasUtilidadPadre.aspx.vb index 0fd0d5983..83458643a 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx.vb +++ b/Ventas/RepVentasUtilidadPadre.aspx.vb @@ -39,6 +39,7 @@ Partial Class Ventas_RepVentasUtilidadPadre #Region " INICIALIZA VALORES " Private Sub CargaCombos() + txtFechaI.Text = Now.FirstDayOfMonth.ToShortDateString txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString From c88f65899238a3c38aecc11024765f292503d219 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 15 Aug 2019 11:43:56 -0700 Subject: [PATCH 03/23] Actualizar Clase de produccion --- App_Code/ClsVentas.vb | 7754 +++++++++++++++++++++-------------------- 1 file changed, 3879 insertions(+), 3875 deletions(-) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index dc07b5d17..448b3e53a 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -1,3875 +1,3879 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.SqlClient -Imports Extensiones -Imports System -Imports System.Configuration - -Public Class ClsVentas - Implements IDisposable - -#Region "Campos" - - 'SQL - Private SqlConexion As SqlConnection - Private SqlAdapter As SqlDataAdapter - Private SqlCommand As SqlCommand - Private SqlTransacc As SqlTransaction - Private Data As DataTable - Private Dataset As DataSet - - 'Atributos de la clase - Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - -#End Region - -#Region "Propiedades" - Public ReadOnly Property DtResultados() As DataTable - Get - DtResultados = Data - End Get - End Property - Public ReadOnly Property DataSetResultados() As DataSet - Get - DataSetResultados = Dataset - End Get - End Property - - Public Property CveVenta As Integer - Public Property CveVentaDetalle As Integer - Public ReadOnly Property SerieFolio As String - Public ReadOnly Property Serie As String - Public ReadOnly Property Folio As Integer - - Public Property SerieVenta As String - Public Property SubTotalVenta As Double - Public Property SubTotalVentaDolares As Double - Public Property FechaVenta As String - Public Property Costo As Double - Public Property FolioCosto As String - Public Property FechaSalidaCosto As String - - Public Property Utilidad As Double - Public Property PorUtilidad As Double - Public Property Perdida As Double - Public Property PorPerdida As Double - - Public Property Neto As Double - Public Property PorNeto As Double - Public Property CveClasificacionDetalle As Integer - - - -#End Region - - Public Function IniciaTransacSQL() As SqlTransaction - If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() - Return SqlTransacc - End Function - - Public Sub Commit() - SqlTransacc.Commit() - End Sub - Public Sub RollBack() - SqlTransacc.Rollback() - End Sub - Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) - - If TransaccionCompartida Is Nothing Then - SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString - Try - SqlConexion.Open() - Catch ex As Exception - OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) - End Try - Else - SqlConexion = TransaccionCompartida.Connection - SqlTransacc = TransaccionCompartida - End If - - SqlAdapter = New SqlDataAdapter("", SqlConexion) - - End Sub - Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) - With SqlAdapter.SelectCommand - .Parameters.Clear() - .CommandText = pStrSQL - .CommandType = TipoComando - End With - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - Data = New DataTable - End Sub - Public Function GetVenta(CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaTerminal(CveVentaTerminal As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetTerminal") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la Venta, VentaTerminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentas(CveEmpresa As Integer, TipoDocto As String, Serie As String, Folio As Integer, Codigo As String, CveCliente As Integer, - CveSubProyecto As Integer, CveEstatus As Integer, CveUsuario As Integer, FechaI As String, FechaF As String, FolioFiscal As String, Optional CveClienteSucursal As Integer = -1, Optional CvePS As Integer = -1, Optional PedidoContrato As String = "-1", - Optional OrdenCompra As String = "-1", Optional CveUsuarioConsulta As Integer = -1, Optional ClienteRFC As String = "-1", - Optional CveEmpresaCRM As Integer = -1, Optional CveAcercamientoCRM As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_VentasGetBuscar") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@Serie", SqlDbType.VarChar).Value = Serie - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato - .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@ClienteRFC", SqlDbType.VarChar).Value = ClienteRFC - .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM - .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaComplementos() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ComplementosGet") - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los complementos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaOtrosConceptos(CveEmpresa As Integer, Optional CveVenta As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasConceptosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los conceptos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaImpuestosLocales(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasImpuestosLocalesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la Deduccion de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasImpuestosLocalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion - .Add("@Importe", SqlDbType.Money).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar impuestos locales al documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasImpuestosLocalesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion - .Add("@Importe", SqlDbType.Money).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddVenta(TipoDocto As String, FolioFact As Integer, CveCliente As Integer, CveClienteSucursal As Integer, SubTotal As Double, Descuento As Double, Amortizacion As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double, - CveMoneda As Integer, TipoCambio As Double, CveMetodoPago As Integer, CondicionesPago As Integer, FormaPago As Integer, FechaVencimiento As DateTime, Fecha As DateTime, MotivoDescuento As String, Observaciones As String, FechaEjecucion As Date, - CveVendedor As Integer, Alfa1 As String, Alfa2 As String, Alfa3 As String, Num1 As Double, Num2 As Double, Num3 As Double, - Fech1 As Date, Fech2 As Date, Fech3 As Date, CveCorte As Integer, CveMesa As Integer, NumeroPersonas As Integer, CvePrePoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer, - Optional Propina As Double = -1, Optional CveVentaTerminal As Integer = -1, Optional AtencionA As String = "-1", Optional CveContrato As Integer = -1, - Optional CveVentaPadre As Integer = -1, Optional Det_OrdenCompra As String = "", Optional Det_FechaOrdenCompra As String = "", Optional otros As Decimal = 0, - Optional Entrega As String = "-1", Optional Vigencia As DateTime = MinFecha, Optional CveAlmacenTraspasoDestino As Integer = -1, Optional CveAlmacenTraspasoOrigen As Integer = -1, Optional CveDireccionEnvio As Integer = -1, - Optional CveOC As Integer = -1, Optional IEPS As Double = 0, Optional Serie As String = "-1", Optional TelefonoGenerico As String = "", Optional CveCondicionEntrega As Integer = -1, Optional PedidoContrato As String = "-1", - Optional ObservacionesAlmacen As String = "", Optional CveSubProyecto As Integer = -1, Optional CveSubProyectoEjecucion As Integer = -1, Optional CveSubProyectoCobranza As Integer = -1, - Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, - Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, - Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@FolioFact", SqlDbType.Int).Value = FolioFact - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@SubTotal", SqlDbType.Float).Value = SubTotal - .Add("@Descuento", SqlDbType.Float).Value = Descuento - .Add("@Amortizacion", SqlDbType.Float).Value = Amortizacion - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@RetIVA", SqlDbType.Float).Value = RetIVA - .Add("@RetISR", SqlDbType.Float).Value = RetISR - .Add("@ImpuestoLocal", SqlDbType.Float).Value = ImpuestoLocal - .Add("@Total", SqlDbType.Float).Value = Total - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago - .Add("@FormaPago", SqlDbType.Int).Value = FormaPago - .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@MotivoDescuento", SqlDbType.VarChar).Value = MotivoDescuento - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@FechaEjecucion", SqlDbType.Date).Value = FechaEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@Alfa1", SqlDbType.VarChar).Value = Alfa1 - .Add("@Alfa2", SqlDbType.VarChar).Value = Alfa2 - .Add("@Alfa3", SqlDbType.VarChar).Value = Alfa3 - .Add("@Num1", SqlDbType.Int).Value = Num1 - .Add("@Num2", SqlDbType.Int).Value = Num2 - .Add("@Num3", SqlDbType.Int).Value = Num3 - .Add("@Fech1", SqlDbType.VarChar).Value = IIf(Fech1.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech1.ToString("yyyy/MM/dd")) - .Add("@Fech2", SqlDbType.VarChar).Value = IIf(Fech2.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech2.ToString("yyyy/MM/dd")) - .Add("@Fech3", SqlDbType.VarChar).Value = IIf(Fech3.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech3.ToString("yyyy/MM/dd")) - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveMesa", SqlDbType.Int).Value = CveMesa - .Add("@NumeroPersonas", SqlDbType.Int).Value = NumeroPersonas - .Add("@Propina", SqlDbType.Float).Value = Propina - .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVentaPadre", SqlDbType.Int).Value = CveVentaPadre - .Add("@Det_OrdenCompra", SqlDbType.VarChar).Value = Det_OrdenCompra - .Add("@Det_FechaOrdenCompra", SqlDbType.VarChar).Value = Det_FechaOrdenCompra - .Add("@Otros", SqlDbType.Money).Value = otros - '.Add("@Ref", SqlDbType.VarChar).Value = Ref - .Add("@Entrega", SqlDbType.VarChar).Value = Entrega - .Add("@Vigencia", SqlDbType.Date).Value = Vigencia - .Add("@CveAlmacenTraspasoDestino", SqlDbType.Int).Value = CveAlmacenTraspasoDestino - .Add("@CveAlmacenTraspasoOrigen", SqlDbType.Int).Value = CveAlmacenTraspasoOrigen - .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio - .Add("@CveOC", SqlDbType.Int).Value = CveOC - .Add("@Serie", SqlDbType.VarChar).Value = Serie - .Add("@TelefonoGenerico", SqlDbType.VarChar).Value = TelefonoGenerico - .Add("@CveCondicionEntrega", SqlDbType.Int).Value = CveCondicionEntrega - .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato - .Add("@ObservacionesAlmacen", SqlDbType.VarChar).Value = ObservacionesAlmacen - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveSubProyectoCobranza", SqlDbType.Int).Value = CveSubProyectoCobranza - .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 - .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 - .Add("@CveUsoCFDI", SqlDbType.SmallInt).Value = CveUsoCFDI - .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra - .Add("@CveCuentaTerminal", SqlDbType.VarChar).Value = CveCuentaTerminal - .Add("@CveTipoRelacion", SqlDbType.Int).Value = CveTipoRelacion - - .Add("@CveTipoAmortizacionAnticipo", SqlDbType.Int).Value = CveTipoAmortizacionAnticipo - .Add("@CveVentaRelacion", SqlDbType.Int).Value = CveVentaRelacion - .Add("@ImporteRelacion", SqlDbType.Money).Value = ImporteRelacion - - .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM - .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM - .Add("@EsInterno", SqlDbType.Int).Value = EsInterno - - .Add("@DiasCredito", SqlDbType.Int).Value = DiasCredito - .Add("@EsDiasCreditoFijo", SqlDbType.Bit).Value = EsDiasCreditoFijo - .Add("@AnticipoEspecial", SqlDbType.Bit).Value = AnticipoEspecial - - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue - End With - 'SqlTypes.SqlDateTime.Null - Try - SqlAdapter.Fill(Data) - CveVenta = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero - If Data.Rows.Count > 0 Then _SerieFolio = Data.Rows(0)("vFolio").ToString : _Serie = Data.Rows(0)("Serie").ToString : _Folio = Data.Rows(0)("Folio").ToString.ToEntero - - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") And Ex1.Message.Contains("UK_Ventas_TipoDocto_Serie_Folio_CveSubProyecto") Then - Alert(String.Format("el Folio '{0}' ya se encuentra registrado", FolioFact), TipoMensaje.MsgAdvertencia) - GuardaLog(String.Format("el folio ya se encuentra registrado {0}", Ex1.Message)) - Else - Me.OnError("Ocurrió un error al Guardar la Venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentas(SubTotal As Double, Descuento As Double, IVA As Double, IEPS As Double, Total As Double, CveMoneda As Integer, TipoCambio As Double, - Fecha As Date, Observaciones As String, CveEmpresa As Integer, CveVenta As Integer, CveMetodoPago As Integer, FormaPago As Integer, - Optional TipoDocto As String = "Cot", Optional Vigencia As Date = MinFecha, Optional CondicionesPago As Integer = -1, - Optional AtencionA As String = "-1", Optional PedidoContrato As String = "-1", Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, - Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Double = -1, Optional RetISR As Double = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@SubTotal", SqlDbType.Float).Value = SubTotal - .Add("@Descuento", SqlDbType.Float).Value = Descuento - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@Total", SqlDbType.Float).Value = Total - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio - .Add("@RetIVA", SqlDbType.Float).Value = RetIVA - .Add("@RetISR", SqlDbType.Float).Value = RetISR - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago - .Add("@FormaPago", SqlDbType.Int).Value = FormaPago - .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA - .Add("@Vigencia", SqlDbType.Date).Value = Vigencia - .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato - .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 - .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el documento.", 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") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la fecha de vencimiento de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function AddVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasPagoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@Importe", SqlDbType.Float).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el Pago de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemoveVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasPagoRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar el Pago a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function EliminarVenta(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_EliminarVenta") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al intentar eliminar la venta. Verifique que el registro no tenga relaciones (Movimientos de almacén, Factura, Anticipos...)", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaPrePoliza(IDPoliza As Integer, CvePrePoliza As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentaPrePolizaUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@IDPoliza", SqlDbType.Int).Value = IDPoliza - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al guardar la poliza de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddLeyendaFiscal(CveVenta As Integer, CveLeyenda As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasLeyendasFiscalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveLeyendaFiscal", SqlDbType.Int).Value = CveLeyenda - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Leyenda Fiscal en la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusFactura(Estatus As Integer, FolioFiscal As String, SelloSAT As String, FechaCancelacion As DateTime, CveVenta As Integer, Optional IdPolizaCancelacion As Integer = -1, Optional CvePAC As Integer = -1, Optional CveEstatusRefacturacion As Integer = 0) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasUpdateEstatus") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEstatusFactura", SqlDbType.Int).Value = Estatus - .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal - .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloSAT - .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@IdPolizaCancelacion", SqlDbType.Int).Value = IdPolizaCancelacion - .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC - .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el estatus de la factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasEstatusRefacturacionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el estatus de refacturación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusVenta(CveVenta As Integer, CveEstatusFactura As Integer, CveEmpresa As Integer, Optional Num2 As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_VentasEstatusUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Num2", SqlDbType.Float).Value = Num2 - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus de la Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateCancelaVenta(CveVenta As Integer, FechaCancelacion As DateTime, SelloCancelacionSAT As String, CveEmpresa As Integer, Optional CvePAC As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_VentasCancelacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion - .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloCancelacionSAT - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus de cancelacion Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaMail(Tipo As Integer, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasUpdateMail") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus del Mail.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaTimbre(Timbro As Boolean, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasUpdateTimbre") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Timbre", SqlDbType.Bit).Value = If(Timbro, 1, 0) - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus del Timbrado.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - - Return Retorno - End Function - Public Function UpdateVentaFolioFiscal(FolioFiscal As String, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUpdateFolioFiscal") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el folio fiscal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaCotizacion(CveVenta As Integer, CveCotizacion As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasUpdateCotizacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveCotizacion", SqlDbType.Int).Value = CveCotizacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al vincular la Venta con la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ObtenerCreditoRestante(CveCliente As Integer, CveSucCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ClientesLimiteCreditoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ObtenerCreditoRestanteSucursalCliente(CveSucCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_SucClientesLimiteCreditoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function ObtenerClienteLimitesVenta(CveCliente As Integer, CveEmpresa As Integer) As Integer - Dim Retorno As Integer = 0 - DataAdapter("PA_Vta_ClientesLimitesVentaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Opcion", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@OpcionMsg", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - SerieVenta = SqlAdapter.SelectCommand.Parameters("@OpcionMsg").Value.ToString - Retorno = SqlAdapter.SelectCommand.Parameters("@Opcion").Value.ToString.ToEntero - - Catch ex As Exception - OnError("Ocurrió un error al obtener el limite de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AgregarVentaOCDetalle(CveVentaDetalle As Integer, CveOCDetalle As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_AddVentaOCDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveOCDetalle", SqlDbType.Int).Value = CveOCDetalle - .Add("@Cantidad", SqlDbType.Int).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el detalle de la OC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AgregarRemisionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_AddRemisionDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el detalle de la Remisión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function VerificarRemisionFacturada(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VerificarRemisionFacturada") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al verificar la remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function LiberarRemisionesFacturadas(CveVenta As Integer, Optional CveVentaLiberar As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarRemisionesFacturadas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaLiberar", SqlDbType.Int).Value = CveVentaLiberar - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar las remisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RemisionesXCancelarAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaRemision", SqlDbType.Int).Value = CveVentaRemision - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las remisiones x cancelar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function LiberarCotizacionesFacturadas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarCotizacionesFacturadas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar las cotizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function LiberarPedidos2Facturados(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarPedidos2Facturados") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar los pedidos2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function LiberarOCFacturadas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarOCFacturadas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar las Ordenes de Compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaRemision(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasRemisionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al vincular la Venta con la Remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function MarcarRemisionesSinSurtir(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_MarcarRemisionSinSurtir") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al marcar la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaCadenaOriginal(CadenaOriginal As String, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasCadenaOriginalAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CadenaOriginal", SqlDbType.VarChar).Value = CadenaOriginal - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaCuentaTerminal(CveCuentaTerminal As Integer, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasCuentaTerminalUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuentaTerminal", SqlDbType.Int).Value = CveCuentaTerminal - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la cuenta terminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetCadenaOriginal(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasCadenaOriginalGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Obtener la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "V E N T A - D E T A L L E" - Public Function GetVentaDetalle(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el detalle de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddVentaDetalle(CveVenta As Integer, CvePS As Integer, Cantidad As Double, CveUnidadMedida As Integer, PU As Double, IVA As Double, - Total As Double, Observaciones As String, Descuento As Double, TipoDescuento As Integer, CveSubProyecto As Integer, - CvePresupuestoIngreso As Integer, Optional TiempoEntrega As String = "", Optional CveVentaDetallePadre As Integer = -1, - Optional CveContratoDetalle As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional IEPS As Double = -1, Optional PorcentajeIEPS As Double = 0, Optional CvePromocionDetalle As Integer = -1, - Optional CveMovimientoDetallePedido As Integer = -1, Optional ImporteRetIVA As Double = 0, Optional PorcentajeRetIVA As Double = 0, - Optional ImporteRetISR As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional CuentaPredial As String = "") As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@PU", SqlDbType.Float).Value = PU - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@ImporteRetIVA", SqlDbType.Float).Value = ImporteRetIVA - .Add("@ImporteRetISR", SqlDbType.Float).Value = ImporteRetISR - .Add("@PorcentajeIVA", SqlDbType.Float).Value = PorcentajeIVA - .Add("@PorcentajeIEPS", SqlDbType.Float).Value = PorcentajeIEPS - .Add("@PorcentajeRetIVA", SqlDbType.Float).Value = PorcentajeRetIVA - .Add("@PorcentajeRetISR", SqlDbType.Float).Value = PorcentajeRetISR - .Add("@Total", SqlDbType.Float).Value = Total - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@Descuento", SqlDbType.Float).Value = Descuento - .Add("@TipoDescuento", SqlDbType.Int).Value = TipoDescuento - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CvePresupuestoIngreso", SqlDbType.Int).Value = CvePresupuestoIngreso - .Add("@TiempoEntrega", SqlDbType.VarChar).Value = TiempoEntrega - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle - .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle - .Add("@CveMovimientoDetallePedido", SqlDbType.Int).Value = CveMovimientoDetallePedido - .Add("@CuentaPredial", SqlDbType.VarChar).Value = CuentaPredial - End With - - Try - SqlAdapter.Fill(Data) - CveVentaDetalle = Data.Rows(0)("CveVentaDetalle").ToString.ToEntero - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddVentaDetalleCaracteristica(CveVentaDetalle As Integer, CvePS As Integer, CveOpcion As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetallesCaracteristicasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la Caracteristica del Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Double, PU As Double, IEPS As Double, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetalleRemisionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVenta - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@PU", SqlDbType.Float).Value = PU - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al editar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateVentasDevolucionAlmacen(EstatusDevolucion As Integer, CveVenta As Integer) As Boolean - - 'NOTA: - ' - 0: No requiere devolucion - ' - 1: Requiere devolucion - ' - 2: Devolucion ya realizada - - - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDevolucionAlmacenUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@EstatusDevolucion", SqlDbType.TinyInt).Value = EstatusDevolucion - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la solicitud de Devolución de Almacén.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveVentasDetalle(CveVenta As Integer, Optional CveVentaDetalle As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "V E N T A - P R E S U P U E S T O" - Public Function GetPresupuestosVentas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AC_PresupuestosVentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "R E P O R T E S - D E - V E N T A S" - 'Reporte de Ventas - Public Function GetRepVentas(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As String, CveUsuario As Integer, CveEstatus As String, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", - Optional CveProyecto As Integer = -1, Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional CveClienteClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasGetRep") - - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepTopVenta(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetTopRepPS") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepTopCompras(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Comp_GetTopRepPS") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - 'Reporte de Ventas por Período - Public Function GetRepVentasPeriodos(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", - Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, - Optional CveClienteClasificacion As Integer = -1) As Boolean - - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetRepPeriodo") - - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@VerEn", SqlDbType.Int).Value = VerEn - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - 'Reporte de Ventas - Detalle - Public Function GetRepVentasDetalle(Gpo As Integer, Anio As Integer, Mes As Integer, AnioMes As String, Fecha As String, CveCliente As Integer, IVA As String, - Vendedor As String, CveUsuario As Integer, CveEstatus As String, FechaI As Date, FechaF As Date, CveCorte As Integer, TipoDocto As String, - CveSubProyectoEjecucion As Integer, CveEmpresa As Integer, FechaIEjec As Date, FechaFEjec As Date, Optional CveProyecto As Integer = -1, - Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveMoneda As Integer = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional CveClienteClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasGetRepDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@Anio", SqlDbType.Int).Value = Anio - .Add("@Mes", SqlDbType.Int).Value = Mes - .Add("@AnioMes", SqlDbType.VarChar).Value = AnioMes - .Add("@Fecha", SqlDbType.VarChar).Value = Fecha - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - - Return Retorno - End Function - - 'Reporte de Ventas - Productos y Servicios - Public Function GetRepProductosServicios(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, - FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, - Optional TipoCambio As Integer = -1, Optional TCEspecifico As Double = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional TipoDocto As String = "-1", Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetRepPS") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetRepProductosServiciosDetalle(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, - FechaI As Date, FechaF As Date, Mes As Integer, FechaIEjec As Date, FechaFEjec As Date, MesEjec As Integer, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1, - Optional TipoDocto As String = "-1", Optional GPO As Integer = -1, Optional CveMoneda As Integer = -1, Optional TipoCambio As Integer = -1, - Optional TCEspecifico As Double = 0, Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetRepPSDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Mes", SqlDbType.Int).Value = Mes - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@MesEjec", SqlDbType.Int).Value = MesEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetRepNCxAplicar(CveClienteSucursal As Integer, CveSubProyecto As Integer, CveCliente As Integer, FechaInicio As DateTime, FechaFin As DateTime, ConSaldo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_NotasCreditosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Notas de Crédito por Aplicar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "V E N T A S - P R E C I O L I S T A S" 'Hecho por Charlie 1/9/2016 - Public Function GetPrecioListas(Optional CveEmpresa As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Listas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPrecioLista(CveUsuario As Integer, CveEmpresa As Integer, PrecioLista As String, Porcentaje As Double) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Lista con el mismo Nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al la Lista", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdatePrecioLista(PrecioLista As String, Estatus As Boolean, CveUsuario As Integer, Porcentaje As Double, CvePrecioLista As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Lista con el mismo nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en la Lista", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePrecioLista(CvePrecioLista As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("La Lista no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "V E N T A S - M E S A S" - Public Function GetMesas(Optional CveEmpresa As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Mesas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddMesa(Mesa As String, CveUsuario As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Mesa", SqlDbType.VarChar).Value = Mesa - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar el Mesa", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateMesa(Mesa As String, Estatus As Boolean, CveSubProyecto As Integer, CveMesa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Mesa", SqlDbType.VarChar).Value = Mesa - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveMesa", SqlDbType.Int).Value = CveMesa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en el Mesa", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveMesa(CveMesa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveMesa", SqlDbType.Int).Value = CveMesa - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Mesa no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "V E N T A S - B I T A C O R A" - Public Function GetVta_Bitacora(CveVenta As Integer, FechaI As String, FechaF As String, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_BitacoraGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la Bitacora de las Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddVta_Bitacora(CveVenta As Integer, Fecha As DateTime, Observacion As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_BitacoraAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Bitacora de la Venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - -#End Region - -#Region "R E P O R T E S - D E L - P V " - Public Function GetRepVentasPV(FechaI As String, FechaF As String, FechaIEjec As String, FechaFEjec As String, CveCliente As Integer, CveSubProyecto As Integer, CveSubProyectoEjecucion As Integer, - Vendedor As String, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_PV_VentasGetRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaIEjec", SqlDbType.VarChar).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.VarChar).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - - Public Function GetRepABT(Ejercicio As Integer, Periodo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetRepABT") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Periodo", SqlDbType.Int).Value = Periodo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte ABT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region " PROMOCIONES " - Public Function GetPromociones(CvePromocion As Integer, Fecha As String, CveVendedor As Integer, CveCliente As Integer, Estatus As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@Fecha", SqlDbType.VarChar).Value = Fecha - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Promociones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddPromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Integer - Dim Retorno = -1 - DataAdapter("PA_Vta_PromocionesAdd") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@Promocion", SqlDbType.VarChar).Value = Promocion - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CvePromocion", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CvePromocion").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error al agregar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdatePromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CvePromocion As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesUpdate") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@Promocion", SqlDbType.VarChar).Value = Promocion - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CvePromocion", SqlDbType.Float).Value = CvePromocion - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePromociones(CvePromocion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region " PROMOCIONES DETALLE " - Public Function GetPromocionesPS(CvePS As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveCliente As Integer, CveVendedor As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesPSGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetPromocionesDetalle(CvePromocion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddPromocionesDetalle(CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleAdd") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion - .Add("@Promocion", SqlDbType.Money).Value = Promocion - .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior - .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion - .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion - .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes - .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes - .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles - .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves - .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes - .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado - .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo - .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio - .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdatePromocionesDetalle(CvePromocionDetalle As Integer, CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleUpdate") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion - .Add("@Promocion", SqlDbType.Money).Value = Promocion - .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior - .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion - .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion - .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes - .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes - .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles - .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves - .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes - .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado - .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo - .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio - .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin - .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePromocionesDetalle(CvePromocionDetalle As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "Pruebas" - - Public Function GetDeduccion(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de las deducciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddDeduccion(Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion - .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje - .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error al tratar de agregar la deducción. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function RemoveDeduccion(CveVentaDeduccion As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesRemove") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al tratar de eliminar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - - - End Function - Public Function UpdateDeduccion(CvePrincipal As Integer, Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrincipal", SqlDbType.VarChar).Value = CvePrincipal - .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion - .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje - .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error al tratar de Actualizar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - - - -#End Region - - Public Function GetPrecios(CveClasificacion As Integer, CvePS As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ActualizarPreciosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los precios de los precios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "Firmas" - - Public Function GetVentasFirmas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function AddVentasFirmas(CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Titulo", SqlDbType.VarChar).Value = Titulo - .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Puesto", SqlDbType.VarChar).Value = Puesto - .Add("@Lado", SqlDbType.Bit).Value = Lado - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function UpdateVentasFirmas(CveVentaFirma As Integer, CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Titulo", SqlDbType.VarChar).Value = Titulo - .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Puesto", SqlDbType.VarChar).Value = Puesto - .Add("@Lado", SqlDbType.VarChar).Value = Lado - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function RemoveVentasFirmas(CveVentaFirma As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - -#End Region - -#Region " I M P U E S T O S L O C A L E S" - Public Function AddImpuestosLocales(ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al añadir los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetImpuestosLocales(CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateImpuestosLocales(CveImpuestoLocal As Integer, ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal - .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemoveImpuestosLocales(CveImpuestoLocal As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - - End Function - - -#End Region - - -#Region " ANTICIPOS/NOTASCREDITO - VENTAS " - Public Function GetVentasAntNC(CveVenta As Integer, CveVentaNC As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasAntNCGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaNC", SqlDbType.Int).Value = CveVentaNC - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las NotasCrédito/Anticipos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - - Public Function GetRemisionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveContrato As Integer, Tipo As Integer, CveMoneda As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasRemisionesFacturasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetOCSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasOrdenesCompraGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las ordenes de compra sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepRemisionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSubProyecto As String, CveCliente As Integer, CveContrato As Integer, CveVendedor As String, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepRemisionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepRemisionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, Optional CveUsuarioConsulta As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepRemisionesDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReporteHP(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Compu_HPRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReporteVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUtilidadGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - - Try - SqlAdapter.Fill(Data) - - If Data.Rows.Count > 0 Then _Neto = Data.Rows(0)("Neto").ToString.ToDouble : _PorNeto = Data.Rows(0)("PorNeto").ToString.ToDouble - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReporteVentasUtilidadDetalle(CveVendedor As String, CveVenta As Integer, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUtilidadDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - - Try - SqlAdapter.Fill(Data) - If Data.Rows.Count > 1 Then _SerieVenta = Data.Rows(1)("SerieFolio").ToString : _SubTotalVenta = Data.Rows(0)("SubTotal").ToString.ToDouble : _SubTotalVentaDolares = Data.Rows(0)("SubTotalDolares").ToString.ToDouble : _FechaVenta = Data.Rows(1)("FechaVenta").ToString - If Data.Rows.Count > 1 Then _Costo = Data.Rows(0)("CostoVta").ToString.ToDouble : _FolioCosto = Data.Rows(1)("FolioMovto").ToString : _FechaSalidaCosto = Data.Rows(1)("FechaMovto").ToString - - If Data.Rows.Count > 0 Then _Utilidad = Data.Rows(0)("Utilidad").ToString.ToDouble : _PorUtilidad = Data.Rows(0)("PorUtilidad").ToString.ToDouble - If Data.Rows.Count > 0 Then _Perdida = Data.Rows(0)("Perdida").ToString.ToDouble : _PorPerdida = Data.Rows(0)("PorPerdida").ToString.ToDouble - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReportePadreVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Gpo As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepVentasUtilidadGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Gpo", SqlDbType.Int).Value = Gpo - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetReporteVentasAutorizaciones(CveUsuario As Integer, CveEstatusFactura As Integer, CveSubProyecto As Integer, FechaInicio As Date, FechaFin As Date, CveCliente As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepVentasAutorizacionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Autorizaciones de Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region " Facturas " - - Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveEmpresa As Integer) As Boolean - Dim OnError As Boolean = False - - - DataAdapter("PA_Vta_FacturasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Folio", SqlDbType.VarChar).Value = Folio - .Add("@FechaFacturaI", SqlDbType.Date).Value = FechaFacturaI - .Add("@FechaFacturaF", SqlDbType.Date).Value = FechaFacturaF - .Add("@RFC", SqlDbType.VarChar).Value = RFC - .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor - .Add("@FueValidado", SqlDbType.Int).Value = FueValidado - .Add("@CveResponsable", SqlDbType.Int).Value = CveResponsable - .Add("@CveFactura", SqlDbType.Int).Value = CveFactura - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - Public Function GetFacturasCanceladasPendientes(FoliosFiscales As String, CveEmpresa As Integer) As Boolean - Dim OnError As Boolean = False - DataAdapter("PA_Vta_FacturasCanceladasPendientesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FoliosFiscales", SqlDbType.VarChar).Value = FoliosFiscales - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener las facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - - Public Function UpdateVentaFacturas(CveFactura As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim OnError As Boolean = False - - - DataAdapter("PA_Vta_FacturaVentaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveFactura", SqlDbType.Int).Value = CveFactura - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al actualizar las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - Public Function ProcesoPrepolizasCancelacion(CveVenta As Integer, CveUsuario As Integer) As Boolean - Dim OnError As Boolean = False - - DataAdapter("PA_Vta_ProcesoPrepolizasCancelacion") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al crear las prepolizas de cancelación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function -#End Region - - -#Region "C O N D I C I O N E S D E E N T R E G A" - Public Function GetCondicionesEntrega(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CondicionesEntregaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region " CANCELAR PEDIDO " - Public Function CancelarPedido(CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CancelarPedido") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cancelar el pedido.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "Punto Venta" - - Public Function AddVtaCortesDetalles(CveCorte As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CortesDetallesAdd") - - - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@Importe", SqlDbType.Money).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al guardar el Detalle del Corte de Turno.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetCortesDetalleVentasResumen(CveCorte As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_CortesDetalleVentasResumenGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalle de cortes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region " CANCELAR ANTE SAT " - Public Function CancelarVentasSAT(StrVentas As String) As String - Dim CveVentas = StrVentas.Split(","c) - Dim CveVentasError As New List(Of Integer) - - If CveVentas IsNot Nothing Then - Dim ObjVentas As New ClsVentas - Dim ObjCancelacion As New Timbrado - Dim ObjUsuario As New ClsSisUsuarios - Dim Usuario As Usuario = Nothing - Dim ObjEmpresa As New ClsSisEmpresas() - - Dim FolioFiscal = "-1" - Dim CveEstatus = -1 - Dim Total = 0.0D - Dim RFCReceptor = "-1" - Dim Nombre = "-1" - Dim DbRowVenta As DataRow - Dim CveUsuario = -1 - Dim pCveEmpresa = -1 - Dim Contraseña = "-1" - - For Each PCveVenta In CveVentas - If ObjVentas.GetVenta(PCveVenta.ToEntero, -1) Then - DbRowVenta = ObjVentas.DtResultados.Rows(0) - - FolioFiscal = DbRowVenta("FolioFiscal").ToString - CveEstatus = DbRowVenta("CveEstatusFactura").ToString.ToEntero - Total = DbRowVenta("Total").ToString.ToDecimal - RFCReceptor = DbRowVenta("ClienteRFC").ToString - CveUsuario = DbRowVenta("CveUsuario").ToString.ToEntero - pCveEmpresa = DbRowVenta("CveEmpresa").ToString.ToEntero - Nombre = DbRowVenta("Nombre").ToString - - If ObjUsuario.GetUsuarios(CveUsuario, -1, -1) Then - Contraseña = ObjUsuario.DtResultados.Rows(0)("Contraseña").ToString - Else - CveVentasError.Add(PCveVenta.ToEntero) - Continue For - End If - Usuario = ObjUsuario.ValidaUsuario(Nombre, Contraseña, IMEI) - - If ObjEmpresa.GetEmpresas(pCveEmpresa, "-1", "-1", "-1", "-1") Then - Usuario.Empresa = ObjEmpresa.Empresa - Usuario.CveEmpresa = ObjEmpresa.Empresa.CveEmpresa - Else - CveVentasError.Add(PCveVenta.ToEntero) - Continue For - End If - - - 'SOLO SI ESTA CANCELADA ANTE SAT EN SIG SE INTENTARA CANCELAR DE NUEVO CONTRA EL SAT - If CveEstatus = 5 Then - If ObjCancelacion.CFDICancelar(Usuario.Empresa, FolioFiscal, Total, RFCReceptor, Usuario.Empresa.RFC) Then - If Not ObjVentas.UpdateEstatusFactura(5, FolioFiscal, ObjCancelacion.CancelacionAcuse, Now, PCveVenta.ToEntero, -1, CvePAC:=Usuario.Empresa.CvePAC) Then - CveVentasError.Add(PCveVenta.ToEntero) - End If - Else - CveVentasError.Add(PCveVenta.ToEntero) - End If - Else - CveVentasError.Add(PCveVenta.ToEntero) - End If - End If - Next - - ObjVentas.Dispose() - ObjUsuario.Dispose() - ObjEmpresa.Dispose() - Else - - End If - - Return "Procesando" - End Function -#End Region - -#Region "Remisiones" - Public Function GetRemisionesRelacionadas(CveVenta As Integer, TipoDocto As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RemisionesRelacionadasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Remisiones/Facturas Relacionadas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - - Public Function VentasSaldar(CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional Amortizacion As Integer = -1, Optional CveVentaAmortizada As Integer = -1, Optional CveContrato As Integer = -1, Optional Fecha As Date = MinFecha) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasSaldar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Amortizacion", SqlDbType.Int).Value = Amortizacion - .Add("@CveVentaAmortizada", SqlDbType.Int).Value = CveVentaAmortizada - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al saldar una venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - -#Region "COTIZACIONES SIN FACTURAR" - - Public Function GetCotizacionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasCotizacionesFacturasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepCotizacionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepCotizacionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepCotizacionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepCotizacionesDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AgregaCotizacionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_AddCotizacionDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@Cantidad", SqlDbType.Int).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el detalle de la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "C O B R A N Z A V E N T A S" - Public Function UpdateVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveCobranzaEstatusTurno As Integer, FechaCobranza As DateTime, CobranzaObservacion As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasCobranzaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza - .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion - .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function UpdateAsignaVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveCobranzaEstatusTurno As Integer, CobranzaObservacion As String, FechaCobranza As DateTime) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AsignaCobranzaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza - .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza - .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion - .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function GetCobranzaEstatus(CveCobranzaEstatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_EstatusCobranzaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function GetCobranzaTurnoEstatus(CveCobranzaEstatusTurno As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_EstatusTurnoCobranzaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function GetGestionCobranza(CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveResponsableCobranza As Integer, CveCobranzaTurno As Integer, TipoPago As String, FechaI As String, FechaF As String, CveEmpresa As Integer, TipoCambio As Integer, TCEspecifico As Double) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_GestionCobranzaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza - .Add("@CveResponsableCobranza", SqlDbType.Int).Value = CveResponsableCobranza - .Add("@CveCobranzaTurno", SqlDbType.Int).Value = CveCobranzaTurno - .Add("@TipoPago", SqlDbType.VarChar).Value = TipoPago - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener la gestión de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function AddVisitaCobranza(CveVenta As Integer, CveUsuarioCobranza As Integer, FechaCobranza As Date, Observaciones As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VisitaCobranzaAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza - .Add("@FechaCobranza", SqlDbType.Date).Value = FechaCobranza - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar guardar la visita de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region "C O M P L E M E N T O S" - Public Function UpdateVentasComplementos(CveVenta As Integer, TipoProceso As String, TipoComite As String, IdContabilidad As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_UpdateVentaComplementos") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@TipoProceso", SqlDbType.VarChar).Value = TipoProceso - .Add("@TipoComite", SqlDbType.VarChar).Value = TipoComite - .Add("@IdContabilidad", SqlDbType.VarChar).Value = IdContabilidad - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los complementos de la venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region " FLETES " - Public Function GetFletes(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_WT_Viajes") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener los Fletes", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region "Metodos y Forma de Pago" - - Public Function GetFormaPago() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_FormaPagoGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al obtener Formas de pago", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetMetodoPago() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_MetodoPagoGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al obtener Métodos de Pago.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - - Public Function GetTiposRelacion() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_TiposRelacionGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al obtener Tipos de relación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "Tipo Documentos" - - Public Function GetTiposDocumentos() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_TipoDocumentosGet") - With SqlAdapter.SelectCommand.Parameters - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los tipos de documentos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "DEVOLUCIONES" - Public Function AddVentaDetalleDevolucion(pCveVentaDetalle As Integer, CveVentaDetalleDevolucion As Integer, Cantidad As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetalleDevolucionAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = pCveVentaDetalle - .Add("@CveVentaDetalleDevolucion", SqlDbType.Int).Value = CveVentaDetalleDevolucion - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveVentaDetalleDevolucion(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetalleDevolucionRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "COMISIONES" - - Public Function GetRepComisiones(FechaI As Date, FechaF As Date, CveSubProyecto As Integer, CveVendedor As Integer, CveCliente As Integer, CveUsuario As Integer, CveEmpresa As Integer, TipoSaldo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepComisiones119") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoSaldo", SqlDbType.Int).Value = TipoSaldo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "REPORTE DE PRODUCTOS SERVICIOS PERIODO" - - - Public Function GetRepPSPeriodo(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", - Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, - Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, Optional CvePS As Integer = -1, Optional CveClasificacion As Integer = -1, - Optional CveCategoria As Integer = -1, Optional TipoFecha As Integer = 1, Optional CveClienteClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetRepPeriodoPS") - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@VerEn", SqlDbType.Int).Value = VerEn - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria - .Add("@TipoFecha", SqlDbType.Int).Value = TipoFecha - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Productos Servicios por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "Ventas Refacturas" - Public Function GetVentaRefacturacion(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentaRefacturacionGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener datos de la venta refacturada .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "REPORTE DE ANTICIPOS - NC - IXC" - - Public Function GetRepAnticiposNCIXC(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1, Optional ConSaldo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepAnt-NC-IXC") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte - .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepAnticiposNCIXCDetalle(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, ConSaldo As Integer, Tipo As Integer, CveMoneda As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepAnt-NC-IXCDetalle") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte - .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "BUSCAR OC REGISTRADAS" - Public Function GetOCVentas(CveCliente As Integer, OC As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetOCVentas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@OC", SqlDbType.VarChar).Value = OC - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Ordenes de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function -#End Region - -#Region "CLASIFICACIONES DETALLE" - Public Function GetClasificacionDetalle(CveEmpresa As Integer, Optional CveClasificacionDetalle As Integer = -1, Optional Estatus As Integer = -1, Optional CveClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las clasificaciones detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function AddClasificacionDetalle(ClasificacionDetalle As String, CveClasificacion As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveClasificacionDetalle", SqlDbType.Int).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - CveClasificacionDetalle = SqlAdapter.SelectCommand.Parameters("@CveClasificacionDetalle").Value.ToString.ToEntero - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al guardar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function UpdateClasificacionDetalle(CveClasificacionDetalle As Integer, ClasificacionDetalle As String, CveClasificacion As Integer, Estatus As Boolean) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function RemoveClasificacionDetalle(CveClasificacionDetalle As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region "PEDIDOS2" - - Public Function AddVentaDetallePedido2(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetallePedidos2Add") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la venta detalle pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function GetVentaDetallePedido2SinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveMoneda As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetallePedidos2SinFacturarGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@Tipo", SqlDbType.Float).Value = Tipo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function GetVentasPedidos2Totales(CveCliente As Integer, Ventas As String, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetallePedidos2Totales") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Ventas", SqlDbType.VarChar).Value = Ventas - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 totales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function UpdateVentaPedido2(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasPedido2Update") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al vincular la Venta con el Pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepPedidos2SinFacturar(FechaI As Date, FechaF As Date, FechaV As Date, CveSubProyecto As String, CveCliente As Integer, CveVendedor As String, CveEmpresa As Integer, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepPedidos2Get") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaV", SqlDbType.Date).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepPedidos2SinFacturarDetalle(FechaI As Date, FechaF As Date, FechaV As Date, CveCliente As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, CveVendedor As String, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepPedidos2DetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaV", SqlDbType.Date).Value = FechaV - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 sin facturar detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "COSTO PROMEDIO VENTA" - - Public Function RepCostoPromedioVenta(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CostoPromedioVentaRep") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function RepVentasNetasResumen(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasNetasResumenRep") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - - Public Function RepIngresos(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Ventas_RepIngresos", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - - Public Function RepIngresosDetalle(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer, CveConceptoContable As Integer, CveCuenta As Integer) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Ventas_RepIngresosDetalle", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Ingresos Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - -#Region " AUTORIZACION DESCUENTOS " - - Public Function AutorizacionDescuentosGet(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosGet", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al obtener las Autorizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionDescuentosRemove(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosRemove", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al eliminar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionDescuentosAdd(CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosAdd", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al agregar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionDescuentosUpdate(CveAutorizacionDescuento As Integer, CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosUpdate", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al actualizar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionEstatusUpdate(CveAutorizacionDescuento As Integer, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionEstatusUpdate", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al actualizar el Estatus de la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function -#End Region - -#Region "CANCELACION REMISION" - - Public Function UpdateCancelaRemision(CveVenta As Integer, SeCancelaRemision As Boolean) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_CancelaRemisionUpdate", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@SeCancelaRemision", SqlDbType.Bit).Value = SeCancelaRemision - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar que la remision sea cancelable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - -#End Region - -#Region "REPORTE PUES SIN PAGO" - - Public Function GetPUESinPago(FI As DateTime, FF As DateTime, CveCliente As Integer, CveSubProyecto As Integer, CveVendedor As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_PUESinPagoGet", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FI", SqlDbType.DateTime).Value = FI - .Add("@FF", SqlDbType.DateTime).Value = FF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las ventas con método de pago PUE.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - -#End Region - - Public Function GetAnticiposEspeciales(FI As DateTime, FF As DateTime, CveSubProyecto As Integer, AnticipoEspecial As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_AnticiposEspecialesGet", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FI", SqlDbType.DateTime).Value = FI - .Add("@FF", SqlDbType.DateTime).Value = FF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@AnticipoEspecial", SqlDbType.Int).Value = AnticipoEspecial - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Anticipo Ficticio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - Public Function GetRepArqueos(Anio As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - Dataset = New DataSet() - DataAdapter("PA_Vta_RepArqueosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Anio", SqlDbType.Int).Value = Anio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Dataset) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - 'compila - End Function - Public Function GetRepArqueosDetalle(Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - Dataset = New DataSet() - DataAdapter("PA_Vta_RepArqueosDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Dataset) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - 'compila - End Function -#Region "Conciliación emitidas SAT" - - Public Function ConciliacionemitidasSATGet(cveEmpresa As Int32) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_ConciliacionemitidasSATGet", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de 'Conciliación emitidas SAT'.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - retorno = False - End Try - Return retorno - End Function -#End Region -#Region "IDisposable Support" - - - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - ' TODO: dispose managed state (managed objects). - If Not Data Is Nothing Then Data.Dispose() - If Not Dataset Is Nothing Then Dataset.Dispose() - If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() - If Not SqlCommand Is Nothing Then SqlCommand.Dispose() - If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() - If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() - If Not SqlConexion Is Nothing Then SqlConexion.Dispose() - End If - - ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. - ' TODO: set large fields to null. - End If - Me.disposedValue = True - End Sub - - ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. - 'Protected Overrides Sub Finalize() - ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ' Dispose(False) - ' MyBase.Finalize() - 'End Sub - - ' This code added by Visual Basic to correctly implement the disposable pattern. - Public Sub Dispose() Implements IDisposable.Dispose - ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - Dispose(True) - GC.SuppressFinalize(Me) - End Sub -#End Region -End Class - +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports System +Imports System.Configuration + +Public Class ClsVentas + Implements IDisposable + +#Region "Campos" + + 'SQL + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlCommand As SqlCommand + Private SqlTransacc As SqlTransaction + Private Data As DataTable + Private Dataset As DataSet + + 'Atributos de la clase + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + +#End Region + +#Region "Propiedades" + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get + End Property + Public ReadOnly Property DataSetResultados() As DataSet + Get + DataSetResultados = Dataset + End Get + End Property + + Public Property CveVenta As Integer + Public Property CveVentaDetalle As Integer + Public ReadOnly Property SerieFolio As String + Public ReadOnly Property Serie As String + Public ReadOnly Property Folio As Integer + + Public Property SerieVenta As String + Public Property SubTotalVenta As Double + Public Property SubTotalVentaDolares As Double + Public Property FechaVenta As String + Public Property Costo As Double + Public Property FolioCosto As String + Public Property FechaSalidaCosto As String + + Public Property Utilidad As Double + Public Property PorUtilidad As Double + Public Property Perdida As Double + Public Property PorPerdida As Double + + Public Property Neto As Double + Public Property PorNeto As Double + Public Property CveClasificacionDetalle As Integer + + + +#End Region + + Public Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + Return SqlTransacc + End Function + + Public Sub Commit() + SqlTransacc.Commit() + End Sub + Public Sub RollBack() + SqlTransacc.Rollback() + End Sub + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + + If TransaccionCompartida Is Nothing Then + SqlConexion = New SqlConnection + SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + Try + SqlConexion.Open() + Catch ex As Exception + OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + End Try + Else + SqlConexion = TransaccionCompartida.Connection + SqlTransacc = TransaccionCompartida + End If + + SqlAdapter = New SqlDataAdapter("", SqlConexion) + + End Sub + Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = pStrSQL + .CommandType = TipoComando + End With + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + Data = New DataTable + End Sub + Public Function GetVenta(CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaTerminal(CveVentaTerminal As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetTerminal") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la Venta, VentaTerminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentas(CveEmpresa As Integer, TipoDocto As String, Serie As String, Folio As Integer, Codigo As String, CveCliente As Integer, + CveSubProyecto As Integer, CveEstatus As Integer, CveUsuario As Integer, FechaI As String, FechaF As String, FolioFiscal As String, Optional CveClienteSucursal As Integer = -1, Optional CvePS As Integer = -1, Optional PedidoContrato As String = "-1", + Optional OrdenCompra As String = "-1", Optional CveUsuarioConsulta As Integer = -1, Optional ClienteRFC As String = "-1", + Optional CveEmpresaCRM As Integer = -1, Optional CveAcercamientoCRM As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasGetBuscar") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@ClienteRFC", SqlDbType.VarChar).Value = ClienteRFC + .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM + .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaComplementos() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ComplementosGet") + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los complementos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaOtrosConceptos(CveEmpresa As Integer, Optional CveVenta As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasConceptosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los conceptos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaImpuestosLocales(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasImpuestosLocalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la Deduccion de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasImpuestosLocalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar impuestos locales al documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasImpuestosLocalesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddVenta(TipoDocto As String, FolioFact As Integer, CveCliente As Integer, CveClienteSucursal As Integer, SubTotal As Double, Descuento As Double, Amortizacion As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double, + CveMoneda As Integer, TipoCambio As Double, CveMetodoPago As Integer, CondicionesPago As Integer, FormaPago As Integer, FechaVencimiento As DateTime, Fecha As DateTime, MotivoDescuento As String, Observaciones As String, FechaEjecucion As Date, + CveVendedor As Integer, Alfa1 As String, Alfa2 As String, Alfa3 As String, Num1 As Double, Num2 As Double, Num3 As Double, + Fech1 As Date, Fech2 As Date, Fech3 As Date, CveCorte As Integer, CveMesa As Integer, NumeroPersonas As Integer, CvePrePoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer, + Optional Propina As Double = -1, Optional CveVentaTerminal As Integer = -1, Optional AtencionA As String = "-1", Optional CveContrato As Integer = -1, + Optional CveVentaPadre As Integer = -1, Optional Det_OrdenCompra As String = "", Optional Det_FechaOrdenCompra As String = "", Optional otros As Decimal = 0, + Optional Entrega As String = "-1", Optional Vigencia As DateTime = MinFecha, Optional CveAlmacenTraspasoDestino As Integer = -1, Optional CveAlmacenTraspasoOrigen As Integer = -1, Optional CveDireccionEnvio As Integer = -1, + Optional CveOC As Integer = -1, Optional IEPS As Double = 0, Optional Serie As String = "-1", Optional TelefonoGenerico As String = "", Optional CveCondicionEntrega As Integer = -1, Optional PedidoContrato As String = "-1", + Optional ObservacionesAlmacen As String = "", Optional CveSubProyecto As Integer = -1, Optional CveSubProyectoEjecucion As Integer = -1, Optional CveSubProyectoCobranza As Integer = -1, + Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, + Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, + Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@FolioFact", SqlDbType.Int).Value = FolioFact + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@SubTotal", SqlDbType.Float).Value = SubTotal + .Add("@Descuento", SqlDbType.Float).Value = Descuento + .Add("@Amortizacion", SqlDbType.Float).Value = Amortizacion + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@RetIVA", SqlDbType.Float).Value = RetIVA + .Add("@RetISR", SqlDbType.Float).Value = RetISR + .Add("@ImpuestoLocal", SqlDbType.Float).Value = ImpuestoLocal + .Add("@Total", SqlDbType.Float).Value = Total + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago + .Add("@FormaPago", SqlDbType.Int).Value = FormaPago + .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@MotivoDescuento", SqlDbType.VarChar).Value = MotivoDescuento + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@FechaEjecucion", SqlDbType.Date).Value = FechaEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@Alfa1", SqlDbType.VarChar).Value = Alfa1 + .Add("@Alfa2", SqlDbType.VarChar).Value = Alfa2 + .Add("@Alfa3", SqlDbType.VarChar).Value = Alfa3 + .Add("@Num1", SqlDbType.Int).Value = Num1 + .Add("@Num2", SqlDbType.Int).Value = Num2 + .Add("@Num3", SqlDbType.Int).Value = Num3 + .Add("@Fech1", SqlDbType.VarChar).Value = IIf(Fech1.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech1.ToString("yyyy/MM/dd")) + .Add("@Fech2", SqlDbType.VarChar).Value = IIf(Fech2.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech2.ToString("yyyy/MM/dd")) + .Add("@Fech3", SqlDbType.VarChar).Value = IIf(Fech3.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech3.ToString("yyyy/MM/dd")) + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveMesa", SqlDbType.Int).Value = CveMesa + .Add("@NumeroPersonas", SqlDbType.Int).Value = NumeroPersonas + .Add("@Propina", SqlDbType.Float).Value = Propina + .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVentaPadre", SqlDbType.Int).Value = CveVentaPadre + .Add("@Det_OrdenCompra", SqlDbType.VarChar).Value = Det_OrdenCompra + .Add("@Det_FechaOrdenCompra", SqlDbType.VarChar).Value = Det_FechaOrdenCompra + .Add("@Otros", SqlDbType.Money).Value = otros + '.Add("@Ref", SqlDbType.VarChar).Value = Ref + .Add("@Entrega", SqlDbType.VarChar).Value = Entrega + .Add("@Vigencia", SqlDbType.Date).Value = Vigencia + .Add("@CveAlmacenTraspasoDestino", SqlDbType.Int).Value = CveAlmacenTraspasoDestino + .Add("@CveAlmacenTraspasoOrigen", SqlDbType.Int).Value = CveAlmacenTraspasoOrigen + .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio + .Add("@CveOC", SqlDbType.Int).Value = CveOC + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@TelefonoGenerico", SqlDbType.VarChar).Value = TelefonoGenerico + .Add("@CveCondicionEntrega", SqlDbType.Int).Value = CveCondicionEntrega + .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato + .Add("@ObservacionesAlmacen", SqlDbType.VarChar).Value = ObservacionesAlmacen + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveSubProyectoCobranza", SqlDbType.Int).Value = CveSubProyectoCobranza + .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 + .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 + .Add("@CveUsoCFDI", SqlDbType.SmallInt).Value = CveUsoCFDI + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + .Add("@CveCuentaTerminal", SqlDbType.VarChar).Value = CveCuentaTerminal + .Add("@CveTipoRelacion", SqlDbType.Int).Value = CveTipoRelacion + + .Add("@CveTipoAmortizacionAnticipo", SqlDbType.Int).Value = CveTipoAmortizacionAnticipo + .Add("@CveVentaRelacion", SqlDbType.Int).Value = CveVentaRelacion + .Add("@ImporteRelacion", SqlDbType.Money).Value = ImporteRelacion + + .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM + .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM + .Add("@EsInterno", SqlDbType.Int).Value = EsInterno + + .Add("@DiasCredito", SqlDbType.Int).Value = DiasCredito + .Add("@EsDiasCreditoFijo", SqlDbType.Bit).Value = EsDiasCreditoFijo + .Add("@AnticipoEspecial", SqlDbType.Bit).Value = AnticipoEspecial + + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue + End With + 'SqlTypes.SqlDateTime.Null + Try + SqlAdapter.Fill(Data) + CveVenta = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero + If Data.Rows.Count > 0 Then _SerieFolio = Data.Rows(0)("vFolio").ToString : _Serie = Data.Rows(0)("Serie").ToString : _Folio = Data.Rows(0)("Folio").ToString.ToEntero + + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") And Ex1.Message.Contains("UK_Ventas_TipoDocto_Serie_Folio_CveSubProyecto") Then + Alert(String.Format("el Folio '{0}' ya se encuentra registrado", FolioFact), TipoMensaje.MsgAdvertencia) + GuardaLog(String.Format("el folio ya se encuentra registrado {0}", Ex1.Message)) + Else + Me.OnError("Ocurrió un error al Guardar la Venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentas(SubTotal As Double, Descuento As Double, IVA As Double, IEPS As Double, Total As Double, CveMoneda As Integer, TipoCambio As Double, + Fecha As Date, Observaciones As String, CveEmpresa As Integer, CveVenta As Integer, CveMetodoPago As Integer, FormaPago As Integer, + Optional TipoDocto As String = "Cot", Optional Vigencia As Date = MinFecha, Optional CondicionesPago As Integer = -1, + Optional AtencionA As String = "-1", Optional PedidoContrato As String = "-1", Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, + Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Double = -1, Optional RetISR As Double = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@SubTotal", SqlDbType.Float).Value = SubTotal + .Add("@Descuento", SqlDbType.Float).Value = Descuento + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@Total", SqlDbType.Float).Value = Total + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio + .Add("@RetIVA", SqlDbType.Float).Value = RetIVA + .Add("@RetISR", SqlDbType.Float).Value = RetISR + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago + .Add("@FormaPago", SqlDbType.Int).Value = FormaPago + .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA + .Add("@Vigencia", SqlDbType.Date).Value = Vigencia + .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato + .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 + .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el documento.", 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") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la fecha de vencimiento de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function AddVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasPagoAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@Importe", SqlDbType.Float).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Pago de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemoveVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasPagoRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar el Pago a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function EliminarVenta(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_EliminarVenta") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al intentar eliminar la venta. Verifique que el registro no tenga relaciones (Movimientos de almacén, Factura, Anticipos...)", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaPrePoliza(IDPoliza As Integer, CvePrePoliza As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentaPrePolizaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@IDPoliza", SqlDbType.Int).Value = IDPoliza + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la poliza de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddLeyendaFiscal(CveVenta As Integer, CveLeyenda As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasLeyendasFiscalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveLeyendaFiscal", SqlDbType.Int).Value = CveLeyenda + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Leyenda Fiscal en la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusFactura(Estatus As Integer, FolioFiscal As String, SelloSAT As String, FechaCancelacion As DateTime, CveVenta As Integer, + Optional IdPolizaCancelacion As Integer = -1, Optional CvePAC As Integer = -1, Optional CveEstatusRefacturacion As Integer = 0, + Optional CveUsuarioCambiaEstatus As Integer = -1, Optional FechaCambioEstatus As String = "-1") As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasUpdateEstatus") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEstatusFactura", SqlDbType.Int).Value = Estatus + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal + .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloSAT + .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@IdPolizaCancelacion", SqlDbType.Int).Value = IdPolizaCancelacion + .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC + .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion + .Add("@CveUsuarioCambiaEstatus", SqlDbType.Int).Value = CveUsuarioCambiaEstatus + .Add("@FechaCambioEstatus", SqlDbType.VarChar).Value = FechaCambioEstatus + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus de la factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasEstatusRefacturacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus de refacturación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusVenta(CveVenta As Integer, CveEstatusFactura As Integer, CveEmpresa As Integer, Optional Num2 As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasEstatusUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Num2", SqlDbType.Float).Value = Num2 + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus de la Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateCancelaVenta(CveVenta As Integer, FechaCancelacion As DateTime, SelloCancelacionSAT As String, CveEmpresa As Integer, Optional CvePAC As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasCancelacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion + .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloCancelacionSAT + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus de cancelacion Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaMail(Tipo As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasUpdateMail") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus del Mail.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaTimbre(Timbro As Boolean, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasUpdateTimbre") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Timbre", SqlDbType.Bit).Value = If(Timbro, 1, 0) + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus del Timbrado.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + + Return Retorno + End Function + Public Function UpdateVentaFolioFiscal(FolioFiscal As String, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUpdateFolioFiscal") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el folio fiscal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaCotizacion(CveVenta As Integer, CveCotizacion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasUpdateCotizacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveCotizacion", SqlDbType.Int).Value = CveCotizacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al vincular la Venta con la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ObtenerCreditoRestante(CveCliente As Integer, CveSucCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ClientesLimiteCreditoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ObtenerCreditoRestanteSucursalCliente(CveSucCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_SucClientesLimiteCreditoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function ObtenerClienteLimitesVenta(CveCliente As Integer, CveEmpresa As Integer) As Integer + Dim Retorno As Integer = 0 + DataAdapter("PA_Vta_ClientesLimitesVentaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Opcion", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@OpcionMsg", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + SerieVenta = SqlAdapter.SelectCommand.Parameters("@OpcionMsg").Value.ToString + Retorno = SqlAdapter.SelectCommand.Parameters("@Opcion").Value.ToString.ToEntero + + Catch ex As Exception + OnError("Ocurrió un error al obtener el limite de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AgregarVentaOCDetalle(CveVentaDetalle As Integer, CveOCDetalle As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AddVentaOCDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveOCDetalle", SqlDbType.Int).Value = CveOCDetalle + .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el detalle de la OC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AgregarRemisionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AddRemisionDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el detalle de la Remisión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function VerificarRemisionFacturada(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VerificarRemisionFacturada") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al verificar la remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function LiberarRemisionesFacturadas(CveVenta As Integer, Optional CveVentaLiberar As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarRemisionesFacturadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaLiberar", SqlDbType.Int).Value = CveVentaLiberar + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar las remisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RemisionesXCancelarAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaRemision", SqlDbType.Int).Value = CveVentaRemision + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las remisiones x cancelar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function LiberarCotizacionesFacturadas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarCotizacionesFacturadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar las cotizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function LiberarPedidos2Facturados(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarPedidos2Facturados") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar los pedidos2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function LiberarOCFacturadas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarOCFacturadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar las Ordenes de Compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaRemision(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasRemisionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al vincular la Venta con la Remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function MarcarRemisionesSinSurtir(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MarcarRemisionSinSurtir") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al marcar la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaCadenaOriginal(CadenaOriginal As String, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCadenaOriginalAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CadenaOriginal", SqlDbType.VarChar).Value = CadenaOriginal + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaCuentaTerminal(CveCuentaTerminal As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasCuentaTerminalUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuentaTerminal", SqlDbType.Int).Value = CveCuentaTerminal + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la cuenta terminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetCadenaOriginal(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCadenaOriginalGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Obtener la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region "V E N T A - D E T A L L E" + Public Function GetVentaDetalle(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el detalle de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddVentaDetalle(CveVenta As Integer, CvePS As Integer, Cantidad As Double, CveUnidadMedida As Integer, PU As Double, IVA As Double, + Total As Double, Observaciones As String, Descuento As Double, TipoDescuento As Integer, CveSubProyecto As Integer, + CvePresupuestoIngreso As Integer, Optional TiempoEntrega As String = "", Optional CveVentaDetallePadre As Integer = -1, + Optional CveContratoDetalle As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional IEPS As Double = -1, Optional PorcentajeIEPS As Double = 0, Optional CvePromocionDetalle As Integer = -1, + Optional CveMovimientoDetallePedido As Integer = -1, Optional ImporteRetIVA As Double = 0, Optional PorcentajeRetIVA As Double = 0, + Optional ImporteRetISR As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional CuentaPredial As String = "") As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetalleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@PU", SqlDbType.Float).Value = PU + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@ImporteRetIVA", SqlDbType.Float).Value = ImporteRetIVA + .Add("@ImporteRetISR", SqlDbType.Float).Value = ImporteRetISR + .Add("@PorcentajeIVA", SqlDbType.Float).Value = PorcentajeIVA + .Add("@PorcentajeIEPS", SqlDbType.Float).Value = PorcentajeIEPS + .Add("@PorcentajeRetIVA", SqlDbType.Float).Value = PorcentajeRetIVA + .Add("@PorcentajeRetISR", SqlDbType.Float).Value = PorcentajeRetISR + .Add("@Total", SqlDbType.Float).Value = Total + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Descuento", SqlDbType.Float).Value = Descuento + .Add("@TipoDescuento", SqlDbType.Int).Value = TipoDescuento + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePresupuestoIngreso", SqlDbType.Int).Value = CvePresupuestoIngreso + .Add("@TiempoEntrega", SqlDbType.VarChar).Value = TiempoEntrega + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle + .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + .Add("@CveMovimientoDetallePedido", SqlDbType.Int).Value = CveMovimientoDetallePedido + .Add("@CuentaPredial", SqlDbType.VarChar).Value = CuentaPredial + End With + + Try + SqlAdapter.Fill(Data) + CveVentaDetalle = Data.Rows(0)("CveVentaDetalle").ToString.ToEntero + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddVentaDetalleCaracteristica(CveVentaDetalle As Integer, CvePS As Integer, CveOpcion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetallesCaracteristicasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la Caracteristica del Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Double, PU As Double, IEPS As Double, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetalleRemisionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVenta + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@PU", SqlDbType.Float).Value = PU + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al editar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateVentasDevolucionAlmacen(EstatusDevolucion As Integer, CveVenta As Integer) As Boolean + + 'NOTA: + ' - 0: No requiere devolucion + ' - 1: Requiere devolucion + ' - 2: Devolucion ya realizada + + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDevolucionAlmacenUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@EstatusDevolucion", SqlDbType.TinyInt).Value = EstatusDevolucion + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la solicitud de Devolución de Almacén.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveVentasDetalle(CveVenta As Integer, Optional CveVentaDetalle As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "V E N T A - P R E S U P U E S T O" + Public Function GetPresupuestosVentas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AC_PresupuestosVentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "R E P O R T E S - D E - V E N T A S" + 'Reporte de Ventas + Public Function GetRepVentas(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As String, CveUsuario As Integer, CveEstatus As String, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", + Optional CveProyecto As Integer = -1, Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, + Optional CveClienteClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasGetRep") + + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepTopVenta(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetTopRepPS") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepTopCompras(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Comp_GetTopRepPS") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + 'Reporte de Ventas por Período + Public Function GetRepVentasPeriodos(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", + Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, + Optional CveClienteClasificacion As Integer = -1) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetRepPeriodo") + + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@VerEn", SqlDbType.Int).Value = VerEn + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + 'Reporte de Ventas - Detalle + Public Function GetRepVentasDetalle(Gpo As Integer, Anio As Integer, Mes As Integer, AnioMes As String, Fecha As String, CveCliente As Integer, IVA As String, + Vendedor As String, CveUsuario As Integer, CveEstatus As String, FechaI As Date, FechaF As Date, CveCorte As Integer, TipoDocto As String, + CveSubProyectoEjecucion As Integer, CveEmpresa As Integer, FechaIEjec As Date, FechaFEjec As Date, Optional CveProyecto As Integer = -1, + Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveMoneda As Integer = -1, Optional CveUsuarioConsulta As Integer = -1, + Optional CveClienteClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasGetRepDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@Anio", SqlDbType.Int).Value = Anio + .Add("@Mes", SqlDbType.Int).Value = Mes + .Add("@AnioMes", SqlDbType.VarChar).Value = AnioMes + .Add("@Fecha", SqlDbType.VarChar).Value = Fecha + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + + Return Retorno + End Function + + 'Reporte de Ventas - Productos y Servicios + Public Function GetRepProductosServicios(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, + FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, + Optional TipoCambio As Integer = -1, Optional TCEspecifico As Double = -1, Optional CveUsuarioConsulta As Integer = -1, + Optional TipoDocto As String = "-1", Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetRepPS") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetRepProductosServiciosDetalle(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, + FechaI As Date, FechaF As Date, Mes As Integer, FechaIEjec As Date, FechaFEjec As Date, MesEjec As Integer, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1, + Optional TipoDocto As String = "-1", Optional GPO As Integer = -1, Optional CveMoneda As Integer = -1, Optional TipoCambio As Integer = -1, + Optional TCEspecifico As Double = 0, Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetRepPSDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Mes", SqlDbType.Int).Value = Mes + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@MesEjec", SqlDbType.Int).Value = MesEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetRepNCxAplicar(CveClienteSucursal As Integer, CveSubProyecto As Integer, CveCliente As Integer, FechaInicio As DateTime, FechaFin As DateTime, ConSaldo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_NotasCreditosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Notas de Crédito por Aplicar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "V E N T A S - P R E C I O L I S T A S" 'Hecho por Charlie 1/9/2016 + Public Function GetPrecioListas(Optional CveEmpresa As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Listas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPrecioLista(CveUsuario As Integer, CveEmpresa As Integer, PrecioLista As String, Porcentaje As Double) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Lista con el mismo Nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al la Lista", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdatePrecioLista(PrecioLista As String, Estatus As Boolean, CveUsuario As Integer, Porcentaje As Double, CvePrecioLista As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Lista con el mismo nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en la Lista", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePrecioLista(CvePrecioLista As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Lista no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "V E N T A S - M E S A S" + Public Function GetMesas(Optional CveEmpresa As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Mesas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddMesa(Mesa As String, CveUsuario As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Mesa", SqlDbType.VarChar).Value = Mesa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar el Mesa", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateMesa(Mesa As String, Estatus As Boolean, CveSubProyecto As Integer, CveMesa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Mesa", SqlDbType.VarChar).Value = Mesa + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveMesa", SqlDbType.Int).Value = CveMesa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en el Mesa", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveMesa(CveMesa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveMesa", SqlDbType.Int).Value = CveMesa + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Mesa no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "V E N T A S - B I T A C O R A" + Public Function GetVta_Bitacora(CveVenta As Integer, FechaI As String, FechaF As String, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_BitacoraGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la Bitacora de las Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddVta_Bitacora(CveVenta As Integer, Fecha As DateTime, Observacion As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_BitacoraAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Bitacora de la Venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + +#End Region + +#Region "R E P O R T E S - D E L - P V " + Public Function GetRepVentasPV(FechaI As String, FechaF As String, FechaIEjec As String, FechaFEjec As String, CveCliente As Integer, CveSubProyecto As Integer, CveSubProyectoEjecucion As Integer, + Vendedor As String, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_PV_VentasGetRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaIEjec", SqlDbType.VarChar).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.VarChar).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + + Public Function GetRepABT(Ejercicio As Integer, Periodo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetRepABT") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Periodo", SqlDbType.Int).Value = Periodo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte ABT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region " PROMOCIONES " + Public Function GetPromociones(CvePromocion As Integer, Fecha As String, CveVendedor As Integer, CveCliente As Integer, Estatus As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@Fecha", SqlDbType.VarChar).Value = Fecha + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Promociones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddPromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Integer + Dim Retorno = -1 + DataAdapter("PA_Vta_PromocionesAdd") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@Promocion", SqlDbType.VarChar).Value = Promocion + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePromocion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePromocion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error al agregar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdatePromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CvePromocion As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesUpdate") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@Promocion", SqlDbType.VarChar).Value = Promocion + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CvePromocion", SqlDbType.Float).Value = CvePromocion + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePromociones(CvePromocion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region " PROMOCIONES DETALLE " + Public Function GetPromocionesPS(CvePS As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveCliente As Integer, CveVendedor As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesPSGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetPromocionesDetalle(CvePromocion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddPromocionesDetalle(CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleAdd") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion + .Add("@Promocion", SqlDbType.Money).Value = Promocion + .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior + .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion + .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion + .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes + .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes + .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles + .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves + .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes + .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado + .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo + .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio + .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdatePromocionesDetalle(CvePromocionDetalle As Integer, CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleUpdate") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion + .Add("@Promocion", SqlDbType.Money).Value = Promocion + .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior + .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion + .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion + .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes + .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes + .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles + .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves + .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes + .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado + .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo + .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio + .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin + .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePromocionesDetalle(CvePromocionDetalle As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "Pruebas" + + Public Function GetDeduccion(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de las deducciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddDeduccion(Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion + .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje + .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error al tratar de agregar la deducción. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RemoveDeduccion(CveVentaDeduccion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesRemove") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al tratar de eliminar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + + End Function + Public Function UpdateDeduccion(CvePrincipal As Integer, Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrincipal", SqlDbType.VarChar).Value = CvePrincipal + .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion + .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje + .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error al tratar de Actualizar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + + + +#End Region + + Public Function GetPrecios(CveClasificacion As Integer, CvePS As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ActualizarPreciosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios de los precios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region "Firmas" + + Public Function GetVentasFirmas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function AddVentasFirmas(CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Titulo", SqlDbType.VarChar).Value = Titulo + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Puesto", SqlDbType.VarChar).Value = Puesto + .Add("@Lado", SqlDbType.Bit).Value = Lado + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function UpdateVentasFirmas(CveVentaFirma As Integer, CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Titulo", SqlDbType.VarChar).Value = Titulo + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Puesto", SqlDbType.VarChar).Value = Puesto + .Add("@Lado", SqlDbType.VarChar).Value = Lado + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RemoveVentasFirmas(CveVentaFirma As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + +#End Region + +#Region " I M P U E S T O S L O C A L E S" + Public Function AddImpuestosLocales(ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al añadir los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetImpuestosLocales(CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateImpuestosLocales(CveImpuestoLocal As Integer, ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal + .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemoveImpuestosLocales(CveImpuestoLocal As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + +#End Region + + +#Region " ANTICIPOS/NOTASCREDITO - VENTAS " + Public Function GetVentasAntNC(CveVenta As Integer, CveVentaNC As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasAntNCGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaNC", SqlDbType.Int).Value = CveVentaNC + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las NotasCrédito/Anticipos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + + Public Function GetRemisionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveContrato As Integer, Tipo As Integer, CveMoneda As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasRemisionesFacturasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetOCSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasOrdenesCompraGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las ordenes de compra sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepRemisionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSubProyecto As String, CveCliente As Integer, CveContrato As Integer, CveVendedor As String, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepRemisionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepRemisionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, Optional CveUsuarioConsulta As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepRemisionesDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReporteHP(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Compu_HPRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReporteVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUtilidadGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + + Try + SqlAdapter.Fill(Data) + + If Data.Rows.Count > 0 Then _Neto = Data.Rows(0)("Neto").ToString.ToDouble : _PorNeto = Data.Rows(0)("PorNeto").ToString.ToDouble + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReporteVentasUtilidadDetalle(CveVendedor As String, CveVenta As Integer, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUtilidadDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + + Try + SqlAdapter.Fill(Data) + If Data.Rows.Count > 1 Then _SerieVenta = Data.Rows(1)("SerieFolio").ToString : _SubTotalVenta = Data.Rows(0)("SubTotal").ToString.ToDouble : _SubTotalVentaDolares = Data.Rows(0)("SubTotalDolares").ToString.ToDouble : _FechaVenta = Data.Rows(1)("FechaVenta").ToString + If Data.Rows.Count > 1 Then _Costo = Data.Rows(0)("CostoVta").ToString.ToDouble : _FolioCosto = Data.Rows(1)("FolioMovto").ToString : _FechaSalidaCosto = Data.Rows(1)("FechaMovto").ToString + + If Data.Rows.Count > 0 Then _Utilidad = Data.Rows(0)("Utilidad").ToString.ToDouble : _PorUtilidad = Data.Rows(0)("PorUtilidad").ToString.ToDouble + If Data.Rows.Count > 0 Then _Perdida = Data.Rows(0)("Perdida").ToString.ToDouble : _PorPerdida = Data.Rows(0)("PorPerdida").ToString.ToDouble + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReportePadreVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Gpo As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepVentasUtilidadGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Gpo", SqlDbType.Int).Value = Gpo + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetReporteVentasAutorizaciones(CveUsuario As Integer, CveEstatusFactura As Integer, CveSubProyecto As Integer, FechaInicio As Date, FechaFin As Date, CveCliente As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepVentasAutorizacionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Autorizaciones de Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region " Facturas " + + Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + + + DataAdapter("PA_Vta_FacturasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@FechaFacturaI", SqlDbType.Date).Value = FechaFacturaI + .Add("@FechaFacturaF", SqlDbType.Date).Value = FechaFacturaF + .Add("@RFC", SqlDbType.VarChar).Value = RFC + .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor + .Add("@FueValidado", SqlDbType.Int).Value = FueValidado + .Add("@CveResponsable", SqlDbType.Int).Value = CveResponsable + .Add("@CveFactura", SqlDbType.Int).Value = CveFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + Public Function GetFacturasCanceladasPendientes(FoliosFiscales As String, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + DataAdapter("PA_Vta_FacturasCanceladasPendientesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FoliosFiscales", SqlDbType.VarChar).Value = FoliosFiscales + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener las facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + + Public Function UpdateVentaFacturas(CveFactura As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + + + DataAdapter("PA_Vta_FacturaVentaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveFactura", SqlDbType.Int).Value = CveFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + Public Function ProcesoPrepolizasCancelacion(CveVenta As Integer, CveUsuario As Integer) As Boolean + Dim OnError As Boolean = False + + DataAdapter("PA_Vta_ProcesoPrepolizasCancelacion") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al crear las prepolizas de cancelación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function +#End Region + + +#Region "C O N D I C I O N E S D E E N T R E G A" + Public Function GetCondicionesEntrega(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CondicionesEntregaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region " CANCELAR PEDIDO " + Public Function CancelarPedido(CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CancelarPedido") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cancelar el pedido.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "Punto Venta" + + Public Function AddVtaCortesDetalles(CveCorte As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CortesDetallesAdd") + + + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al guardar el Detalle del Corte de Turno.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetCortesDetalleVentasResumen(CveCorte As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_CortesDetalleVentasResumenGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalle de cortes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region " CANCELAR ANTE SAT " + Public Function CancelarVentasSAT(StrVentas As String) As String + Dim CveVentas = StrVentas.Split(","c) + Dim CveVentasError As New List(Of Integer) + + If CveVentas IsNot Nothing Then + Dim ObjVentas As New ClsVentas + Dim ObjCancelacion As New Timbrado + Dim ObjUsuario As New ClsSisUsuarios + Dim Usuario As Usuario = Nothing + Dim ObjEmpresa As New ClsSisEmpresas() + + Dim FolioFiscal = "-1" + Dim CveEstatus = -1 + Dim Total = 0.0D + Dim RFCReceptor = "-1" + Dim Nombre = "-1" + Dim DbRowVenta As DataRow + Dim CveUsuario = -1 + Dim pCveEmpresa = -1 + Dim Contraseña = "-1" + + For Each PCveVenta In CveVentas + If ObjVentas.GetVenta(PCveVenta.ToEntero, -1) Then + DbRowVenta = ObjVentas.DtResultados.Rows(0) + + FolioFiscal = DbRowVenta("FolioFiscal").ToString + CveEstatus = DbRowVenta("CveEstatusFactura").ToString.ToEntero + Total = DbRowVenta("Total").ToString.ToDecimal + RFCReceptor = DbRowVenta("ClienteRFC").ToString + CveUsuario = DbRowVenta("CveUsuario").ToString.ToEntero + pCveEmpresa = DbRowVenta("CveEmpresa").ToString.ToEntero + Nombre = DbRowVenta("Nombre").ToString + + If ObjUsuario.GetUsuarios(CveUsuario, -1, -1) Then + Contraseña = ObjUsuario.DtResultados.Rows(0)("Contraseña").ToString + Else + CveVentasError.Add(PCveVenta.ToEntero) + Continue For + End If + Usuario = ObjUsuario.ValidaUsuario(Nombre, Contraseña, IMEI) + + If ObjEmpresa.GetEmpresas(pCveEmpresa, "-1", "-1", "-1", "-1") Then + Usuario.Empresa = ObjEmpresa.Empresa + Usuario.CveEmpresa = ObjEmpresa.Empresa.CveEmpresa + Else + CveVentasError.Add(PCveVenta.ToEntero) + Continue For + End If + + + 'SOLO SI ESTA CANCELADA ANTE SAT EN SIG SE INTENTARA CANCELAR DE NUEVO CONTRA EL SAT + If CveEstatus = 5 Then + If ObjCancelacion.CFDICancelar(Usuario.Empresa, FolioFiscal, Total, RFCReceptor, Usuario.Empresa.RFC) Then + If Not ObjVentas.UpdateEstatusFactura(5, FolioFiscal, ObjCancelacion.CancelacionAcuse, Now, PCveVenta.ToEntero, -1, CvePAC:=Usuario.Empresa.CvePAC) Then + CveVentasError.Add(PCveVenta.ToEntero) + End If + Else + CveVentasError.Add(PCveVenta.ToEntero) + End If + Else + CveVentasError.Add(PCveVenta.ToEntero) + End If + End If + Next + + ObjVentas.Dispose() + ObjUsuario.Dispose() + ObjEmpresa.Dispose() + Else + + End If + + Return "Procesando" + End Function +#End Region + +#Region "Remisiones" + Public Function GetRemisionesRelacionadas(CveVenta As Integer, TipoDocto As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RemisionesRelacionadasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Remisiones/Facturas Relacionadas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + + Public Function VentasSaldar(CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional Amortizacion As Integer = -1, Optional CveVentaAmortizada As Integer = -1, Optional CveContrato As Integer = -1, Optional Fecha As Date = MinFecha) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasSaldar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Amortizacion", SqlDbType.Int).Value = Amortizacion + .Add("@CveVentaAmortizada", SqlDbType.Int).Value = CveVentaAmortizada + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al saldar una venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + +#Region "COTIZACIONES SIN FACTURAR" + + Public Function GetCotizacionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCotizacionesFacturasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepCotizacionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepCotizacionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepCotizacionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepCotizacionesDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AgregaCotizacionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AddCotizacionDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el detalle de la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "C O B R A N Z A V E N T A S" + Public Function UpdateVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveCobranzaEstatusTurno As Integer, FechaCobranza As DateTime, CobranzaObservacion As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasCobranzaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza + .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion + .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function UpdateAsignaVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveCobranzaEstatusTurno As Integer, CobranzaObservacion As String, FechaCobranza As DateTime) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AsignaCobranzaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza + .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza + .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion + .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetCobranzaEstatus(CveCobranzaEstatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_EstatusCobranzaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function GetCobranzaTurnoEstatus(CveCobranzaEstatusTurno As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_EstatusTurnoCobranzaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function GetGestionCobranza(CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveResponsableCobranza As Integer, CveCobranzaTurno As Integer, TipoPago As String, FechaI As String, FechaF As String, CveEmpresa As Integer, TipoCambio As Integer, TCEspecifico As Double) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_GestionCobranzaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza + .Add("@CveResponsableCobranza", SqlDbType.Int).Value = CveResponsableCobranza + .Add("@CveCobranzaTurno", SqlDbType.Int).Value = CveCobranzaTurno + .Add("@TipoPago", SqlDbType.VarChar).Value = TipoPago + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener la gestión de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function AddVisitaCobranza(CveVenta As Integer, CveUsuarioCobranza As Integer, FechaCobranza As Date, Observaciones As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VisitaCobranzaAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza + .Add("@FechaCobranza", SqlDbType.Date).Value = FechaCobranza + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar guardar la visita de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "C O M P L E M E N T O S" + Public Function UpdateVentasComplementos(CveVenta As Integer, TipoProceso As String, TipoComite As String, IdContabilidad As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_UpdateVentaComplementos") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoProceso", SqlDbType.VarChar).Value = TipoProceso + .Add("@TipoComite", SqlDbType.VarChar).Value = TipoComite + .Add("@IdContabilidad", SqlDbType.VarChar).Value = IdContabilidad + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los complementos de la venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region " FLETES " + Public Function GetFletes(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_WT_Viajes") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener los Fletes", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "Metodos y Forma de Pago" + + Public Function GetFormaPago() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_FormaPagoGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al obtener Formas de pago", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetMetodoPago() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MetodoPagoGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al obtener Métodos de Pago.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + + Public Function GetTiposRelacion() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_TiposRelacionGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al obtener Tipos de relación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region "Tipo Documentos" + + Public Function GetTiposDocumentos() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_TipoDocumentosGet") + With SqlAdapter.SelectCommand.Parameters + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los tipos de documentos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "DEVOLUCIONES" + Public Function AddVentaDetalleDevolucion(pCveVentaDetalle As Integer, CveVentaDetalleDevolucion As Integer, Cantidad As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleDevolucionAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = pCveVentaDetalle + .Add("@CveVentaDetalleDevolucion", SqlDbType.Int).Value = CveVentaDetalleDevolucion + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveVentaDetalleDevolucion(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleDevolucionRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "COMISIONES" + + Public Function GetRepComisiones(FechaI As Date, FechaF As Date, CveSubProyecto As Integer, CveVendedor As Integer, CveCliente As Integer, CveUsuario As Integer, CveEmpresa As Integer, TipoSaldo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepComisiones119") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoSaldo", SqlDbType.Int).Value = TipoSaldo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "REPORTE DE PRODUCTOS SERVICIOS PERIODO" + + + Public Function GetRepPSPeriodo(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", + Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, + Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, Optional CvePS As Integer = -1, Optional CveClasificacion As Integer = -1, + Optional CveCategoria As Integer = -1, Optional TipoFecha As Integer = 1, Optional CveClienteClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetRepPeriodoPS") + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@VerEn", SqlDbType.Int).Value = VerEn + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@TipoFecha", SqlDbType.Int).Value = TipoFecha + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Productos Servicios por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "Ventas Refacturas" + Public Function GetVentaRefacturacion(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentaRefacturacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener datos de la venta refacturada .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "REPORTE DE ANTICIPOS - NC - IXC" + + Public Function GetRepAnticiposNCIXC(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1, Optional ConSaldo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepAnt-NC-IXC") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte + .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepAnticiposNCIXCDetalle(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, ConSaldo As Integer, Tipo As Integer, CveMoneda As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepAnt-NC-IXCDetalle") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte + .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "BUSCAR OC REGISTRADAS" + Public Function GetOCVentas(CveCliente As Integer, OC As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetOCVentas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@OC", SqlDbType.VarChar).Value = OC + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Ordenes de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function +#End Region + +#Region "CLASIFICACIONES DETALLE" + Public Function GetClasificacionDetalle(CveEmpresa As Integer, Optional CveClasificacionDetalle As Integer = -1, Optional Estatus As Integer = -1, Optional CveClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las clasificaciones detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddClasificacionDetalle(ClasificacionDetalle As String, CveClasificacion As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveClasificacionDetalle", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + CveClasificacionDetalle = SqlAdapter.SelectCommand.Parameters("@CveClasificacionDetalle").Value.ToString.ToEntero + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdateClasificacionDetalle(CveClasificacionDetalle As Integer, ClasificacionDetalle As String, CveClasificacion As Integer, Estatus As Boolean) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function RemoveClasificacionDetalle(CveClasificacionDetalle As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "PEDIDOS2" + + Public Function AddVentaDetallePedido2(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetallePedidos2Add") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la venta detalle pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function GetVentaDetallePedido2SinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveMoneda As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetallePedidos2SinFacturarGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@Tipo", SqlDbType.Float).Value = Tipo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetVentasPedidos2Totales(CveCliente As Integer, Ventas As String, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetallePedidos2Totales") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Ventas", SqlDbType.VarChar).Value = Ventas + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 totales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdateVentaPedido2(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasPedido2Update") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al vincular la Venta con el Pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepPedidos2SinFacturar(FechaI As Date, FechaF As Date, FechaV As Date, CveSubProyecto As String, CveCliente As Integer, CveVendedor As String, CveEmpresa As Integer, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepPedidos2Get") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaV", SqlDbType.Date).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepPedidos2SinFacturarDetalle(FechaI As Date, FechaF As Date, FechaV As Date, CveCliente As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, CveVendedor As String, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepPedidos2DetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaV", SqlDbType.Date).Value = FechaV + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 sin facturar detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "COSTO PROMEDIO VENTA" + + Public Function RepCostoPromedioVenta(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CostoPromedioVentaRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RepVentasNetasResumen(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasNetasResumenRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + + Public Function RepIngresos(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Ventas_RepIngresos", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function RepIngresosDetalle(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer, CveConceptoContable As Integer, CveCuenta As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Ventas_RepIngresosDetalle", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Ingresos Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + +#Region " AUTORIZACION DESCUENTOS " + + Public Function AutorizacionDescuentosGet(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosGet", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al obtener las Autorizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionDescuentosRemove(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosRemove", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al eliminar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionDescuentosAdd(CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosAdd", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al agregar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionDescuentosUpdate(CveAutorizacionDescuento As Integer, CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosUpdate", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al actualizar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionEstatusUpdate(CveAutorizacionDescuento As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionEstatusUpdate", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al actualizar el Estatus de la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function +#End Region + +#Region "CANCELACION REMISION" + + Public Function UpdateCancelaRemision(CveVenta As Integer, SeCancelaRemision As Boolean) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_CancelaRemisionUpdate", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@SeCancelaRemision", SqlDbType.Bit).Value = SeCancelaRemision + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar que la remision sea cancelable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + +#End Region + +#Region "REPORTE PUES SIN PAGO" + + Public Function GetPUESinPago(FI As DateTime, FF As DateTime, CveCliente As Integer, CveSubProyecto As Integer, CveVendedor As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_PUESinPagoGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FI", SqlDbType.DateTime).Value = FI + .Add("@FF", SqlDbType.DateTime).Value = FF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las ventas con método de pago PUE.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + +#End Region + + Public Function GetAnticiposEspeciales(FI As DateTime, FF As DateTime, CveSubProyecto As Integer, AnticipoEspecial As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_AnticiposEspecialesGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FI", SqlDbType.DateTime).Value = FI + .Add("@FF", SqlDbType.DateTime).Value = FF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@AnticipoEspecial", SqlDbType.Int).Value = AnticipoEspecial + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Anticipo Ficticio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + Public Function GetRepArqueos(Anio As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + Dataset = New DataSet() + DataAdapter("PA_Vta_RepArqueosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Anio", SqlDbType.Int).Value = Anio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Dataset) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + 'compila + End Function + Public Function GetRepArqueosDetalle(Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + Dataset = New DataSet() + DataAdapter("PA_Vta_RepArqueosDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Dataset) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + 'compila + End Function +#Region "Conciliación emitidas SAT" + + Public Function ConciliacionemitidasSATGet(cveEmpresa As Int32) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_ConciliacionemitidasSATGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de 'Conciliación emitidas SAT'.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + retorno = False + End Try + Return retorno + End Function +#End Region +#Region "IDisposable Support" + + + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + ' TODO: dispose managed state (managed objects). + If Not Data Is Nothing Then Data.Dispose() + If Not Dataset Is Nothing Then Dataset.Dispose() + If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() + If Not SqlCommand Is Nothing Then SqlCommand.Dispose() + If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() + If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() + If Not SqlConexion Is Nothing Then SqlConexion.Dispose() + End If + + ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. + ' TODO: set large fields to null. + End If + Me.disposedValue = True + End Sub + + ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. + 'Protected Overrides Sub Finalize() + ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ' Dispose(False) + ' MyBase.Finalize() + 'End Sub + + ' This code added by Visual Basic to correctly implement the disposable pattern. + Public Sub Dispose() Implements IDisposable.Dispose + ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region +End Class + From 07f7c39fdddddbbfcbdc6bee1578aae54ac70a5b Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Thu, 15 Aug 2019 12:49:13 -0700 Subject: [PATCH 04/23] --- App_Code/Modelos.vb | 5 +- Bancos/PopIECompras.aspx | 2 +- Bancos/PopIECompras.aspx.vb | 96 +++++++++++++++++++++++++++++--- Bancos/PopIEVentas.aspx.vb | 4 +- Bancos/ProveedoresAbonar.aspx | 2 +- Bancos/ProveedoresAbonar.aspx.vb | 83 +++++++++++++++++++++++---- 6 files changed, 168 insertions(+), 24 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 4d78eadb3..41b6f6116 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1181,13 +1181,14 @@ Namespace Modelos 'Se agregan los PS For Each Row As DataRow In TmpDTDetalle.Rows If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, - Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("IVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("IVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), + Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, TiempoEntrega:=Row("TiempoEntrega").ToString, CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1), IEPS:=Row("ImporteIEPS").ToString.ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString.ToEntero, ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, - PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString) Then + PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString, + PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal) Then ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Exit For Else diff --git a/Bancos/PopIECompras.aspx b/Bancos/PopIECompras.aspx index dcc1b2cb0..9d8a06644 100644 --- a/Bancos/PopIECompras.aspx +++ b/Bancos/PopIECompras.aspx @@ -11,7 +11,7 @@   - + diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 8e42df1f3..683e35fd7 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -307,6 +307,8 @@ Partial Class Bancos_PopIECompras Public Class IEMovimiento Public Property SubTotal As Decimal Public Property IVA As Decimal + Public Property IVADeducible As Decimal + Public Property IVANoDeducible As Decimal Public Property RetIVA As Decimal Public Property RetISR As Decimal Public Property Total As Decimal @@ -615,6 +617,8 @@ Partial Class Bancos_PopIECompras MovimientoPagar = New IEMovimiento MovimientoPagar.SubTotal = dr("SubTotal").ToString.ToDecimal MovimientoPagar.IVA = dr("IVA").ToString.ToDecimal + MovimientoPagar.IVADeducible = dr("IVADeducible").ToString.ToDecimal + MovimientoPagar.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal MovimientoPagar.RetIVA = dr("RetIVA").ToString.ToDecimal MovimientoPagar.RetISR = dr("RetISR").ToString.ToDecimal MovimientoPagar.Total = dr("Total").ToString.ToDecimal @@ -2250,16 +2254,16 @@ Partial Class Bancos_PopIECompras If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = MovimientoPagar.IVA + ImporteMovimiento = MovimientoPagar.IVADeducible ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA) + ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = (MovimientoPagar.IVA) + ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA) + ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2) @@ -2273,16 +2277,92 @@ Partial Class Bancos_PopIECompras End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = MovimientoPagar.IVA * PorcentajePago + ImporteMovimiento = MovimientoPagar.IVADeducible * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) + ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) + ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) + ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2) + ImporteMX = Math.Round(ImporteMX, 2) + TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + + If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + End If + + PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA + Dim IdCtaIVAXAcreditar As Integer = 0 + Dim IdCtaIVAAcreditable As Integer = 0 + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then + IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero + IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero + End If + + IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + + If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjMov.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero + End If + End If + Case 280 'Iva Acreditable No Deducible + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + 'funcionalidad que toma el 100% del pago para acreditamiento de iva + Dim TotalImporte As Decimal + + If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then + TotalImporte = ImportePagado.ToString.ToDecimal + ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then + TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then + TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then + TotalImporte = ImportePagado.ToString.ToDecimal + End If + + If TotalImporte = CompraSaldo Then + If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = MovimientoPagar.IVANoDeducible + ImporteMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible) + ImporteMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2) + ImporteMX = Math.Round(ImporteMX, 2) + TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + + If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + Else + ImporteMovimiento = 0 + ImporteMX = 0 + End If + Else + If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = MovimientoPagar.IVANoDeducible * PorcentajePago + ImporteMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago) + ImporteMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2) diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 9a60d6198..9715941cf 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -2062,7 +2062,7 @@ Partial Class Bancos_PopIEVentas IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria tipoCambioVentaDiferenciaCambiaria = If(FechaVenta < FechaUltimaFluctuacion, TipoCambioFluctuacion, TipoCambioOriginal) - Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta) + Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVentaDiferenciaCambiaria) TimpocambioGeneral = TCImpuestos Dim Diferencia As Decimal = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioVentaValuacion) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta @@ -2090,7 +2090,7 @@ Partial Class Bancos_PopIEVentas IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria tipoCambioVentaDiferenciaCambiaria = If(FechaVenta < FechaUltimaFluctuacion, TipoCambioFluctuacion, TipoCambioOriginal) - Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta) + Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVentaDiferenciaCambiaria) TimpocambioGeneral = TCImpuestos diff --git a/Bancos/ProveedoresAbonar.aspx b/Bancos/ProveedoresAbonar.aspx index fd65df3b5..dec829379 100644 --- a/Bancos/ProveedoresAbonar.aspx +++ b/Bancos/ProveedoresAbonar.aspx @@ -358,7 +358,7 @@ diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 672ec98f1..38a671b26 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -310,7 +310,7 @@ Partial Class Bancos_ProveedoresAbonar ViewState("CveCuentaRetISR") = 0 End If - If UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 126, 119, 122,145) Then + If UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 126, 119, 122) Then rowComisiones.Visible = True End If @@ -1506,16 +1506,16 @@ Partial Class Bancos_ProveedoresAbonar 'funcionalidad que toma el 100% del pago para acreditamiento de iva If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal - importeMX = gvr.DataKey("IVA").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal + importeMX = gvr.DataKey("IVADeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) @@ -1528,16 +1528,79 @@ Partial Class Bancos_ProveedoresAbonar End If Else If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) + importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) + + If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + End If + TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + + PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal + Dim IdCtaIVAXAcreditar As Integer = 0 + Dim IdCtaIVAAcreditable As Integer = 0 + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then + IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero + IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero + End If + IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + + If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjMov.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero + End If + End If + Case 280 'Iva Acreditado No Deducible + Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + 'funcionalidad que toma el 100% del pago para acreditamiento de iva + If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then + If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = gvr.DataKey("IVANoDeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) + importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) + + If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + Else + ImporteMovimiento = 0 + importeMX = 0 + End If + Else + If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) From a1a19b374bc8624f269b722d1beab060efff029c Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Thu, 15 Aug 2019 12:52:11 -0700 Subject: [PATCH 05/23] --- Ventas/RepVentasUtilidad.aspx | 16 +++++++------- Ventas/RepVentasUtilidad.aspx.vb | 36 ++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Ventas/RepVentasUtilidad.aspx b/Ventas/RepVentasUtilidad.aspx index 5c58d537d..adf3f6615 100644 --- a/Ventas/RepVentasUtilidad.aspx +++ b/Ventas/RepVentasUtilidad.aspx @@ -87,10 +87,10 @@
  • - Generar PDF + PDF
  • - Generar Excel + Excel
  • @@ -164,9 +164,8 @@ Cliente:
    - - - + +
    @@ -232,8 +231,8 @@
    - - + +
    VentaCostoVentaCosto Utilidad/Pérdida
    @@ -250,6 +249,9 @@ + + + diff --git a/Ventas/RepVentasUtilidad.aspx.vb b/Ventas/RepVentasUtilidad.aspx.vb index 706a1bd43..9b9a2dabf 100644 --- a/Ventas/RepVentasUtilidad.aspx.vb +++ b/Ventas/RepVentasUtilidad.aspx.vb @@ -38,8 +38,15 @@ Partial Class Ventas_RepVentasUtilidad txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString 'Carga Clientes - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.DataBind() + Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlClientes.setEsWebService(True) + Else + DdlClientes.setEsWebService(False) + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientes.DataBind() + DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + End If 'CargaSubProyectos DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) @@ -84,7 +91,10 @@ Partial Class Ventas_RepVentasUtilidad DdlSubProyecto.SelectedValuesIfExistM(CveSubProyecto) DdlVendedor.SelectedValuesIfExistM(CveVendedor) - DdlClientes.SelectedValueExist(CveCliente) + If CveCliente <> "-1" Then + DdlClientes.SelectedValue = CveCliente + DdlClientes.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {CveCliente}").FiltroPrimeroValor("Nombre") + End If DdlClasificacion.SelectedValueExist(CveClasificacion) DdlPS.SelectedValue = CvePS If CvePS.ToEntero > 0 AndAlso GlobalDTPS(UsuarioActual.CveEmpresa, CvePS.ToEntero).Rows.Count > 0 Then @@ -184,17 +194,25 @@ Partial Class Ventas_RepVentasUtilidad End If + + If e.Row.DBCampo("CveVenta") = "" Then + e.Row.Cells(6).Text = "" + e.Row.Cells(7).Text = "" + e.Row.Cells(8).Text = "" + e.Row.Cells(10).Text = "" + End If + If e.Row.DBCampo("CveMovimiento") = "" Then - e.Row.Cells(3).Text = "" + e.Row.Cells(7).Text = "" + e.Row.Cells(8).Text = "" + e.Row.Cells(10).Text = "" End If If e.Row.DBCampo("CveVenta") = "" Then e.Row.CssClass = "Totales" End If - If e.Row.DBCampo("CveVenta") = "" Then - e.Row.Cells(7).Text = "" - End If + Dim Liga As String = String.Format("/Ventas/RepVentasUtilidadDetalle.aspx?CveVenta={0}&CveVendedor={1}&FechaI={2:d}&FechaF={3:d}&CveCliente={4}&Orden={5}&CveSubProyecto={6}&CvePS={7}&CveClasificacion={8}", @@ -249,7 +267,7 @@ Partial Class Ventas_RepVentasUtilidad If txtFechaI.Text = "" Then FechaI = MinFecha If txtFechaF.Text = "" Then FechaF = MaxFecha - Dim Cliente = If(DdlClientes.SelectedValue = "", "", $" Cliente: {DdlClientes.SelectedItem.Text}") + Dim Cliente = If(DdlClientes.SelectedValue = "", "", $" Cliente: {DdlClientes.SelectedText}") Dim Sucursal = If(DdlSubProyecto.GetSelectedText = "", "", $" Sucursal: {DdlSubProyecto.GetSelectedText}") Dim Vendedor = If(DdlVendedor.GetSelectedText = "", "", $" Vendedor: {DdlVendedor.GetSelectedText}") Dim PS = If(DdlPS.SelectedValue = "-1", "", $" P.S.: {DdlPS.SelectedText}") @@ -305,7 +323,7 @@ Partial Class Ventas_RepVentasUtilidad Dim Sucursal = If(DdlSubProyecto.GetSelectedText = "", "", $" Sucursal: {DdlSubProyecto.GetSelectedText}") Dim FechaIn As String = $" Fecha Inicio: {txtFechaI.Text}" Dim FechaFn As String = $" Fecha Fin: {txtFechaF.Text}" - Dim Cliente = If(DdlClientes.SelectedValue = "-1", "", $" Cliente: {DdlClientes.SelectedItem.Text}") + Dim Cliente = If(DdlClientes.SelectedValue = "-1", "", $" Cliente: {DdlClientes.SelectedText}") Dim Vendedor = If(DdlVendedor.GetSelectedText = "", "", $" Vendedor: {DdlVendedor.GetSelectedText}") Dim PS = If(DdlPS.SelectedValue = "-1", "", $" P.S.: {DdlPS.SelectedText}") Dim Clasificacion = If(DdlClasificacion.SelectedValue = "-1", "", $" Clasificacion: {DdlClasificacion.SelectedItem.Text}") From ce74e59d88fd5e9f40030c23ab291d5b5c606e68 Mon Sep 17 00:00:00 2001 From: janeth arvizu Date: Thu, 15 Aug 2019 14:01:28 -0700 Subject: [PATCH 06/23] =?UTF-8?q?Se=20cambi=C3=B3=20cat=C3=A1logo=20a=20nu?= =?UTF-8?q?evo=20modelo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OS/CatTiposOrdenesServicios.aspx | 267 ++++++++++++++++----------- OS/CatTiposOrdenesServicios.aspx.vb | 276 +++++++++++++--------------- 2 files changed, 294 insertions(+), 249 deletions(-) diff --git a/OS/CatTiposOrdenesServicios.aspx b/OS/CatTiposOrdenesServicios.aspx index d14ae3451..b7ccee347 100644 --- a/OS/CatTiposOrdenesServicios.aspx +++ b/OS/CatTiposOrdenesServicios.aspx @@ -3,116 +3,175 @@ + - - - + Catálogo de Tipos de Ordenes de Servicio + + - - - + - - - - - - - - - - - - - - - - - -
    - - Tipo de Orden de Servicio - - - - - Estatus - - - - - Fecha Ing. - - - - - Usuario - - - Comandos
    - - - -     -
    -
    -
    - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -   -
    -
    - - - -
    - - - - - -
    - - -
    +
  • + +
  • - + + + + + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + +
    + + + + + + + +   + + + + + +   + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + +
    +
    + +
    + + \ No newline at end of file diff --git a/OS/CatTiposOrdenesServicios.aspx.vb b/OS/CatTiposOrdenesServicios.aspx.vb index d9f07a516..0ff4c01c3 100644 --- a/OS/CatTiposOrdenesServicios.aspx.vb +++ b/OS/CatTiposOrdenesServicios.aspx.vb @@ -6,179 +6,165 @@ Imports System.Linq Imports Extensiones Partial Class OS_CatTiposOrdenesServicios - Inherits ClsPaginas + Inherits ClsPaginas - Public Property PuedeEditar As Boolean - Get - Return CBool(ViewState("PuedeEditar")) - End Get - Set(value As Boolean) - ViewState("PuedeEditar") = value - End Set - End Property + Private Property CveOrdenServicioTipo As Integer + Get + If Not ViewState("CveOrdenServicioTipo") Is Nothing Then + Return ViewState("CveOrdenServicioTipo").ToString.ToEntero + Else + Return -1 + End If - Public Property PuedeEliminar As Boolean - Get - Return CBool(ViewState("PuedeEditar")) - End Get - Set(value As Boolean) - ViewState("PuedeEditar") = value - End Set - End Property + End Get + Set(value As Integer) + ViewState("CveOrdenServicioTipo") = value + End Set - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not Page.IsPostBack Then - ViewState("Orden") = "" - CargaDatos() - End If - End Sub + End Property - Public Sub CargaDatos() - Dim ObjSubTipoOrdenServicios As New ClsOS + Private Property Actualizar As Boolean + Get + If Not ViewState("Actualizar") Is Nothing Then + Return DirectCast(ViewState("Actualizar"), Boolean) + Else + Return False + End If + End Get + Set(value As Boolean) + ViewState("Actualizar") = value + End Set + End Property + + + Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + + If Not Page.IsPostBack Then + CargadatosGvTiposOS() + End If + + End Sub + + Private Sub CargadatosGvTiposOS() + + Dim ObjSubTipoOrdenServicios As New ClsOS If ObjSubTipoOrdenServicios.GetTipoOrdenesServicios(-1) Then - ViewState("DTTipoOrdenServicios") = ObjSubTipoOrdenServicios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + GvTiposOS.DataSource = ObjSubTipoOrdenServicios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) GlobalDTSubTipoOrdenServicios = ObjSubTipoOrdenServicios.DtResultados Else - Me.GvDatos.DataSource = Nothing + GvTiposOS.DataSource = Nothing End If - ObjSubTipoOrdenServicios.Dispose() + ObjSubTipoOrdenServicios.Dispose() - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End Sub + GvTiposOS.DataBind() + UpGral.Update() - Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click - Dim ObjTipoOrdenServicios As New ClsOS - If ObjTipoOrdenServicios.AddTipoOrdenServicio(TxtTipoOrdenServicio.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - TxtTipoOrdenServicio.Text = "" - Alert("El nuevo Tipo de Orden de Servicio se guardó correctamente.", TipoMensaje.MsgInformacion) - UpTitulos.Update() - ViewState("DTTipoOrdenServicios") = ObjTipoOrdenServicios.DtResultados '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - 'GlobalDTTipoOrdenServicios(-1) = ObjTipoOrdenServicios.DtResultados + End Sub - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End If - ObjTipoOrdenServicios.Dispose() - End Sub + Protected Sub BtnAgregarTiposOS_Click(sender As Object, e As EventArgs) Handles BtnAgregarTiposOS.Click + LtlTituloModalTiposOS.Text = "Agregar Tipo de Orden de Servicio" + BtnAgregarTiposOSModal.Text = "Agregar" + DivEstatus.Visible = False -#Region "G V D A T O S" - Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(250) - e.Row.Cells(1).Width = Unit.Pixel(100) - e.Row.Cells(2).Width = Unit.Pixel(100) - e.Row.Cells(3).Width = Unit.Pixel(100) - e.Row.Cells(4).Width = Unit.Pixel(100) - e.Row.Cells(5).Width = Unit.Pixel(61) + TxtTiposOS.Text = "" + + Actualizar = False + UpGral.Update() + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposOS")) + + End Sub + + Protected Sub BtnAgregarTiposOSModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarTiposOSModal.Click + + Dim ObjTipoOrdenServicios As New ClsOS + + If Not Actualizar Then + If ObjTipoOrdenServicios.AddTipoOrdenServicio(TxtTiposOS.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + + TxtTiposOS.Text = "" + ChkEstatus.Checked = True + + CargadatosGvTiposOS() + + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposOS"), "jsHideModalTiposOS") + 'GeneraGlobalDT() + UpGral.Update() + + Alert("Tipo de Orden de Servicio Agregado Correctamente", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrio un error al guardar el Tipo de Orden de Servicio", TipoMensaje.MsgError) End If - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center - End If - End Sub - - Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting - Dim ObjTipoOrdenServicios As New ClsOS - If ObjTipoOrdenServicios.RemoveTipoOrdenServicio(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then - GvDatos.EditIndex = -1 - ViewState("DTTipoOrdenServicios") = ObjTipoOrdenServicios.DtResultados '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - 'GlobalDTTipoOrdenServicios(-1) = ObjTipoOrdenServicios.DtResultados - Alert("El Tipo de Orden de Servicio se eliminó correctamente.", TipoMensaje.MsgInformacion) - End If - ObjTipoOrdenServicios.Dispose() - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) Else - CargaGrid("") - End If - End Sub + If ObjTipoOrdenServicios.UpdateTipoOrdenServicio(TxtTiposOS.Text.Trim, False, ChkEstatus.Checked, CveOrdenServicioTipo) Then - Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit - GvDatos.EditIndex = -1 - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End Sub + TxtTiposOS.Text = "" + ChkEstatus.Checked = True - Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating - Dim ObjTipoOrdenServicios As New ClsOS - Dim TipoOrdenServicio As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtTipoOrdenServicio"), TextBox).Text.Trim - Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked - Dim CveTipoOrdenServicio As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero + CargadatosGvTiposOS() + 'GeneraGlobalDT() + UpModalTiposOS.Update() - If ObjTipoOrdenServicios.UpdateTipoOrdenServicio(TipoOrdenServicio, False, Estatus, CveTipoOrdenServicio) Then - GvDatos.EditIndex = -1 - ViewState("DTTipoOrdenServicios") = ObjTipoOrdenServicios.DtResultados '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - 'GlobalDTTipoOrdenServicios(-1) = ObjTipoOrdenServicios.DtResultados - Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposOS"), "jsHideModalTiposOS") + + UpGral.Update() + Alert("Tipo de Orden de Servicio Actualizado Correctamente", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrio un error al Actualizar el Tipo de Orden de Servicio", TipoMensaje.MsgError) + End If End If + + CveOrdenServicioTipo = -1 + Actualizar = False + ObjTipoOrdenServicios.Dispose() - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If End Sub - Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing - GvDatos.EditIndex = e.NewEditIndex - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) + Public Sub Remove_ClickTiposOS(sender As Object, e As EventArgs) + + Dim ObjTipoOrdenServicios As New ClsOS + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + CveOrdenServicioTipo = GvRow.DataKey("CveOrdenServicioTipo").ToEntero + + If ObjTipoOrdenServicios.RemoveTipoOrdenServicio(CveOrdenServicioTipo) Then + CargadatosGvTiposOS() + 'GeneraGlobalDT() + + Alert("El Tipo de Orden de Servicio se eliminó Correctamente ", TipoMensaje.MsgInformacion) Else - CargaGrid("") + Alert("Ocurrio un error al Eliminar el Tipo de Orden de Servicio", TipoMensaje.MsgError) End If - End Sub -#End Region -#Region "O R D E N A M I E N T O" - Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs) - Dim Orden As String = "" - Dim Campo As String = "" - Dim Literal As Literal = Nothing - Const OrdenInicial As String = "" - Dim Arg(2) As String + ObjTipoOrdenServicios.Dispose() - Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c) - Campo = Arg(0) - Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal) + CargadatosGvTiposOS() + + CveOrdenServicioTipo = -1 - If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then - ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo) - Literal.Text = String.Format("") - Else - ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo) - Literal.Text = String.Format("") - End If - Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString - ViewState("Orden") = Orden - CargaGrid(Orden) End Sub - Private Sub CargaGrid(Orden As String) - If Orden <> String.Empty Then - Dim DV As New DataView(CType(ViewState("DTTipoOrdenServicios"), DataTable), "", Orden, DataViewRowState.CurrentRows) - GvDatos.DataSource = DV.ToTable() - DV.Dispose() - Else - GvDatos.DataSource = CType(ViewState("DTTipoOrdenServicios"), DataTable) - End If - GvDatos.DataBind() - UpDatos.Update() + Public Sub Edit_ClickTiposOS(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + + LtlTituloModalTiposOS.Text = "Editar Tipo de Orden de Servicio" + Actualizar = True + DivEstatus.Visible = True + + CveOrdenServicioTipo = GvRow.DataKey("CveOrdenServicioTipo").ToEntero + + TxtTiposOS.Text = GvRow.DataKey("OrdenServicioTipo") + ChkEstatus.Checked = If(GvRow.DataKey("Estatus") = "Activo", True, False) + + BtnAgregarTiposOSModal.Text = "Actualizar" + + UpModalTiposOS.Update() + + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposOS")) + End Sub -#End Region -End Class + +End Class \ No newline at end of file From e05ae09b374408b9fdc3e582bc3c295a3595ab41 Mon Sep 17 00:00:00 2001 From: janeth arvizu Date: Thu, 15 Aug 2019 14:04:17 -0700 Subject: [PATCH 07/23] Combo de tipo de orden requerido --- OS/OrdenesServicios.aspx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OS/OrdenesServicios.aspx b/OS/OrdenesServicios.aspx index 850f62121..610f5a755 100644 --- a/OS/OrdenesServicios.aspx +++ b/OS/OrdenesServicios.aspx @@ -86,7 +86,7 @@
    -
    +
    Fecha Recibido:
    @@ -106,7 +106,7 @@
    - +
    Sucursal del Cliente: @@ -152,6 +152,8 @@
    + +
    From dc2affd5b2f91a5d37360f64716a086b2420692c Mon Sep 17 00:00:00 2001 From: Desarrollo2019 Date: Thu, 15 Aug 2019 17:01:58 -0700 Subject: [PATCH 08/23] --- .gitignore | 3 ++- Ventas/Ventas.aspx.vb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 87735880e..832ad61b6 100644 --- a/.gitignore +++ b/.gitignore @@ -265,4 +265,5 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc +/SIGGIT.sln diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 1c2c1ab10..68c76c68c 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9,6 +9,7 @@ Imports Microsoft.Reporting.WebForms Imports System.Security.Cryptography.X509Certificates Imports System.Globalization + Partial Class Ventas Inherits ClsPaginas From 96e35e9068d1eca3da31be4bd15f156aef1b810f Mon Sep 17 00:00:00 2001 From: Desarrollo2019 Date: Thu, 15 Aug 2019 18:16:59 -0700 Subject: [PATCH 09/23] Correcion de IVA y IEPS en la funcion de saldar en ClientesAbonar --- Ventas/ClientesAbonar.aspx.vb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 4a26aa753..01435d4c2 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -2104,23 +2104,23 @@ Partial Class Ventas_ClientesAbonar ' iva Dim PorcentajeImpuesto As Decimal = gr.DataKey("PorcentajeIVA").ToDecimal - Dim IdCtaIVATrasladado As Integer = 0 - Dim CveCuentaIVATrasladado As Integer = 0 + Dim IdCtaIVAXTrasladar As Integer = 0 + Dim CveCuentaIVAxTrasladar As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then - IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero - CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero + IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero + CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVAxTrasladar").ToString.ToEntero End If - IdCtaContable = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado) - CveCuenta = If(CveCuentaIVATrasladado > 0, CveCuentaIVATrasladado, UsuarioActual.Empresa.CveCuentaIVATrasladado) - If IVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 61, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) + CveCuenta = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar) + If IVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 13, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If - IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado - CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSTrasladado - If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 39, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar + CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar + If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 38, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If From 1e802e8fc03c207098c3ed68b1304c302d3b4fd6 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 16 Aug 2019 09:16:24 -0700 Subject: [PATCH 10/23] Calcular tiempo de timbrado --- App_Code/Timbrado.vb | 6781 +++++++++++++++++++++--------------------- 1 file changed, 3393 insertions(+), 3388 deletions(-) diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 58f118109..ef77aa206 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -1,3388 +1,3393 @@ -Option Explicit On -Option Strict On - -Imports Extensiones -Imports System.IO -Imports System.Linq -Imports System.Xml -Imports System.Data -Public Class Timbrado - -#Region "P R O P I E D A D E S" - Public Property MensajeErrorCFDI As String - Public Property UUID As String = "" - Public Property CancelacionAcuse As String - Public Property CancelacionState As Integer - Public Property CancelacionMensaje As String - Public Property CancelacionFecha As Date - - - Public Class AcuseCancelacionSAT - Public Property CodigoEstatus As String - Public Property EsCancelable As String - Public Property Estado As String - Public Property EstatusCancelacion As String - End Class - -#End Region - - Public Shared Function VerificarVigenciaSAT(uuid As String, emisor As String, receptor As String, total As String, produccion As Boolean) As AcuseCancelacionSAT - Dim Retorno As AcuseCancelacionSAT = Nothing - Dim resp As Cancelacion.AcuseSat = New Cancelacion.AcuseSat() - Using ws As Cancelacion.CancelacionSoapClient = New Cancelacion.CancelacionSoapClient - Try - If Not produccion Then - Dim PACUsuario As String = "rene.molina@adsistemas.mx" - Dim PACContrasenia As String = "rene2018" - resp = ws.ConsultaVigenciaTest(emisor, PACUsuario, PACContrasenia, uuid, receptor, total) - Retorno = New AcuseCancelacionSAT() - Else - resp = ws.ConsultaVigencia(emisor, "UserTest", "1234567890", uuid, receptor, total) - Retorno = New AcuseCancelacionSAT() - End If - Catch ex As Exception - Return Nothing - End Try - - If Retorno IsNot Nothing Then - Retorno.CodigoEstatus = resp.CodigoEstatus - Retorno.Estado = resp.Estado - Retorno.EsCancelable = resp.EsCancelable - Retorno.EstatusCancelacion = resp.EstatusCancelacion - End If - - End Using - Return Retorno - End Function - 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 - Return False - End If - Else - Return False - End If - End If - - - MsgCancelacion.AppendFormat("CvePAC:{0}", CvePACCancelacion) - - Select Case CvePACCancelacion - Case 1 - MsgCancelacion.AppendFormat("1.1") - Try - Dim CFDi As New ClbNegBICFDv3_2.ClsNegEDI - Dim Respuesta As New ClbNegBICFDv3_2.ClsNegRespuesta - Respuesta = CFDi.CancelaCFdi(Empresa.BIUsuario, Empresa.BIContraseña, Empresa.Ruta & "Certificados\" & Empresa.ArchivoPfx, Empresa.ContraseñaKey, Empresa.RFC, FolioFiscal, "http://portalbiinform.com.mx/srvCFDi/service1.asmx") - - If Respuesta IsNot Nothing AndAlso Respuesta.SelloSAT <> "" Then - Dim xml64 As String = "" - Dim myXml As String = Respuesta.SelloSAT - Dim resp As XElement = XElement.Parse(myXml) - For Each elem As XElement In resp.Descendants - If elem.Name = "xmlBase64" Then xml64 = elem.Value - Next - - 'If Respuesta.UUDI.Contiene("0", "201", "202") Then - Dim xmlDoc As New System.Xml.XmlDocument() - xmlDoc.LoadXml(If(xml64 = "", Respuesta.SelloSAT, Encoding.UTF8.GetString(Convert.FromBase64String(xml64)))) - Dim AcuseChild = xmlDoc.ChildNodes.Cast(Of XmlNode).Where(Function(a) a.Name.Equals("Acuse", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() - - Dim FoliosChild = AcuseChild.ChildNodes.Cast(Of XmlNode).Where(Function(a) a.LocalName.Equals("Folios", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() - Dim SignatureChild = AcuseChild.ChildNodes.Cast(Of XmlNode).Where(Function(a) a.LocalName.Equals("Signature", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() - - Dim prefixFol As String = FoliosChild.Prefix - If prefixFol <> "" Then prefixFol = $"{prefixFol}:" 'se le agregan los ":" si tiene prefijo - - CancelacionState = xmlDoc.GetElementsByTagName($"{prefixFol}EstatusUUID")(0).InnerText.ToEntero - 'verificación basada en el resultado del xml. - If CancelacionState.Contiene(201, 202) Then - - Dim prefixSig = SignatureChild.Prefix - If prefixSig <> "" Then prefixSig = $"{prefixSig}:" 'se le agregan los ":" si tiene prefijo - Dim SignatureValue = xmlDoc.GetElementsByTagName($"{prefixSig}SignatureValue") - CancelacionAcuse = If(SignatureValue.Count < 1, SignatureValue(0).InnerText, SignatureValue(0).InnerText) - Try - CancelacionFecha = AcuseChild.Attributes("Fecha").Value.ToDate - Catch ex As Exception - CancelacionFecha = xmlDoc.GetElementsByTagName("CancelaCFDResult")(0).Attributes("Fecha").Value.ToDate - End Try - Retorno = True - End If - - 'End If - - Else - Me.GuardaLog(CFDi.MsgError) - End If - Respuesta = Nothing - CFDi = Nothing - Catch ex As Exception - GuardaLog($"{ex.Message}") - End Try - - Case 2 - MsgCancelacion.AppendFormat("2.1") - Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" - Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" - Dim UsuarioServicio As String = If(CvePACCancelacion = 2, Empresa.RFC, "rene.molina@adsistemas.mx") - Dim ClaveServicio As String = If(CvePACCancelacion = 2, Empresa.RFC.ToLower, "rene2018") - Dim Clave As String = Empresa.ContraseñaKey - Dim UrlServicio As String = "" ' Produccion - Select Case CvePACCancelacion - Case 2 - UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" - Case 4 - UrlServicio = "http://192.168.0.2:8080/ADSistemas/Timbrado.asmx?WSDL" - End Select - - If Not Empresa.FacturaProduccion Then - ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" - Select Case CvePACCancelacion - Case 2 - UsuarioServicio = "fgomez" - ClaveServicio = "12121212" - UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" - Case 4 - UsuarioServicio = "UserTest" - ClaveServicio = "1234567890" - UrlServicio = "http://192.168.0.2:8080/ADSistemas/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 False - End If - If Not File.Exists(ArchivoLLave) Then - Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) - Return False - End If - If Empresa.ContraseñaKey = "" Then - Alert("La clave no puede ser vacía", TipoMensaje.MsgError) - Return False - End If -#End Region - -#Region "Variables" - Dim llaveByte As Byte(), certByte As Byte() - Dim llaveBase64 As String, certBase64 As String - Dim cfdi As New RVCFDI.GeneraCFDI() - 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 False - 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 False - - End Try -#End Region - - - Dim base64 As String - Dim ObjCancelacion As New RVCancelacion.Cancelacion() - - Dim xmlCancelacion As String = ObjCancelacion.crearXMLCancelacion(certBase64, llaveBase64, Clave, FolioFiscal) - If (ObjCancelacion.MensajeDeError = "") Then - - base64 = CodificarABase64(xmlCancelacion) - - Dim objWS As RVCFDI.WSGeneraCFDI.Service = Nothing - Dim objAuthSoapHD As RVCFDI.WSGeneraCFDI.AuthSoapHd - Dim objResponse As RVCFDI.WSGeneraCFDI.StructCfd - Dim objCancel As RVCFDI.WSGeneraCFDI.StructCancel - - Try - - - 'Variables de consumo de servicio web - objWS = New RVCFDI.WSGeneraCFDI.Service() - objAuthSoapHD = New RVCFDI.WSGeneraCFDI.AuthSoapHd() - 'creacion de Autorizacion de cabecera Soap - objCancel = New RVCFDI.WSGeneraCFDI.StructCancel() - 'Configura el servicio - objWS.Url = UrlServicio - - objAuthSoapHD.strPassword = ClaveServicio - objAuthSoapHD.strUserName = UsuarioServicio - 'Coloca la cabecera - objWS.AuthSoapHdValue = objAuthSoapHD - 'Obtiene el resultado - objCancel = objWS.CancelTicket(base64) - 'Valida la respuesta - ''Codigos del SAT - ''201 - El folio se ha cancelado con éxito. - ''202 - El CFDI ya había sido cancelado previamente. - ''203 - UUID no corresponde al emisor. - ''204 - El CFDI no aplica para cancelación. - ''205 - El UUID no existe o no ha sido procesado por el SAT. - ''402 - El Contribuyente no se encuentra el la LCO o la validez de obligaciones se reporta como negativa. - CancelacionState = objCancel.state - CancelacionMensaje = objCancel.Descripcion - - If objCancel.state.Contiene(0, 201, 202) Then - CancelacionFecha = Now - - Select Case CvePACCancelacion - Case 2 - Dim solicitud As New WSRVConsultas.Service1SoapClient - Dim resp As New WSRVConsultas.resp_Acuse() - resp = solicitud.ConsultarAcuseCancelacion(RFCEmisor, UsuarioServicio, ClaveServicio, FolioFiscal, CancelacionFecha.ToShortDateString) - CancelacionMensaje = objCancel.Descripcion - - If (resp.Estado = 0) Then - - Dim xmlDoc As New System.Xml.XmlDocument() - xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml))) - Dim xpath As String = "Acuse/Folios" - Dim nodes = xmlDoc.SelectNodes(xpath) - CancelacionState = xmlDoc.GetElementsByTagName("EstatusUUID")(0).InnerText.ToEntero - - xpath = "Acuse/Signature" - nodes = xmlDoc.SelectNodes(xpath) - - CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText - CancelacionFecha = xmlDoc.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate - Retorno = True - Else - CancelacionAcuse = resp.MensajeDeError - Retorno = False - End If - solicitud = Nothing - Case 4 - - Dim solicitud As New WSGF.Service1SoapClient - Dim resp As New WSGF.StructXml() - resp = solicitud.GetAcuse(RFCEmisor, UsuarioServicio, ClaveServicio, FolioFiscal) - CancelacionMensaje = objCancel.Descripcion - - If (resp.Estado = 0) Then - - Dim xmlDoc As New System.Xml.XmlDocument() - xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(resp.CfdiB64))) - Dim xpath As String = "Acuse/Folios" - Dim nodes = xmlDoc.SelectNodes(xpath) - CancelacionState = xmlDoc.GetElementsByTagName("EstatusUUID")(0).InnerText.ToEntero - - xpath = "Acuse/Signature" - nodes = xmlDoc.SelectNodes(xpath) - - CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText - CancelacionFecha = xmlDoc.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate - Retorno = True - Else - CancelacionAcuse = resp.Descripcion - Retorno = False - End If - solicitud = Nothing - End Select - - - End If - Catch ex As Exception - CancelacionMensaje += $" | ex: {ex}" - Retorno = False - End Try - - 'Libera memoria - objWS.Dispose() - objResponse = Nothing - objAuthSoapHD = Nothing - GC.Collect() - End If - - - Case 3 - MsgCancelacion.AppendFormat("3.1") - Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" - Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" - Dim UsuarioServicio As String = Empresa.RFC - Dim ClaveServicio As String = Empresa.RFC.ToLower - Dim Clave As String = Empresa.ContraseñaKey - Dim UrlServicio As String = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" - Dim AmbienteProductivo As Boolean = True - - If Not Empresa.FacturaProduccion OrElse Empresa.CveEmpresa = 1 Then - UsuarioServicio = "fgomez" - ClaveServicio = "12121212" - Clave = "12345678a" - ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" - UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" '"http://108.60.211.43/rvltimbrado/service1.asmx" - AmbienteProductivo = False - End If - - -#Region "Valida" - If Not File.Exists(ArchivoCertificado) Then - Alert("El archivo de certificado no existe", TipoMensaje.MsgError) - Return False - End If - If Not File.Exists(ArchivoLLave) Then - Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) - Return False - End If - If Empresa.ContraseñaKey = "" Then - Alert("La clave no puede ser vacía", TipoMensaje.MsgError) - Return False - End If -#End Region - - Dim conector As New Profact.TimbraCFDI33.Conector(AmbienteProductivo) - - If Not AmbienteProductivo Then - conector.EstableceCredenciales("mvpNUXmQfK8=") - Else - conector.EstableceCredenciales("vSGxMFWnNRy/nDoowxqrqw==|Sia123654") - End If - - Dim resultadoCancelacion As Profact.TimbraCFDI.ResultadoCancelacionAck - resultadoCancelacion = conector.CancelaCFDIAck(RFCEmisor, FolioFiscal) - CancelacionFecha = Now - Dim resp As Profact.TimbraCFDI.ResultadoConsulta - resp = conector.ObtieneCFDI(RFCEmisor, FolioFiscal) - If resultadoCancelacion.Exitoso Then - CancelacionMensaje = resultadoCancelacion.Descripcion - Dim xmlDoc As New System.Xml.XmlDocument() - xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml))) - Dim xpath As String = "Acuse/Folios" - Dim nodes = xmlDoc.SelectNodes(xpath) - CancelacionState = xmlDoc.GetElementsByTagName("EstatusUUID")(0).InnerText.ToEntero - - xpath = "Acuse/Signature" - nodes = xmlDoc.SelectNodes(xpath) - - CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText - CancelacionFecha = xmlDoc.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate - Retorno = True - Else - CancelacionAcuse = resp.NumeroError - Retorno = False - End If - - Case 4 - MsgCancelacion.AppendFormat("4.1-") - Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" - Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" - Dim UsuarioServicio As String = If(CvePACCancelacion = 2, Empresa.RFC, "rene.molina@adsistemas.mx") - Dim ClaveServicio As String = If(CvePACCancelacion = 2, Empresa.RFC.ToLower, "rene2018") - Dim Clave As String = Empresa.ContraseñaKey - Dim UrlServicio As String = "" ' Produccion - - UrlServicio = "http://juancalderon-001-site1.ftempurl.com/timbrado.asmx?WSDL" - - If Not Empresa.FacturaProduccion Then - ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" - - UsuarioServicio = "UserTest" - ClaveServicio = "1234567890" - UrlServicio = "http://juancalderon-001-site6.ftempurl.com/cancelacion.asmx?WSDL" - - End If - -#Region "Valida" - If Not File.Exists(ArchivoCertificado) Then - Alert("El archivo de certificado no existe", TipoMensaje.MsgError) - Return False - End If - If Not File.Exists(ArchivoLLave) Then - Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) - Return False - End If - If Empresa.ContraseñaKey = "" Then - Alert("La clave no puede ser vacía", TipoMensaje.MsgError) - Return False - End If -#End Region - -#Region "Variables" - Dim llaveByte As Byte(), certByte As Byte() - Dim llaveBase64 As String, certBase64 As String - Dim objCan 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 False - 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 False - - End Try -#End Region - objCan.CancelacionCfdi = True - objCan.FechaCancelacion = System.DateTime.Now.AddMinutes(-120) ' operación requerida para que no se presente problemas con fechas adelantadas del PAC - MsgCancelacion.AppendFormat("4.3-") - objCan.GeneraCancelacionB64(certBase64, llaveBase64, Clave, FolioFiscal) - If (objCan.MensajeError = "") Then - MsgCancelacion.AppendFormat("4.4-") - objCan.CancelaCfdi(UsuarioServicio, ClaveServicio, UrlServicio, Empresa.FacturaProduccion) - MsgCancelacion.AppendFormat("4.5-") - '' Verifica el resultado, 0. cancelado, 202, cancelado previamente - If (objCan.CodigoError.Contiene(0, 202)) Then - - MsgCancelacion.AppendFormat("4.5.1-") - Dim xmlDoc As New System.Xml.XmlDocument() - xmlDoc.LoadXml(objCan.Xml) - Dim xpath As String = "Acuse/Folios" - Dim nodes = xmlDoc.SelectNodes(xpath) - - xpath = "Acuse/Signature" - nodes = xmlDoc.SelectNodes(xpath) - - CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText - CancelacionFecha = xmlDoc.DocumentElement.Attributes("Fecha").Value.ToDate - Retorno = True - MsgCancelacion.AppendFormat("4.5.2-") - End If - - End If - MsgCancelacion.AppendFormat("{0} --Código:{1} -- XML: {2}", objCan.MensajeError, objCan.CodigoError, objCan.Xml) - - End Select - - - If Not Retorno Then - GuardaLog($"****** Error al cancelar factura ****** Estatus: {CancelacionState} | Mensaje: {CancelacionMensaje} | Mensaje SAT: {MsgCancelacion.ToString} ") - End If - - Return Retorno - End Function - Public Function PreparaTimbrePago(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String, - ReceptorRFC As String, ReceptorNombre As String, Serie As String, Folio As String, FechaTimbrado As DateTime, - CuentaPago As String, FechaPago As DateTime, FormaPago As String, MonedaPago As String, Monto As Double, LugarExpedicion As String, - CuentaBeneficiario As String, TipoCambioP As Double, dttpagos As Data.DataTable, - Optional UsoCFDI As String = "P01", Optional CFDIRelacionado As String = "", Optional EsCancelacion As Boolean = False) As CFDITimbre - ' validación extra para cuando es cancelación requiere el folio relacionado - If EsCancelacion AndAlso CFDIRelacionado = "" Then - Return Nothing - End If - - Dim Timbre As New CFDITimbre - - Timbre.Comprobante.TipoComprobante = "P" - Timbre.Comprobante.Folio = Folio - Timbre.Comprobante.Serie = Serie - Timbre.Comprobante.Fecha = FechaTimbrado - Timbre.Comprobante.FormadePago = "" - Timbre.Comprobante.CondicionesdePago = "" - Timbre.Comprobante.MetodoPago = "" - Timbre.Comprobante.Subtotal = 0 - Timbre.Comprobante.Descuentos = 0 - Timbre.Comprobante.Moneda = "XXX" - Timbre.Comprobante.TipoCambio = "" - Timbre.Comprobante.Total = 0 - - Timbre.Comprobante.LugarExpedicion = LugarExpedicion - - Timbre.Emisor.RegimenFiscal = EmisorRegimenFiscal - Timbre.Emisor.Nombre = EmisorNombre - Timbre.Emisor.RFC = EmisorRFC - - Timbre.Receptor.RFC = ReceptorRFC - Timbre.Receptor.Nombre = ReceptorNombre - Timbre.Receptor.UsoCFDI = UsoCFDI - - If CFDIRelacionado <> "-1" And CFDIRelacionado <> "" Then - Timbre.CFDIRelacionados.TipoRelacion = "04" - Timbre.CFDIRelacionados.UUID.Add(CFDIRelacionado) - End If - - 'detalles - - Dim concepto As New CFDIConceptos With {.Cantidad = 1, - .Descripcion = "Pago", - .ValorUnitario = 0, - .Importe = 0, - .Unidad = "", - .ClaveUnidad = "ACT", - .ClaveProdServ = "84111506", - .Noidentificacion = ""} - Timbre.Conceptos.Add(concepto) - - Select Case FormaPago - Case "01" - CuentaPago = "" - CuentaBeneficiario = "" - - End Select - - Dim ImporteCancelacion As Decimal = 1 - Dim MonedaCancelacion As String = "MXN" - Dim TipoCambioCancelacion As Double = 1 - If EsCancelacion Then MonedaPago = MonedaCancelacion - 'como registra un peso por cada fatura que se cancele, se tiene que multiplicar por el numero de facturas, para que se pueda emitir el timbre - If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then ImporteCancelacion = ImporteCancelacion * dttpagos.Rows.Count - Timbre.ComplementoPagos.CtaOrdenante = CuentaPago - Timbre.ComplementoPagos.CtaBeneficiario = CuentaBeneficiario - Timbre.ComplementoPagos.FechaPago = FechaPago - Timbre.ComplementoPagos.FormaDePagoP = FormaPago - Timbre.ComplementoPagos.MonedaP = MonedaPago - Timbre.ComplementoPagos.Monto = If(EsCancelacion, ImporteCancelacion, Monto) - Timbre.ComplementoPagos.TipoCambioP = If(EsCancelacion, TipoCambioCancelacion, TipoCambioP) - - - Dim VentaFolioFiscal, VentaSerie, VentaFolio, VentaAbreviaturaSAT, VentaMetodoPago As String - Dim VentaImportePago, VentaImporteSaldoInsoluto, VentaImporteSaldoAnterior, VentaTipoCambio, PorcentajeIVA, PorcentajeIEPS As Decimal - Dim VentaNumParcialidad As Integer - - If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then - - For Each dr As Data.DataRow In dttpagos.Rows - VentaFolioFiscal = dr("FolioFiscal").ToString - VentaSerie = dr("VentaSerie").ToString - VentaFolio = dr("VentaFolio").ToString - VentaAbreviaturaSAT = dr("VentaAbreviaturaSAT").ToString - VentaMetodoPago = dr("MetodoPago").ToString - VentaImportePago = dr("VentaImportePagado").ToString.ToDecimal - VentaImporteSaldoInsoluto = dr("ImpSaldoInsoluto").ToString.ToDecimal - VentaImporteSaldoAnterior = dr("ImpSaldoAnterior").ToString.ToDecimal - VentaTipoCambio = dr("TipoCambio").ToString.ToDecimal - VentaNumParcialidad = dr("NumParcialidad").ToString.ToEntero - PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal - PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal - ' si la moneda es igual, se omite el tipo de cambio de la venta - If MonedaPago = VentaAbreviaturaSAT Then VentaTipoCambio = 0 - - 'condiciones especiales para el pago en pesos, facturas en moneda extranjera - If MonedaPago = "MXN" AndAlso VentaAbreviaturaSAT <> "MXN" Then - VentaTipoCambio = 1 / VentaTipoCambio - End If - - ' For Each drr As Data.DataRow In DtFacturasPagadas.Rows - Dim doc As New CFDIComplementoPagosDocsRelacionados With {.IdDocumento = VentaFolioFiscal, - .Serie = VentaSerie, - .Folio = VentaFolio, - .MonedaDR = VentaAbreviaturaSAT, - .MetodoDePagoDR = VentaMetodoPago, - .ImpPagado = If(EsCancelacion, 1, VentaImportePago), - .ImpSaldoInsoluto = If(EsCancelacion, VentaImporteSaldoAnterior - 1, VentaImporteSaldoInsoluto), - .ImpSaldoAnt = VentaImporteSaldoAnterior, - .TipoCambioDR = VentaTipoCambio, - .NumParcialidad = VentaNumParcialidad} 'If(drr("MetodoPago").ToString = "PUE", 0, drr("NumParcialidad").ToString.ToEntero)} - Timbre.ComplementoPagos.DocumentosRelacionados.Add(doc) - - Next - End If - 'If drr("IVA").ToString.ToDouble > 0 Then - If PorcentajeIVA > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = VentaImportePago * PorcentajeIVA, .TasaOCuota = PorcentajeIVA, .Impuesto = "002"}) - 'Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = 0, .TasaOCuota = 0, .Impuesto = "002"}) - - If PorcentajeIEPS > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.Base = VentaImportePago * PorcentajeIEPS, .TasaOCuota = PorcentajeIEPS, .Impuesto = "003"}) - - - 'Next - - Return Timbre - - End Function - Public Function TimbrarFactura(UsuarioActual As Usuario, Ventas As Modelos.Factura, Optional CvePACEspecial As Integer = -1) As Boolean - - Dim Retorno As Boolean = False - Dim tCvePAC As Integer = UsuarioActual.Empresa.CvePAC - If CvePACEspecial <> -1 Then tCvePAC = CvePACEspecial - - Select Case tCvePAC - Case 1 - ' Retorno = TimbrarFacturaBIInform33(UsuarioActual, Ventas, FM, TmpDTConceptos, TmpDTImpuestos, TmpDT7Eleven, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) - Dim Ret As String = TimbrarFacturaBIInform33(Ventas, UsuarioActual) - Retorno = If(Ret = "", True, False) - - Case 2 - 'Retorno = TimbrarFacturaRealVirtual(UsuarioActual, Ventas, TmpDTConceptos, TmpDTImpuestos, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) - Dim Ret As String = TimbrarFacturaRealVirtualv33(Ventas, UsuarioActual) - Retorno = If(Ret = "", True, False) - - Case 3 - Retorno = TimbrarFacturaProFact(UsuarioActual, Ventas) - 'Retorno = TimbrarFacturaProFact(UsuarioActual, Ventas, TmpDTConceptos, TmpDTImpuestos, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) - Case 4 - - Dim Ret As String = TimbrarFacturaGoCFDIv33(Ventas, UsuarioActual) - Retorno = If(Ret = "", True, False) - - End Select - - - Return Retorno - End Function - Public Function TimbrarFacturaBIInform33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String - - - Dim Retorno As String = "" - - 'Dim SucMatriz As SubProyectoModel = Ventas.SubProyectoMatriz - 'Dim SucEmpresa As SubProyectoModel = Ventas.SubProyecto - 'Dim SucCliente As SucursalModel = Ventas.ClienteSucursal - Dim ObjCFDITimbre As CFDITimbre = Ventas.Timbre - Dim ArchivoLLave As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoKey}" - Dim ArchivoCertificado As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoCer}" - Dim ArchivoPFX As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoPfx}" - Dim UsuarioServicio As String = UsuarioActual.Empresa.RFC - Dim ClaveServicio As String = UsuarioActual.Empresa.RFC.ToLower - Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey - Dim EmisorRFC As String = UsuarioActual.Empresa.RFC - Dim UrlServicio As String = "http://portalbiinform.com.mx/srvCFDi33/service1.asmx" ' Produccion - Dim RutaArchivo As String = $"{UsuarioActual.Empresa.Ruta}XML\{Ventas.TipoDocto}\" - Dim NombreArchivoXML As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}" - Dim TimbraProduccion As Boolean = True - - 'Dim sevenElevenNumProveedor = TmpDT7Eleven.Rows(0)("sevenElevenNumProveedor").ToString - 'Dim sevenElevenFolio = TmpDT7Eleven.Rows(0)("sevenElevenFolio").ToString - 'Dim sevenElevenTienda = TmpDT7Eleven.Rows(0)("sevenElevenTienda").ToString - 'Dim sevenElevenFecha = TmpDT7Eleven.Rows(0)("sevenElevenFecha").ToString - - If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then - UsuarioServicio = UsuarioActual.Empresa.BIUsuario - ClaveServicio = UsuarioActual.Empresa.BIContraseña - Clave = "12345678a" - EmisorRFC = "AAA010101AAA" - ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" - UrlServicio = "http://portalmacropro.com.mx/srvCFDi33prueba/service1.asmx" - TimbraProduccion = False - End If - - Dim CFDi As New ClbNegBICFDv3_3.ClsNegEDI - Dim ObjFemsa As New ClbNegBICFDv3_3.ClsNegAddFemsa - Dim ObjDetallista As New ClbNegBICFDv3_3.ClsNegEDICompDet - Dim ImpLoc As New ClbNegBICFDv3_3.ClsNegEDICompImplocal - - Dim Msg As String = String.Empty - 'Nodo Comprobante - Dim clbcomp As ClbNegBICFDv3_3.TipoDeComprobante = If(ObjCFDITimbre.Comprobante.TipoComprobante = "I", ClbNegBICFDv3_3.TipoDeComprobante.I, If(ObjCFDITimbre.Comprobante.TipoComprobante = "E", ClbNegBICFDv3_3.TipoDeComprobante.E, If(ObjCFDITimbre.Comprobante.TipoComprobante = "P", ClbNegBICFDv3_3.TipoDeComprobante.P, ClbNegBICFDv3_3.TipoDeComprobante.T))) - Msg = CFDi.comprobantecfd(0, 0, ObjCFDITimbre.Comprobante.Serie, - ObjCFDITimbre.Comprobante.Folio.ToString, - ObjCFDITimbre.Comprobante.Fecha, - ObjCFDITimbre.Comprobante.FormadePago, - ObjCFDITimbre.Comprobante.CondicionesdePago, - ObjCFDITimbre.Comprobante.Subtotal, - ObjCFDITimbre.Comprobante.Descuentos, - ObjCFDITimbre.Comprobante.TipoCambio.ToDecimal, - ObjCFDITimbre.Comprobante.Moneda, - ObjCFDITimbre.Comprobante.Total, - ObjCFDITimbre.Comprobante.MetodoPago, - clbcomp, - ObjCFDITimbre.Comprobante.LugarExpedicion, - ObjCFDITimbre.Comprobante.Confirmacion) - - If Msg = String.Empty Then - 'Nodo emisor - Msg = CFDi.EmisorCfd(If(UsuarioActual.Empresa.FacturaProduccion, UsuarioActual.Empresa.RFC, "AAA010101AAA"), UsuarioActual.Empresa.Empresa, UsuarioActual.Empresa.CodigoRegimenFiscal) - If Msg = String.Empty Then - - 'Nodo receptor - Msg = CFDi.ReceptorCfd(Ventas.Cliente.RFC, Ventas.Cliente.Nombre, "", "", Ventas.ClaveUsoCFDI) - If Msg = String.Empty Then - - 'Nodo conceptos, se agregan los PS - Dim HasErrorConceptos As Boolean = False - - If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then - For Each concep As CFDIConceptos In ObjCFDITimbre.Conceptos - CFDi.ConceptosCfd(concep.ClaveProdServ, concep.Cantidad, concep.Unidad, concep.Noidentificacion, concep.Descripcion, concep.ValorUnitario, concep.Importe, concep.ClaveUnidad, concep.Descuento) - For Each imp As CFDIConceptosImpuestos In concep.Impuestos - Dim clbImp As ClbNegBICFDv3_3.Impuesto = If(imp.Impuesto = "002", ClbNegBICFDv3_3.Impuesto.IVA, If(imp.Impuesto = "003", ClbNegBICFDv3_3.Impuesto.IEPS, ClbNegBICFDv3_3.Impuesto.ISR)) - Dim clbTipo As ClbNegBICFDv3_3.TipoFactor = If(imp.TipoFactor = "Tasa", ClbNegBICFDv3_3.TipoFactor.Tasa, If(imp.TipoFactor = "Cuota", ClbNegBICFDv3_3.TipoFactor.Cuota, ClbNegBICFDv3_3.TipoFactor.Exento)) - Dim Posicion As Integer = imp.TasaOCuota.ToString.IndexOf(".") - If imp.TrasladooRetencion = "T" Then - CFDi.ConceptosTrasladosCfd(imp.Base, clbImp, clbTipo, imp.TasaOCuota.ToString.PadRight(imp.TasaOCuota.ToString.Length + (6 - imp.TasaOCuota.ToString.Substring(Posicion, imp.TasaOCuota.ToString.Length - 1).Length.ToEntero + 1), Convert.ToChar("0")), imp.Importe) - Else - CFDi.ConceptosRetencionesCfd(imp.Base, clbImp, clbTipo, imp.TasaOCuota.ToString.PadRight(imp.TasaOCuota.ToString.Length + (6 - imp.TasaOCuota.ToString.Substring(Posicion, imp.TasaOCuota.ToString.Length - 1).Length.ToEntero + 1), Convert.ToChar("0")), imp.Importe) - End If - - Next - Next - End If - - - If Not HasErrorConceptos Then - 'Nodo Impuestos, se agrega el total de impuestos - Msg = CFDi.ImpuestosCfd(Ventas.RetIVATC + Ventas.RetISRTC, Ventas.IVATC) - If Msg = String.Empty Then - - Dim HasErrorRetenciones As Boolean = False - 'Nodo Impuestos-retenciones - - - For Each Ret In ObjCFDITimbre.Retenciones - Dim clbImp As ClbNegBICFDv3_3.Impuesto = If(Ret.Impuesto = "002", ClbNegBICFDv3_3.Impuesto.IVA, If(Ret.Impuesto = "003", ClbNegBICFDv3_3.Impuesto.IEPS, ClbNegBICFDv3_3.Impuesto.ISR)) - Msg = CFDi.ImpuestosRetencionesCfd(clbImp, Ret.Importe.ToDecimal) - Next - - If Not HasErrorRetenciones Then - - 'Nodo Impuestos-traslado - Dim HasErrorIVA As Boolean = False - ''se acumulan los importes - For Each Tras In ObjCFDITimbre.Traslados - Dim Posicion As Integer = Tras.TasaOCuota.ToString.IndexOf(".") - Dim tipfact As ClbNegBICFDv3_3.TipoFactor = If(Tras.TipoFactor = "Tasa", ClbNegBICFDv3_3.TipoFactor.Tasa, If(Tras.TipoFactor = "Cuota", ClbNegBICFDv3_3.TipoFactor.Cuota, ClbNegBICFDv3_3.TipoFactor.Exento)) - Msg = CFDi.ImpuestosTrasladosCfd(ClbNegBICFDv3_3.Impuesto.IVA, Tras.TasaOCuota.ToString.PadRight(Tras.TasaOCuota.ToString.Length + (6 - Tras.TasaOCuota.ToString.Substring(Posicion, Tras.TasaOCuota.ToString.Length - 1).Length.ToEntero + 1), Convert.ToChar("0")), Tras.Importe, tipfact) - Next - - - If Not HasErrorIVA Then - 'Nodo Impuestos locales - 'JJMQ 20150826: Se habilitó de nueva cuenta impuestos locales - Dim HasErrorImpuestosLocales As Boolean = False - Dim TieneImpuestosLocales As Boolean = False - - - If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 Then - - For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales - If ret.Importe > 0 Then - Msg = ImpLoc.RetencionesLocales(ret.ImpuestoLocalRetenido, ret.TasaRetencion, ret.Importe) - TieneImpuestosLocales = True - End If - Next - End If - - CFDi.CompImplocal = ImpLoc - If Msg <> String.Empty Then HasErrorImpuestosLocales = True - - If Not HasErrorImpuestosLocales Then - - - - 'Agrega Adenda FEMSA - Dim HasErrorFEMSA As Boolean = False - If Ventas.Cliente.AplicaFEMSA Then - - Msg = ObjFemsa.Carga(Ventas.FemsaFactura.FEMSA_Version, Ventas.ClaseDoctoSat, Ventas.FemsaFactura.FEMSA_NumSociedad, Ventas.FemsaFactura.FEMSA_NumProveedor, Ventas.FemsaFactura.FEMSA_NumPedido, - Ventas.MonedaAbreviatura, Ventas.FemsaFactura.FEMSA_NumEntrada, Ventas.FemsaFactura.FEMSA_NumRemision, Ventas.FemsaFactura.FEMSA_NumSocio, Ventas.FemsaFactura.FEMSA_CentroCosto, - Ventas.FemsaFactura.FEMSA_IPeriodoLiquidacion, Ventas.FemsaFactura.FEMSA_FPeriodoLiquidacion, Ventas.FemsaFactura.FEMSA_CodRetencion1, Ventas.FemsaFactura.FEMSA_CodRetencion2, - Ventas.FemsaFactura.FEMSA_Mail) - If Msg <> String.Empty Then HasErrorFEMSA = True - End If - - If Not HasErrorFEMSA Then - If Ventas.Cliente.AplicaFEMSA Then Msg = CFDi.AddendaFemsa(ObjFemsa) - If Msg = String.Empty Then - 'Agrega Complemento Detallista - Dim HasErrorDetallista As Boolean = False - If Ventas.Cliente.AplicaDetallista Then - 'Desarrollar Detallista - If Msg <> String.Empty Then HasErrorDetallista = True - '1 - Msg = ObjDetallista._1_1R_requestForPaymentIdentification(ClbNegBICFDv3_3.CompDetEntityType.INVOICE) - If Msg <> String.Empty Then HasErrorDetallista = True - '2 - Dim LstInstruccionComercial As New List(Of String) - LstInstruccionComercial.Add(Ventas.TotalTC.ToString.ToDouble.Texto2Letras.ToUpper) - Msg = ObjDetallista._2_1O_SpecialInstruction(ClbNegBICFDv3_3.CompDetCode.ZZZ, LstInstruccionComercial) - If Msg <> String.Empty Then HasErrorDetallista = True - '3 - Msg = ObjDetallista._3_1R_OrderIdentification_ReferenceIdentification("ON", Ventas.Det_OrdenCompra) - If Msg <> String.Empty Then HasErrorDetallista = True - Msg = ObjDetallista._3_2O_OrderIdentification_ReferenceDate(Ventas.Det_FechaOrdenCompra.ToDate) - If Msg <> String.Empty Then HasErrorDetallista = True - '4 - Msg = ObjDetallista._4_1R_AdditionalInformation_ReferenceIdentification("DQ", Ventas.Det_ContraRecibo) - If Msg <> String.Empty Then HasErrorDetallista = True - '5 - Msg = ObjDetallista._5_1R_DeliveryNote_ReferenceIdentification(Ventas.Det_ContraRecibo) - If Msg <> String.Empty Then HasErrorDetallista = True - Msg = ObjDetallista._5_2O_DeliveryNote_ReferenceDate(Ventas.Det_FechaOrdenCompra.ToDate) - If Msg <> String.Empty Then HasErrorDetallista = True - '6 - Msg = ObjDetallista._6_1R_Buyer(Ventas.Cliente.Detallista_GLNComprador, Ventas.Cliente.Detallista_Departamento) - If Msg <> String.Empty Then HasErrorDetallista = True - '7 - Msg = ObjDetallista._7_1R_Seller(Ventas.Cliente.Detallista_GLNVendedor, "SELLER_ASSIGNED_IDENTIFIER_FOR_A_PARTY", Ventas.Cliente.Detallista_NumProveedor) - If Msg <> String.Empty Then HasErrorDetallista = True - '8 - Msg = ObjDetallista._8_1O_AllowanceCharge(ClbNegBICFDv3_3.CompDetNetAllowanceChargeType.ALLOWANCE_GLOBAL, - ClbNegBICFDv3_3.CompDetNetSettlementType.OFF_INVOICE, - "0", - ClbNegBICFDv3_3.CompDetNetSpecialServicesType.AJ, - ClbNegBICFDv3_3.CompDetNetMonetaryAmountOrPercentageBase.INVOICE_VALUE, - If(Ventas.DescuentoTC > 0 AndAlso Ventas.SubTotalTC > 0, (Ventas.DescuentoTC * 100) / Ventas.SubTotalTC, 0)) - If Msg <> String.Empty Then HasErrorDetallista = True - '9 - Dim LineNumber As Integer = 1 - If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then - For Each Row As DataRow In Ventas.DtDetalle.Rows - Dim PS As String = If(Row("PS").ToString.Length = 1, Row("Obs").ToString, If(Row("PS").ToString.Length = 0, "", Row("PS").ToString & " ") & Row("Obs").ToString & If(Row("Obs").ToString.Trim.Length > 0, vbLf, "")) & vbLf - Msg = ObjDetallista._9_1R_LineItem("SimpleInvoidLineItemType", - LineNumber, - Row("Codigo").ToString, - ClbNegBICFDv3_3.CompDetAlternateTradeItemIdentification.SUPPLIER_ASSIGNED, - Row("Codigo").ToString, - ClbNegBICFDv3_3.CompDetNetLanguage.ES, - If((Row("Codigo").ToString & If(Row("Codigo").ToString.Length > 0, "-", "") & PS).Length > 35, (Row("Codigo").ToString & If(Row("Codigo").ToString.Length > 0, "-", "") & PS).Substring(0, 34), (Row("Codigo").ToString & If(Row("Codigo").ToString.Length > 0, "-", "") & PS)), - If(Row("UM").ToString.ToLower = "no aplica", "NA", Row("UM").ToString), - Row("Cantidad").ToString, - Row("PU").ToString.ToDecimal, - Row("PU").ToString.ToDecimal * (1 + Row("IVA").ToString.ToDecimal), - Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, - (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) * (1 + Row("IVA").ToString.ToDecimal)) - LineNumber = LineNumber + 1 - Next - End If - If Msg <> String.Empty Then HasErrorDetallista = True - '10 - Msg = ObjDetallista._10_1R_TotalAmount(Ventas.SubTotalTC) - If Msg <> String.Empty Then HasErrorDetallista = True - '11 - Msg = ObjDetallista._11_1R_TotalAllowanceCharge(ClbNegBICFDv3_3.CompDetNetAllowanceOrChargeType.ALLOWANCE, - ClbNegBICFDv3_3.CompDetNetSpecialServicesType.AA, - Ventas.DescuentoTC) - If Msg <> String.Empty Then HasErrorDetallista = True - End If - If Not HasErrorDetallista Then - If Ventas.Cliente.AplicaDetallista Then Msg = CFDi.ClomplementoDetallistaCfd(ObjDetallista) - If Msg <> String.Empty Then HasErrorDetallista = True - 'Timbrar - - 'Web Services de producción: http://biinform.com.mx/srvCFDi/service1.asmx - 'Web Services de pruebasd: http://biinform.com.mx/srvCFDiPrueba/service1.asmx - - - - - If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "XML\") Then System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "XML\") - If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "XML\" & Ventas.TipoDocto) Then System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "XML\" & Ventas.TipoDocto) - - 'GENERAR TIMBRE - CFDi.Generar(ArchivoPFX, - UsuarioActual.Empresa.ContraseñaKey, - ArchivoCertificado, - $"{RutaArchivo }{NombreArchivoXML}.xml", - UsuarioActual.Empresa.Ruta & "Certificados\", - UsuarioServicio, - ClaveServicio, - UrlServicio, - True) - - - If CFDi.MsgError <> String.Empty Then - OnError($"Ocurrió un error al generar el timbre, el mensaje del SAT fue: {CFDi.MsgError}. Emp:{UsuarioActual.CveEmpresa}. MetPag: {Ventas.ClaveMetodoPagoSAT}", New Exception(CFDi.MsgError)) - Retorno = $"Ocurrió un error al generar el timbre, el mensaje del SAT fue: {CFDi.MsgError}. Emp:{UsuarioActual.CveEmpresa}. MetPag: {Ventas.ClaveMetodoPagoSAT}" - Else - Dim CBB As New ClbNegBICFDv3_3.ClsNegCBBGenerar() - Dim FechaCertificacion As DateTime - Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String - - FolioFiscal = CFDi.Timbrado.UUDI 'XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText - NoSerieCertificado = CFDi.Timbrado.NoCertificadoSAT - FechaCertificacion = CFDi.Timbrado.FechaTimbrado - SelloCFDi = CFDi.Timbrado.SelloCFD - SelloSAT = CFDi.Timbrado.SelloSAT - NoSerieCertificadoContribuyente = CFDi.Timbrado.NoCertificado - - - Dim ObjVentas As New ClsVentas() - If Not ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=1) Then - Retorno = "No se pudo registrar el folio fiscal" - End If - ObjVentas.Dispose() - - - ''Actualiza Cliente (NumeroCuenta) - 'If Not UsuarioActual.CveEmpresa.Contiene(72, 80) Then - ' Dim Hilo2 As New System.Threading.Thread(Sub() ActualizaCliente(UsuarioActual.CveUsuario, Ventas.Cliente.NumCtaPago, Ventas.CveMetodoPago, Ventas.CveCliente)) - ' Hilo2.Start() - 'End If - - - Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Ventas.Cliente.RFC, Ventas.TotalTC, FolioFiscal, RutaCBB) - - ''Genero la addenda de 7-Eleven - 'If sevenElevenNumProveedor <> "" AndAlso sevenElevenFolio <> "" AndAlso sevenElevenTienda <> "" AndAlso sevenElevenFecha <> "" AndAlso sevenElevenFecha <> "__/__/____" Then - ' Dim RutaCadena As String = $"{Ruta}XML\{Ventas.TipoDocto}\{Ventas.SerieFolio}.xml" '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)) - - ' GeneraAddenda7Eleven(RutaCadena, TmpDTConceptos, TmpDT7Eleven) - 'End If - - '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 - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Complemento Detallista" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Complemento Detallista", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AddendaFemsa" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AddendaFemsa", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AddendaFemsa" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AdendaFEMSA", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: RetencionesLocales" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: RetencionesLocales", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosTrasladoCfd" - Me.OnError("El SAT regresó el siguieente mensaje: " & Msg & ". Objeto: ImpuestosTrasladoCfd", New Exception) - End If - - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosRetencionesCfd " - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosRetencionesCfd ", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosCfd" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosCfd", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ConceptosCfd" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ConceptosCfd", New Exception) - End If - - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ReceptorCfd" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ReceptorCfd", New Exception) - End If - - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: EmisorCfd" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: EmisorCfd", New Exception) - End If - Else - Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Comprobante" - Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Comprobante", New Exception) - End If - MensajeErrorCFDI = Retorno - Return Retorno - End Function - Public Function TimbrarFacturaRealVirtualv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String - 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(UsuarioActual.Empresa.CvePAC = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") - Dim ClaveServicio As String = If(UsuarioActual.Empresa.CvePAC = 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 UsuarioActual.Empresa.CvePAC - Case 2 - UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" - Case 4 - UrlServicio = "http://192.168.0.2:8080/ADSistemas/Timbrado.asmx?WSDL" - 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 UsuarioActual.Empresa.CvePAC - 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://192.168.0.2:8080/ADSistemas/Timbrado.asmx?WSDLL" - End Select - End If - -#Region "Valida" - If Not File.Exists(ArchivoCertificado) Then - Alert("El archivo de certificado no existe", TipoMensaje.MsgError) - Return "" - End If - If Not File.Exists(ArchivoLLave) Then - Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) - Return "" - End If - If UsuarioActual.Empresa.ContraseñaKey = "" Then - Alert("La clave no puede ser vacía", TipoMensaje.MsgError) - Return "" - End If -#End Region - -#Region "Variables" - Dim llaveByte As Byte(), certByte As Byte() - Dim llaveBase64 As String, certBase64 As String - Dim cfdi As New RVCFDI33.GeneraCFDI() - 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 "" - 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 "" - - 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.agregarCertificado(ArchivoCertificado) -#End Region - - -#Region "Comprobante" - - cfdi.agregarComprobante33( - 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.agregarCfdiRelacionados(ObjCFDITimbre.CFDIRelacionados.TipoRelacion) - For Each uid As String In ObjCFDITimbre.CFDIRelacionados.UUID - cfdi.agregarCfdiRelacionado(uid) - Next - End If -#Region "Emisor" - ' cfdi.agregarCfdiRelacionados() - cfdi.agregarEmisor(EmisorRFC, UsuarioActual.Empresa.Empresa, UsuarioActual.Empresa.CodigoRegimenFiscal) - -#End Region - -#Region "Receptor" - - cfdi.agregarReceptor(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.agregarConcepto(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.agregarImpuestoConceptoTraslado(imp.Base, imp.Impuesto, imp.TipoFactor, imp.TasaOCuota, imp.Importe) - Else - cfdi.agregarImpuestoConceptoRetenido(imp.Base, imp.Impuesto, imp.TipoFactor, imp.TasaOCuota, imp.Importe) - End If - Next - If concep.CuentaPredial <> "" Then cfdi.agregarCuentaPredial(concep.CuentaPredial) - Next - End If - -#End Region - - If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then - -#Region "Impuestos" - - cfdi.agregarImpuestos(ObjCFDITimbre.TotalImpuestosRetenidos, ObjCFDITimbre.TotalImpuestosTrasladados) - -#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.agregarRetencion(Ret.Impuesto, Ret.Importe) - Next - End If - - ''se acumulan los importes - For Each Tras In ObjCFDITimbre.Traslados - cfdi.agregarTraslado(Tras.Impuesto, Tras.TipoFactor, Tras.TasaOCuota, Tras.Importe) - Next -#End Region - -#Region "Impuestos Locales" - - If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 Then - cfdi.agregarImpuestosLocales("1.0", ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe), 0) - For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales - If ret.Importe > 0 Then - cfdi.agregarRetencionesLocales(ret.ImpuestoLocalRetenido, ret.TasaRetencion, ret.Importe) - End If - Next - End If - - If Ventas.CveComplementoTimbrado > 0 Then - - Select Case Ventas.CveComplementoTimbrado - Case 5 'INE Proceso Ordinario Directivo Estatal" - cfdi.agregarIne11("Ordinario", "Directivo Estatal", "0") - - cfdi.agregarEntidad(Ventas.ComplementoINE.INEEntidad, "") - cfdi.agregarIneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) - Case 6 'INE Proceso Ordinario Ejecutivo Estatal" - cfdi.agregarIne11("Ordinario", "Ejecutivo Estatal", "0") - - cfdi.agregarEntidad(Ventas.ComplementoINE.INEEntidad, "") - cfdi.agregarIneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) - Case 7 'INE Proceso Ordinario Ejecutivo Nacional" - - cfdi.agregarIne11("Ordinario", "Ejecutivo Nacional", Ventas.ComplementoINE.INEIdContabilidad.ToString) - Case 8 'INE PreCampaña - cfdi.agregarIne11(Ventas.ComplementoINE.INETipoProceso, "", "0") - - cfdi.agregarEntidad(Ventas.ComplementoINE.INEEntidad, Ventas.ComplementoINE.INETipoComite) - cfdi.agregarIneContabilidad(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.agregarComercioExterior11(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.agregarComercioExterior11Emisor(If(EmisorRFC.Length >= 12, "", ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CURP)) - cfdi.agregarComercioExterior11Domicilio(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.agregarComercioExterior11Receptor(ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib) - cfdi.agregarComercioExterior11DomicilioReceptor(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.agregarComercioExterior11Destinatario(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.agregarComercioExterior11Mercancia(concep.NoIdentificacion, concep.FraccionArancelaria, concep.CantidadAduana, concep.UnidadAduana, concep.ValorUnitarioAduana, concep.ValorDolares) - If concep.DescripcionesEspecificas.Marca <> "" Then - cfdi.agregarComercioExterior11MercanciaDescripcionesEspeciales(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.agregarPago10(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.agregarPago10DoctoRelacionado(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.agregarPago10Impuestos(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.agregarPago10Retencion(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.agregarPago10Traslado(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.agregarNomina12(ObjCFDITimbre.Nomina.Version, ObjCFDITimbre.Nomina.TipoNomina, ObjCFDITimbre.Nomina.FechaPago.ToString, ObjCFDITimbre.Nomina.FechaInicio, ObjCFDITimbre.Nomina.FechaFin, ObjCFDITimbre.Nomina.NumDiasPagados.ToString, If(ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0, ObjCFDITimbre.Nomina.TotalPercepciones.ToString, ""), If(ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0, ObjCFDITimbre.Nomina.TotalDeducciones.ToString, ""), If(ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0, ObjCFDITimbre.Nomina.TotalOtrosPagos.ToString, "")) - - cfdi.agregarNominaEmisor12(ObjCFDITimbre.Emisor.CURP, If(ObjCFDITimbre.Nomina.Receptor.TipoContrato = "99", "", ObjCFDITimbre.Emisor.RegistroPatronal), ObjCFDITimbre.Emisor.RFC) - - If UsuarioActual.Empresa.UsaAC Then cfdi.agregarNominaEmisorEntidadSNCF12("IF", "90") - - If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then - Dim TotalIndemnizacion As String = If(ObjCFDITimbre.Nomina.TotalIndemnizacion > 0, ObjCFDITimbre.Nomina.TotalIndemnizacion.ToString, "") - Dim TotalJubilacion As String = If(ObjCFDITimbre.Nomina.TotalJubilacion > 0, ObjCFDITimbre.Nomina.TotalJubilacion.ToString, "") - cfdi.agregarNominaPercepciones12(ObjCFDITimbre.Nomina.TotalSueldos.ToString, TotalIndemnizacion, TotalJubilacion, ObjCFDITimbre.Nomina.TotalPercepcionesGravado.ToString, ObjCFDITimbre.Nomina.TotalPercepcionesExento.ToString) - For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones - cfdi.agregarNominaPercepcionesPercepcion12(percep.TipoPercepcion, percep.Clave, percep.Concepto, Math.Round(percep.ImporteGravado, 2).ToString, Math.Round(percep.ImporteExento, 2).ToString) - Next - End If - 'cfdi.agregarNominaReceptorSubContratacion12("AAD990814BP6", "50") - 'cfdi.agregarNominaPercepcionesPercepcionAccionesOTitulos12("100", "200"); - 'cfdi.agregarNominaPercepcionesSeparacionIndemnizacion12("100", "10", "1000", "100", "50"); - 'cfdi.agregarNominaPercepcionesJubilacionPensionRetiro12("50", "100", "10", "100", "0"); - - If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then - For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras - cfdi.agregarNominaPercepcionesPercepcionHorasExtra12(HoraExtra.Dias, HoraExtra.TipoHoras, HoraExtra.HorasExtra.ToString, HoraExtra.ImportePagado.ToString) - 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.agregarNominaIncapacidadesIncapacidad12(Incap.DiasIncapacidad, Incap.TipoIncapacidad, Incap.Importe.ToString) - Next - End If - - If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then - cfdi.agregarNominaDeducciones12(If(Not ObjCFDITimbre.Nomina.TotalDeduccionesOtras.ToString.ToDecimal > 0, "", ObjCFDITimbre.Nomina.TotalDeduccionesOtras.ToString), If(Not ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos.ToString.ToDecimal > 0, "", Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2).ToString)) - For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones - cfdi.agregarNominaDeduccionesDeduccion12(deduc.TipoDeduccion, deduc.Clave, deduc.Concepto, Math.Round(deduc.Importe, 2).ToString) - 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.agregarNominaOtrosPagosOtroPago12(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe.ToString) - If otpag.TipoOtroPago = "002" Then - cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12(otpag.Importe.ToString) - End If - - Next - End If - End If - - -#Region "Receptor" - - cfdi.agregarNominaReceptor12(ObjCFDITimbre.Nomina.Receptor.CURP, - ObjCFDITimbre.Nomina.Receptor.NSS, - ObjCFDITimbre.Nomina.Receptor.FechaInicioContrato, - 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.ToString, - ObjCFDITimbre.Nomina.Receptor.SDI.ToString, - ObjCFDITimbre.Nomina.Receptor.CodigoEntidadFederativa) - - - End If -#End Region - -#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.GenerarXMLBase64(llaveBase64, Clave) - cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) - ArchivoGenerado = True - Catch ex As Exception - Retorno = cfdi.MensajeError - MensajeErrorCFDI = cfdi.MensajeError - End Try - -#End Region - sw.Stop() - swTiempo.AppendFormat("Guardado: ({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 FechaCertificacion As DateTime - 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 - - File.WriteAllText(String.Format("{0}{1}.xml", RutaArchivo, NombreArchivoXML), cfdi.XmlTimbrado, System.Text.UTF8Encoding.UTF8) - - - If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then - - 'Actualiza Estatus Factura - If Ventas.CveVenta > 0 Then - - Dim ObjVentas As New ClsVentas() - If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=UsuarioActual.Empresa.CvePAC) Then - Retorno = "" - Else - Retorno = "Error" - End If - ObjVentas.Dispose() - - - ''Actualiza Cliente (NumeroCuenta) - 'If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then - ' Dim Hilo2 As New System.Threading.Thread(Sub() ActualizaCliente(UsuarioActual.CveUsuario, Ventas.Cliente.NumCtaPago, Ventas.CveMetodoPago, Ventas.CveCliente)) - ' Hilo2.Start() - 'End If - - '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, UsuarioActual.Empresa.CvePAC, 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\") - - Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" - Dim b As Byte() = cfdi.ConvertirQrCode($"?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={FolioFiscal}") - File.WriteAllBytes(RutaCBB, b) - - 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 - End If - End If - - GuardaLogTimbrado(swTiempo.ToString, UsuarioActual.Empresa.CvePAC) -#End Region - 'GC.Collect() - Return Retorno - End Function - Public Function TimbrarFacturaGoCFDIv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String - 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(UsuarioActual.Empresa.CvePAC = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") - Dim ClaveServicio As String = If(UsuarioActual.Empresa.CvePAC = 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 UsuarioActual.Empresa.CvePAC - Case 2 - UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" - Case 4 - UrlServicio = "http://juancalderon-001-site1.ftempurl.com/timbrado.asmx?WSDL" - 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 UsuarioActual.Empresa.CvePAC - 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) - Next - End If - -#End Region - - If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then - -#Region "Impuestos" - - cfdi.Impuestos(ObjCFDITimbre.TotalImpuestosRetenidos, ObjCFDITimbre.TotalImpuestosTrasladados) - -#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.Importe) - 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) - - 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:=UsuarioActual.Empresa.CvePAC) 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, UsuarioActual.Empresa.CvePAC, 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, UsuarioActual.Empresa.CvePAC) - Return Retorno - End Function - Public Sub GuardaLogTimbrado(Str As String, CvePAC As Integer) - Dim ArchivoW As StreamWriter - Dim strLineaTMP As String - - ' strLineaTMP = Chr(13) & Chr(10) & Day(Now) & "/" & Month(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minuto & ". " & Str & Chr(13) & Chr(10) - strLineaTMP = String.Format("{0}{1} .. PAC: {2} - {3} ..{4}:{5}", Chr(13), Chr(10), CvePAC, Str, DateTime.Now.ToShortDateString, DateTime.Now.ToShortTimeString) - Try - ArchivoW = New StreamWriter(String.Format("{0}\LogTimbrado.txt", AppDomain.CurrentDomain.BaseDirectory), True, System.Text.Encoding.UTF8) - Catch ex As UnauthorizedAccessException - 'Alert("No hay permisos para guardar en el Log.", Extensiones.TipoMensaje.MsgError) - Exit Sub - Catch ex As Exception - Exit Sub - End Try - - Try - ArchivoW.WriteLine(strLineaTMP) - Catch - End Try - - ArchivoW.Close() - ArchivoW.Dispose() - End Sub - Public Function TimbrarFacturaProFactv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String - Dim sw As New Diagnostics.Stopwatch - Dim swTiempo As New StringBuilder - Dim swmili As Long = 0 - sw.Start() - - Dim Retorno As String = "" - Dim ObjCFDITimbre As CFDITimbre = Ventas.Timbre - ' 'Sucursal matriz de la empresa - Dim ArchivoLLave As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoKey}" - Dim ArchivoCertificado As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoCer}" - Dim UsuarioServicio As String = UsuarioActual.Empresa.RFC - Dim ClaveServicio As String = UsuarioActual.Empresa.RFC.ToLower - Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey - Dim EmisorRFC As String = UsuarioActual.Empresa.RFC - Dim UrlServicio As String = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" ' Produccion - Dim RutaArchivo As String = $"{UsuarioActual.Empresa.Ruta}XML\{Ventas.TipoDocto}\" - Dim NombreArchivoXML As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}" - Dim SubTotal As Decimal = 0 - Dim AmbienteProductivo As Boolean = True - If Not Directory.Exists(RutaArchivo) Then Directory.CreateDirectory(RutaArchivo) - - If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then - AmbienteProductivo = False - UsuarioServicio = "fgomez" - ClaveServicio = "12121212" - Clave = "12345678a" - EmisorRFC = "AAA010101AAA" - ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" - UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" '"http://108.60.211.43/rvltimbrado/service1.asmx" - End If - - -#Region "Valida" - If Not File.Exists(ArchivoCertificado) Then - Alert("El archivo de certificado no existe", TipoMensaje.MsgError) - Return "" - End If - If Not File.Exists(ArchivoLLave) Then - Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) - Return "" - End If - If UsuarioActual.Empresa.ContraseñaKey = "" Then - Alert("La clave no puede ser vacía", TipoMensaje.MsgError) - Return "" - End If -#End Region - -#Region "Variables" - Dim llaveByte As Byte(), certByte As Byte() - Dim llaveBase64 As String, certBase64 As String - - Dim complemento As String = "" - Dim complementoConcepto As String = "" - '//Inicializamos el conector el parámetro indica el ambiente en el que se utilizará - '//Fasle = Ambiente de pruebas - '//True = Ambiente de producción - Dim cfdi As New Profact.TimbraCFDI33.Conector(AmbienteProductivo) - Dim comprobante As New Profact.TimbraCFDI33.Comprobante() - - If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then - cfdi.EstableceCredenciales("mvpNUXmQfK8=") - Else - cfdi.EstableceCredenciales($"vSGxMFWnNRy/nDoowxqrqw==|Sia123654") - End If - -#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 "" - 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 "" - - End Try - sw.Stop() - swTiempo.AppendFormat("Verificado : ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) - swmili = sw.ElapsedMilliseconds - sw.Start() -#End Region - - -#Region "Comprobante" - - - If ObjCFDITimbre.Comprobante.Serie <> "" Then comprobante.Serie = ObjCFDITimbre.Comprobante.Serie - comprobante.Folio = ObjCFDITimbre.Comprobante.Folio - comprobante.Version = "3.3" - comprobante.Fecha = ObjCFDITimbre.Comprobante.Fecha - comprobante.FormaPago = ObjCFDITimbre.Comprobante.FormadePago - If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then comprobante.CondicionesDePago = ObjCFDITimbre.Comprobante.CondicionesdePago - - comprobante.SubTotal = ObjCFDITimbre.Comprobante.Subtotal - If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then - comprobante.DescuentoSpecified = True - comprobante.Descuento = ObjCFDITimbre.Comprobante.Descuentos - End If - comprobante.Moneda = ObjCFDITimbre.Comprobante.Moneda - comprobante.TipoCambio = ObjCFDITimbre.Comprobante.TipoCambio.ToDecimal - comprobante.TipoCambioSpecified = If(ObjCFDITimbre.Comprobante.Moneda <> "XXX", True, False) - comprobante.Total = ObjCFDITimbre.Comprobante.Total - comprobante.TipoDeComprobante = ObjCFDITimbre.Comprobante.TipoComprobante - comprobante.FormaPagoSpecified = If(ObjCFDITimbre.Comprobante.FormadePago <> "", True, False) - comprobante.MetodoPago = ObjCFDITimbre.Comprobante.MetodoPago - comprobante.MetodoPagoSpecified = If(ObjCFDITimbre.Comprobante.MetodoPago <> "", True, False) - comprobante.LugarExpedicion = ObjCFDITimbre.Comprobante.LugarExpedicion - -#Region "Emisor" - comprobante.Emisor = New Profact.TimbraCFDI33.ComprobanteEmisor() - comprobante.Emisor.Rfc = EmisorRFC - comprobante.Emisor.Nombre = UsuarioActual.Empresa.Empresa - comprobante.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal - -#End Region - -#Region "Receptor" - comprobante.Receptor = New Profact.TimbraCFDI33.ComprobanteReceptor() - comprobante.Receptor.Rfc = ObjCFDITimbre.Receptor.RFC - comprobante.Receptor.Nombre = ObjCFDITimbre.Receptor.Nombre - comprobante.Receptor.UsoCFDI = ObjCFDITimbre.Receptor.UsoCFDI - -#End Region - -#End Region - -#Region "Conceptos" - - 'Nodo conceptos, se agregan los PS - comprobante.Conceptos = New Profact.TimbraCFDI33.ComprobanteConcepto(ObjCFDITimbre.Conceptos.Count - 1) {} - - If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then - Dim i As Integer = 0 - Dim j As Integer = 0 - Dim k As Integer = 0 - For Each concep As CFDIConceptos In ObjCFDITimbre.Conceptos - comprobante.Conceptos(i) = New Profact.TimbraCFDI33.ComprobanteConcepto() - comprobante.Conceptos(i).Cantidad = concep.Cantidad - - If concep.Unidad <> "" Then comprobante.Conceptos(i).Unidad = concep.Unidad - comprobante.Conceptos(i).ClaveUnidad = concep.ClaveUnidad - comprobante.Conceptos(i).Descripcion = concep.Descripcion - comprobante.Conceptos(i).ValorUnitario = concep.ValorUnitario - comprobante.Conceptos(i).Importe = concep.Importe - comprobante.Conceptos(i).ClaveProdServ = concep.ClaveProdServ - - If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then - comprobante.Conceptos(i).Descuento = concep.Descuento - comprobante.Conceptos(i).DescuentoSpecified = True - End If - - If concep.Noidentificacion <> "" Then comprobante.Conceptos(i).NoIdentificacion = concep.Noidentificacion - - j = 0 - k = 0 - If Not ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("P", "N") Then - comprobante.Conceptos(i).Impuestos = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestos() - comprobante.Conceptos(i).Impuestos.Traslados = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosTraslado(concep.Impuestos.FindAll(Function(p As CFDIConceptosImpuestos) p.TrasladooRetencion = "T").Count - 1) {} - If concep.Impuestos.FindAll(Function(p As CFDIConceptosImpuestos) p.TrasladooRetencion <> "T").Count > 0 Then - comprobante.Conceptos(i).Impuestos.Retenciones = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosRetencion(concep.Impuestos.FindAll(Function(p As CFDIConceptosImpuestos) p.TrasladooRetencion <> "T").Count - 1) {} - - End If - For Each imp As CFDIConceptosImpuestos In concep.Impuestos - If imp.TrasladooRetencion = "T" Then - comprobante.Conceptos(i).Impuestos.Traslados(j) = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosTraslado() - comprobante.Conceptos(i).Impuestos.Traslados(j).Base = imp.Base - comprobante.Conceptos(i).Impuestos.Traslados(j).Impuesto = imp.Impuesto - comprobante.Conceptos(i).Impuestos.Traslados(j).TipoFactor = imp.TipoFactor - comprobante.Conceptos(i).Impuestos.Traslados(j).Importe = imp.Importe - comprobante.Conceptos(i).Impuestos.Traslados(j).ImporteSpecified = True - comprobante.Conceptos(i).Impuestos.Traslados(j).TasaOCuota = imp.TasaOCuota.FormatoNumero(6) - comprobante.Conceptos(i).Impuestos.Traslados(j).TasaOCuotaSpecified = True - j += 1 - Else - comprobante.Conceptos(i).Impuestos.Retenciones(k) = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosRetencion() - comprobante.Conceptos(i).Impuestos.Retenciones(k).Base = imp.Base - comprobante.Conceptos(i).Impuestos.Retenciones(k).Impuesto = imp.Impuesto - comprobante.Conceptos(i).Impuestos.Retenciones(k).TipoFactor = imp.TipoFactor - comprobante.Conceptos(i).Impuestos.Retenciones(k).Importe = imp.Importe - comprobante.Conceptos(i).Impuestos.Retenciones(k).TasaOCuota = imp.TasaOCuota.ToString.ToDecimal - k += 1 - End If - Next - End If - i += 1 - Next - End If - -#End Region - - - Dim LXmlComplementos As New List(Of XmlElement)() - Dim TieneComplemento As Boolean = False - - If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then - -#Region "Impuestos" - - - comprobante.Impuestos = New Profact.TimbraCFDI33.ComprobanteImpuestos() - comprobante.Impuestos.Traslados = New Profact.TimbraCFDI33.ComprobanteImpuestosTraslado(ObjCFDITimbre.Traslados.Count - 1) {} - - Dim y As Integer = 0 - - For Each Tras In ObjCFDITimbre.Traslados - comprobante.Impuestos.Traslados(y) = New Profact.TimbraCFDI33.ComprobanteImpuestosTraslado() - comprobante.Impuestos.Traslados(y).Impuesto = Tras.Impuesto - comprobante.Impuestos.Traslados(y).TipoFactor = Tras.TipoFactor - comprobante.Impuestos.Traslados(y).TasaOCuota = Tras.TasaOCuota.FormatoNumero(6) - comprobante.Impuestos.Traslados(y).Importe = Tras.Importe - y += 1 - Next - - comprobante.Impuestos.TotalImpuestosTrasladados = ObjCFDITimbre.TotalImpuestosTrasladados - comprobante.Impuestos.TotalImpuestosTrasladadosSpecified = True - - If ObjCFDITimbre.TotalImpuestosRetenidos > 0 Then - comprobante.Impuestos.Retenciones = New Profact.TimbraCFDI33.ComprobanteImpuestosRetencion(ObjCFDITimbre.Retenciones.Count - 1) {} - - Dim w As Integer = 0 - - For Each Ret In ObjCFDITimbre.Retenciones - comprobante.Impuestos.Retenciones(w) = New Profact.TimbraCFDI33.ComprobanteImpuestosRetencion() - comprobante.Impuestos.Retenciones(w).Impuesto = Ret.Impuesto - comprobante.Impuestos.Retenciones(w).Importe = Ret.Importe.ToDecimal - w += 1 - Next - - comprobante.Impuestos.TotalImpuestosRetenidos = ObjCFDITimbre.TotalImpuestosRetenidos - comprobante.Impuestos.TotalImpuestosRetenidosSpecified = True - End If - - - -#End Region - - -#Region "Impuestos Locales" - - - If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 Then - Dim Imp = New Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocales() - Imp.version = "1.0" - Imp.TotaldeRetenciones = ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe).FormatoNumero().ToDecimal - Imp.TotaldeTraslados = 0 - Imp.RetencionesLocales = New Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocalesRetencionesLocales(ObjCFDITimbre.RetencionesLocales.Count - 1) {} - Dim i As Integer = 0 - For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales - If ret.Importe > 0 Then - Imp.RetencionesLocales(i) = New Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocalesRetencionesLocales() - Imp.RetencionesLocales(i).ImpLocRetenido = ret.ImpuestoLocalRetenido - Imp.RetencionesLocales(i).TasadeRetencion = ret.TasaRetencion.FormatoNumero().ToDecimal - Imp.RetencionesLocales(i).Importe = ret.Importe.FormatoNumero().ToDecimal - i += 1 - End If - Next - - Dim nsImpLocal As New System.Xml.Serialization.XmlSerializerNamespaces() - nsImpLocal.Add("implocal", "http://www.sat.gob.mx/implocal") - Dim xmlImpLocal As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(Imp, GetType(Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocales), nsImpLocal) - Dim docImpLocal As New XmlDocument() - docImpLocal.LoadXml(xmlImpLocal) - LXmlComplementos.Add(docImpLocal.DocumentElement) - comprobante.ImpLocalSpecified = True - TieneComplemento = True - 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 - Dim ComExt = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExterior() - ComExt.Version = "1.1" - ComExt.MotivoTrasladoSpecified = True - ComExt.MotivoTraslado = ObjCFDITimbre.Complementos.ComercioExterior11.MotivoTraslado - ComExt.TipoOperacion = ObjCFDITimbre.Complementos.ComercioExterior11.TipoOperacion - ComExt.ClaveDePedimentoSpecified = True - ComExt.ClaveDePedimento = ObjCFDITimbre.Complementos.ComercioExterior11.ClavedePedimento - ComExt.CertificadoOrigenSpecified = True - ComExt.CertificadoOrigen = ObjCFDITimbre.Complementos.ComercioExterior11.CertificadoOrigen.ToEntero - If ObjCFDITimbre.Complementos.ComercioExterior11.NumCertificadoOrigen <> "" Then - ComExt.NumCertificadoOrigen = ObjCFDITimbre.Complementos.ComercioExterior11.NumCertificadoOrigen - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.NumeroExportadorConfiable <> "" Then - ComExt.NumeroExportadorConfiable = ObjCFDITimbre.Complementos.ComercioExterior11.NumeroExportadorConfiable - End If - ComExt.IncotermSpecified = True - ComExt.Incoterm = ObjCFDITimbre.Complementos.ComercioExterior11.Incoterm - ComExt.SubdivisionSpecified = True - ComExt.Subdivision = ObjCFDITimbre.Complementos.ComercioExterior11.Subdivision.ToEntero - If ObjCFDITimbre.Complementos.ComercioExterior11.Observaciones <> "" Then - ComExt.Observaciones = ObjCFDITimbre.Complementos.ComercioExterior11.Observaciones - End If - ComExt.TipoCambioUSDSpecified = True - ComExt.TipoCambioUSD = ObjCFDITimbre.Complementos.ComercioExterior11.TipoCambioUSD - ComExt.TotalUSDSpecified = True - ComExt.TotalUSD = ObjCFDITimbre.Complementos.ComercioExterior11.TotalUSD - - 'EMISOR - ComExt.Emisor = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorEmisor() - If EmisorRFC.Length < 12 Then - ComExt.Emisor.Curp = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CURP - End If - ComExt.Emisor.Domicilio = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorEmisorDomicilio - ComExt.Emisor.Domicilio.Calle = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Calle - ComExt.Emisor.Domicilio.CodigoPostal = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CP - ComExt.Emisor.Domicilio.ColoniaSpecified = True - ComExt.Emisor.Domicilio.Colonia = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Colonia - ComExt.Emisor.Domicilio.Estado = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Estado - If ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Localidad <> "" Then - ComExt.Emisor.Domicilio.LocalidadSpecified = False - ComExt.Emisor.Domicilio.Localidad = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Localidad - End If - ComExt.Emisor.Domicilio.MunicipioSpecified = True - ComExt.Emisor.Domicilio.Municipio = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Municipio - ComExt.Emisor.Domicilio.NumeroExterior = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.NumeroExterior - ComExt.Emisor.Domicilio.NumeroInterior = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.NumeroInterior - ComExt.Emisor.Domicilio.Pais = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Pais - If ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Referencia <> "" Then - ComExt.Emisor.Domicilio.Referencia = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Referencia - End If - - 'RECEPTOR - ComExt.Receptor = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorReceptor - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib <> "" Then - ComExt.Receptor.NumRegIdTrib = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib - End If - ComExt.Receptor.Domicilio = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorReceptorDomicilio - ComExt.Receptor.Domicilio.Calle = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Calle - ComExt.Receptor.Domicilio.CodigoPostal = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.CP - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Colonia <> "" Then - ComExt.Receptor.Domicilio.Colonia = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Colonia - End If - ComExt.Receptor.Domicilio.Estado = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Estado - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Localidad <> "" Then - ComExt.Receptor.Domicilio.Localidad = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Localidad - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Municipio <> "" Then - ComExt.Receptor.Domicilio.Municipio = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Municipio - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroExterior <> "" Then - ComExt.Receptor.Domicilio.NumeroExterior = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroExterior - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroInterior <> "" Then - ComExt.Receptor.Domicilio.NumeroInterior = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroInterior - End If - ComExt.Receptor.Domicilio.Pais = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Pais - If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Referencia <> "" Then - ComExt.Receptor.Domicilio.Referencia = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Referencia - End If - - 'DESTINATARIO - ComExt.Destinatario = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatario(0) {} - ComExt.Destinatario(0) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatario() - ComExt.Destinatario(0).Nombre = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Nombre - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib <> "" Then - ComExt.Destinatario(0).NumRegIdTrib = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib - End If - ComExt.Destinatario(0).Domicilio = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatarioDomicilio(0) {} - ComExt.Destinatario(0).Domicilio(0) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatarioDomicilio() - ComExt.Destinatario(0).Domicilio(0).Calle = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Calle - ComExt.Destinatario(0).Domicilio(0).CodigoPostal = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.CP - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Colonia <> "" Then - ComExt.Destinatario(0).Domicilio(0).Colonia = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Colonia - End If - ComExt.Destinatario(0).Domicilio(0).Estado = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Estado - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Localidad <> "" Then - ComExt.Destinatario(0).Domicilio(0).Localidad = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Localidad - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Municipio <> "" Then - ComExt.Destinatario(0).Domicilio(0).Municipio = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Municipio - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior <> "" Then - ComExt.Destinatario(0).Domicilio(0).NumeroExterior = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior - End If - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior <> "" Then - ComExt.Destinatario(0).Domicilio(0).NumeroInterior = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior - End If - ComExt.Destinatario(0).Domicilio(0).Pais = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Pais - If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Referencia <> "" Then - ComExt.Destinatario(0).Domicilio(0).Referencia = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Referencia - End If - - 'MERCANCIAS - If ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias IsNot Nothing AndAlso ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias.Count > 0 Then - ComExt.Mercancias = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercancia(ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias.Count - 1) {} - Dim i As Integer - For Each concep As CFDIComercioExterior11Mercancias In ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias - ComExt.Mercancias(i) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercancia() - ComExt.Mercancias(i).NoIdentificacion = concep.NoIdentificacion - ComExt.Mercancias(i).FraccionArancelariaSpecified = True - ComExt.Mercancias(i).FraccionArancelaria = concep.FraccionArancelaria - ComExt.Mercancias(i).CantidadAduanaSpecified = True - ComExt.Mercancias(i).CantidadAduana = concep.CantidadAduana - ComExt.Mercancias(i).UnidadAduanaSpecified = True - ComExt.Mercancias(i).UnidadAduana = concep.UnidadAduana - ComExt.Mercancias(i).ValorUnitarioAduanaSpecified = True - ComExt.Mercancias(i).ValorUnitarioAduana = concep.ValorUnitarioAduana - ComExt.Mercancias(i).ValorDolares = concep.ValorDolares - If concep.DescripcionesEspecificas.Marca <> "" Then - ComExt.Mercancias(i).DescripcionesEspecificas = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercanciaDescripcionesEspecificas(0) {} - ComExt.Mercancias(i).DescripcionesEspecificas(0) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercanciaDescripcionesEspecificas() - If concep.DescripcionesEspecificas.Marca <> "" Then - ComExt.Mercancias(i).DescripcionesEspecificas(0).Marca = concep.DescripcionesEspecificas.Marca - End If - If concep.DescripcionesEspecificas.Modelo <> "" Then - ComExt.Mercancias(i).DescripcionesEspecificas(0).Modelo = concep.DescripcionesEspecificas.Modelo - End If - If concep.DescripcionesEspecificas.SubModelo <> "" Then - ComExt.Mercancias(i).DescripcionesEspecificas(0).SubModelo = concep.DescripcionesEspecificas.SubModelo - End If - If concep.DescripcionesEspecificas.NumeroSerie <> "" Then - ComExt.Mercancias(i).DescripcionesEspecificas(0).NumeroSerie = concep.DescripcionesEspecificas.NumeroSerie - End If - End If - i += 1 - Next - End If - Dim nsComer As New System.Xml.Serialization.XmlSerializerNamespaces() - nsComer.Add("cce11", "http://www.sat.gob.mx/ComercioExterior11") - Dim xmlComer As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(ComExt, GetType(Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExterior), nsComer) - Dim docComer As New XmlDocument() - docComer.LoadXml(xmlComer) - LXmlComplementos.Add(docComer.DocumentElement) - comprobante.ComercioExterior11Specified = True - TieneComplemento = True - End If - End If - -#End Region - - - - - - - End If - -#Region "Complemento Pago" - - If ObjCFDITimbre.Comprobante.TipoComprobante = "P" Then - Dim ComPag = New Profact.TimbraCFDI33.Complementos.Pagos10.Pagos() - ComPag.Pago = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPago(0) {} - ComPag.Pago(0) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPago() - ComPag.Pago(0).FechaPago = ObjCFDITimbre.ComplementoPagos.FechaPago.ToString("yyyy-MM-ddTHH:mm:ss").ToDate() - ComPag.Pago(0).FormaDePagoP = ObjCFDITimbre.ComplementoPagos.FormaDePagoP - ComPag.Pago(0).MonedaP = ObjCFDITimbre.ComplementoPagos.MonedaP - ComPag.Pago(0).TipoCadPagoSpecified = If(ObjCFDITimbre.ComplementoPagos.MonedaP = "MXN", False, True) - ComPag.Pago(0).TipoCambioP = ObjCFDITimbre.ComplementoPagos.TipoCambioP.ToDecimal - ComPag.Pago(0).Monto = ObjCFDITimbre.ComplementoPagos.Monto.ToDecimal - If ObjCFDITimbre.ComplementoPagos.NumOperacion <> "" Then - ComPag.Pago(0).NumOperacion = ObjCFDITimbre.ComplementoPagos.NumOperacion - End If - If ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaOrd <> "" Then - ComPag.Pago(0).RfcEmisorCtaOrd = ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaOrd - End If - If ObjCFDITimbre.ComplementoPagos.NomBancoOrdExt <> "" Then - ComPag.Pago(0).NomBancoOrdExt = ObjCFDITimbre.ComplementoPagos.NomBancoOrdExt - End If - If ObjCFDITimbre.ComplementoPagos.CtaOrdenante <> "" Then - ComPag.Pago(0).CtaOrdenante = ObjCFDITimbre.ComplementoPagos.CtaOrdenante - End If - If ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaBen <> "" Then - ComPag.Pago(0).RfcEmisorCtaBen = ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaBen - End If - If ObjCFDITimbre.ComplementoPagos.CtaBeneficiario <> "" Then - ComPag.Pago(0).CtaBeneficiario = ObjCFDITimbre.ComplementoPagos.CtaBeneficiario - End If - ComPag.Pago(0).TipoCadPago = ObjCFDITimbre.ComplementoPagos.TipoCadPago - If ObjCFDITimbre.ComplementoPagos.CertPago <> "" Then - ComPag.Pago(0).CertPago = System.Text.Encoding.Default.GetBytes(ObjCFDITimbre.ComplementoPagos.CertPago).ToString - End If - If ObjCFDITimbre.ComplementoPagos.CadPago <> "" Then - ComPag.Pago(0).CadPago = ObjCFDITimbre.ComplementoPagos.CadPago - End If - If ObjCFDITimbre.ComplementoPagos.SelloPago <> "" Then - ComPag.Pago(0).SelloPago = System.Text.Encoding.Default.GetBytes(ObjCFDITimbre.ComplementoPagos.SelloPago).ToString - End If - - If ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados.Count > 0 Then - ComPag.Pago(0).DoctoRelacionado = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoDoctoRelacionado(ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados.Count - 1) {} - Dim i As Integer - For Each doc As CFDIComplementoPagosDocsRelacionados In ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados - ComPag.Pago(0).DoctoRelacionado(i) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoDoctoRelacionado() - ComPag.Pago(0).DoctoRelacionado(i).IdDocumento = doc.IdDocumento - If Not String.IsNullOrEmpty(doc.Serie) Then - ComPag.Pago(0).DoctoRelacionado(i).Serie = doc.Serie - End If - ComPag.Pago(0).DoctoRelacionado(i).Folio = doc.Folio - ComPag.Pago(0).DoctoRelacionado(i).MonedaDR = doc.MonedaDR - ComPag.Pago(0).DoctoRelacionado(i).TipoCambioDRSpecified = If(doc.TipoCambioDR.ToDecimal = 0, False, True) - ComPag.Pago(0).DoctoRelacionado(i).TipoCambioDR = doc.TipoCambioDR.ToDecimal - ComPag.Pago(0).DoctoRelacionado(i).MetodoDePagoDR = doc.MetodoDePagoDR - ComPag.Pago(0).DoctoRelacionado(i).NumParcialidad = doc.NumParcialidad.ToString - - ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoAntSpecified = True - ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoAnt = doc.ImpSaldoAnt.ToDecimal - - ComPag.Pago(0).DoctoRelacionado(i).ImpPagadoSpecified = True - ComPag.Pago(0).DoctoRelacionado(i).ImpPagado = doc.ImpPagado.ToDecimal - - ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoInsolutoSpecified = True - ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoInsoluto = doc.ImpSaldoInsoluto.ToDecimal - i += 1 - Next - - 'Estos impuestos aplicarían para anticipos - If ObjCFDITimbre.ComplementoPagos.TotalImpuestosRetenidos > 0 OrElse ObjCFDITimbre.ComplementoPagos.TotalImpuestosTrasladados > 0 Then - ComPag.Pago(0).Impuestos = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestos(0) {} - ComPag.Pago(0).Impuestos(0) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestos() - ComPag.Pago(0).Impuestos(0).TotalImpuestosRetenidosSpecified = True - ComPag.Pago(0).Impuestos(0).TotalImpuestosRetenidos = ObjCFDITimbre.ComplementoPagos.TotalImpuestosRetenidos.ToDecimal - ComPag.Pago(0).Impuestos(0).TotalImpuestosTrasladadosSpecified = True - ComPag.Pago(0).Impuestos(0).TotalImpuestosTrasladados = ObjCFDITimbre.ComplementoPagos.TotalImpuestosTrasladados.ToDecimal - - If (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "R").Count > 0 Then - Dim x As Integer - ComPag.Pago(0).Impuestos(0).Retenciones = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosRetencion((ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "R").Count - 1) {} - For Each Ret As CFDIConceptosImpuestos In (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "R") - ComPag.Pago(0).Impuestos(0).Retenciones(x) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosRetencion() - ComPag.Pago(0).Impuestos(0).Retenciones(x).Impuesto = Ret.Impuesto - ComPag.Pago(0).Impuestos(0).Retenciones(x).Importe = Ret.Importe - x += 1 - Next - End If - If (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "T").Count > 0 Then - Dim x As Integer - ComPag.Pago(0).Impuestos(0).Traslados = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosTraslado((ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "T").Count - 1) {} - For Each Tra As CFDIConceptosImpuestos In (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "T") - ComPag.Pago(0).Impuestos(0).Traslados(x) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosTraslado() - ComPag.Pago(0).Impuestos(0).Traslados(x).Impuesto = Tra.Impuesto - ComPag.Pago(0).Impuestos(0).Traslados(x).TipoFactor = Tra.TipoFactor - ComPag.Pago(0).Impuestos(0).Traslados(x).TasaOCuota = Tra.TasaOCuota.ToString - ComPag.Pago(0).Impuestos(0).Traslados(x).Importe = Tra.Importe - x += 1 - Next - End If - - End If - - - Dim nsComp As New System.Xml.Serialization.XmlSerializerNamespaces() - nsComp.Add("pago10", "http://www.sat.gob.mx/Pagos") - Dim xmlComp As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(ComPag, GetType(Profact.TimbraCFDI33.Complementos.Pagos10.Pagos), nsComp) - Dim docComp As New XmlDocument() - docComp.LoadXml(xmlComp) - comprobante.PagosSpecified = True - LXmlComplementos.Add(docComp.DocumentElement) - TieneComplemento = True - End If - - End If -#End Region - -#Region "Nomina12" - If ObjCFDITimbre.Comprobante.TipoComprobante = "N" Then - Dim Nom = New Profact.TimbraCFDI33.Complementos.Nomina12.Nomina() - 'cfdi.Esquema.AgregarEsquema("http://www.sat.gob.mx/nomina12 http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd") - Nom.Version = ObjCFDITimbre.Nomina.Version - Nom.TipoNomina = ObjCFDITimbre.Nomina.TipoNomina - Nom.FechaPago = ObjCFDITimbre.Nomina.FechaPago - Nom.FechaInicialPago = ObjCFDITimbre.Nomina.FechaInicio.ToDate - Nom.FechaFinalPago = ObjCFDITimbre.Nomina.FechaFin.ToDate - Nom.NumDiasPagados = ObjCFDITimbre.Nomina.NumDiasPagados.ToString - Nom.TotalPercepcionesSpecified = True - Nom.TotalPercepciones = ObjCFDITimbre.Nomina.TotalPercepciones.ToDecimal - Nom.TotalDeduccionesSpecified = True - Nom.TotalDeducciones = ObjCFDITimbre.Nomina.TotalDeducciones.ToDecimal - Nom.TotalOtrosPagosSpecified = True - Nom.TotalOtrosPagos = ObjCFDITimbre.Nomina.TotalOtrosPagos.ToDecimal - - Nom.Emisor = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaEmisor - Nom.Emisor.Curp = ObjCFDITimbre.Emisor.CURP - Nom.Emisor.RegistroPatronal = ObjCFDITimbre.Emisor.RegistroPatronal - Nom.Emisor.RfcPatronOrigen = ObjCFDITimbre.Emisor.RFC - - If UsuarioActual.Empresa.UsaAC Then Nom.Emisor.EntidadSNCF.OrigenRecurso = "IF" : Nom.Emisor.EntidadSNCF.MontoRecursoPropio = 90 - - If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then - Dim TotalIndemnizacion As String = If(ObjCFDITimbre.Nomina.TotalIndemnizacion > 0, ObjCFDITimbre.Nomina.TotalIndemnizacion.ToString, "") - Dim TotalJubilacion As String = If(ObjCFDITimbre.Nomina.TotalJubilacion > 0, ObjCFDITimbre.Nomina.TotalJubilacion.ToString, "") - Nom.Percepciones = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepciones - Nom.Percepciones.TotalSueldosSpecified = True - Nom.Percepciones.TotalSueldos = ObjCFDITimbre.Nomina.TotalSueldos.ToDecimal - Nom.Percepciones.TotalSeparacionIndemnizacionSpecified = True - Nom.Percepciones.TotalSeparacionIndemnizacion = TotalIndemnizacion.ToDecimal - Nom.Percepciones.TotalJubilacionPensionRetiroSpecified = True - Nom.Percepciones.TotalJubilacionPensionRetiro = TotalJubilacion.ToDecimal - Nom.Percepciones.TotalGravado = ObjCFDITimbre.Nomina.TotalPercepcionesGravado.ToDecimal - Nom.Percepciones.TotalExento = ObjCFDITimbre.Nomina.TotalPercepcionesExento.ToDecimal - Nom.Percepciones.Percepcion = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcion(ObjCFDITimbre.Nomina.Percepciones.Count - 1) {} - Dim i As Integer = 0 - For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones - Nom.Percepciones.Percepcion(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcion() - Nom.Percepciones.Percepcion(i).TipoPercepcion = percep.TipoPercepcion - Nom.Percepciones.Percepcion(i).Clave = percep.Clave - Nom.Percepciones.Percepcion(i).Concepto = percep.Concepto - Nom.Percepciones.Percepcion(i).ImporteGravado = Math.Round(percep.ImporteGravado, 2).ToString.ToDecimal - Nom.Percepciones.Percepcion(i).ImporteExento = Math.Round(percep.ImporteExento, 2).ToString.ToDecimal - - If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then - Nom.Percepciones.Percepcion(i).HorasExtra = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcionHorasExtra(ObjCFDITimbre.Nomina.HorasExtras.Count - 1) {} - Dim x As Integer = 0 - For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras - Nom.Percepciones.Percepcion(i).HorasExtra(x) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcionHorasExtra() - Nom.Percepciones.Percepcion(i).HorasExtra(x).Dias = HoraExtra.Dias.ToEntero - Nom.Percepciones.Percepcion(i).HorasExtra(x).TipoHoras = HoraExtra.TipoHoras - Nom.Percepciones.Percepcion(i).HorasExtra(x).HorasExtra = HoraExtra.HorasExtra.ToEntero - Nom.Percepciones.Percepcion(i).HorasExtra(x).ImportePagado = HoraExtra.ImportePagado.ToDecimal - x += 1 - Next - End If - - i += 1 - Next - End If - 'cfdi.agregarNominaReceptorSubContratacion12("AAD990814BP6", "50") - 'cfdi.agregarNominaPercepcionesPercepcionAccionesOTitulos12("100", "200"); - 'cfdi.agregarNominaPercepcionesSeparacionIndemnizacion12("100", "10", "1000", "100", "50"); - 'cfdi.agregarNominaPercepcionesJubilacionPensionRetiro12("50", "100", "10", "100", "0"); - - - - If ObjCFDITimbre.Nomina.Incapacidades IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Incapacidades.Count > 0 Then - Nom.Incapacidades = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaIncapacidad(ObjCFDITimbre.Nomina.Incapacidades.Count - 1) {} - Dim i As Integer = 0 - For Each Incap As CFDINominaIncapacidades In ObjCFDITimbre.Nomina.Incapacidades - Nom.Incapacidades(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaIncapacidad() - Nom.Incapacidades(i).DiasIncapacidad = Incap.DiasIncapacidad.ToEntero - Nom.Incapacidades(i).TipoIncapacidad = Incap.TipoIncapacidad - Nom.Incapacidades(i).ImporteMonetarioSpecified = True - Nom.Incapacidades(i).ImporteMonetario = Incap.Importe.ToDecimal - i += 1 - Next - End If - - If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then - Nom.Deducciones = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaDeducciones() - Nom.Deducciones.TotalOtrasDeduccionesSpecified = True - Nom.Deducciones.TotalOtrasDeducciones = Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesOtras, 2) - Nom.Deducciones.TotalImpuestosRetenidosSpecified = True - Nom.Deducciones.TotalImpuestosRetenidos = Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2) - Nom.Deducciones.Deduccion = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaDeduccionesDeduccion(ObjCFDITimbre.Nomina.Deducciones.Count - 1) {} - Dim i As Integer = 0 - For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones - Nom.Deducciones.Deduccion(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaDeduccionesDeduccion() - Nom.Deducciones.Deduccion(i).TipoDeduccion = deduc.TipoDeduccion - Nom.Deducciones.Deduccion(i).Clave = deduc.Clave - Nom.Deducciones.Deduccion(i).Concepto = deduc.Concepto - Nom.Deducciones.Deduccion(i).Importe = Math.Round(deduc.Importe, 2) - i += 1 - 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 - Nom.OtrosPagos = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPago(ObjCFDITimbre.Nomina.OtrosPagos.Count - 1) {} - Dim i As Integer = 0 - For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos - Nom.OtrosPagos(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPago() - Nom.OtrosPagos(i).TipoOtroPago = otpag.TipoOtroPago - Nom.OtrosPagos(i).Clave = otpag.Clave - Nom.OtrosPagos(i).Concepto = otpag.Concepto - Nom.OtrosPagos(i).Importe = otpag.Importe.ToDecimal - If otpag.TipoOtroPago = "002" Then - Nom.OtrosPagos(i).SubsidioAlEmpleo = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPagoSubsidioAlEmpleo() - Nom.OtrosPagos(i).SubsidioAlEmpleo.SubsidioCausado = otpag.Importe.ToDecimal - End If - i += 1 - Next - End If - End If - - -#Region "Receptor" - Nom.Receptor = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaReceptor() - Nom.Receptor.Curp = ObjCFDITimbre.Nomina.Receptor.CURP - Nom.Receptor.NumSeguridadSocial = ObjCFDITimbre.Nomina.Receptor.NSS - Nom.Receptor.FechaInicioRelLaboralSpecified = True - Nom.Receptor.FechaInicioRelLaboral = ObjCFDITimbre.Nomina.Receptor.FechaInicioContrato.ToDate - Nom.Receptor.Antigüedad = ObjCFDITimbre.Nomina.Receptor.Antiguedad - Nom.Receptor.TipoContrato = ObjCFDITimbre.Nomina.Receptor.TipoContrato - 'Nom.Receptor.Sindicalizado = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaReceptorSindicalizado() - 'Nom.Receptor.Sindicalizado = ObjCFDITimbre.Nomina.Receptor.Sindicalizado - Nom.Receptor.TipoJornadaSpecified = True - Nom.Receptor.TipoJornada = ObjCFDITimbre.Nomina.Receptor.CodigoTipoJornada - Nom.Receptor.TipoRegimen = ObjCFDITimbre.Nomina.Receptor.CodigoRegimenContratacion - Nom.Receptor.NumEmpleado = ObjCFDITimbre.Nomina.Receptor.CodigoEmpleado - Nom.Receptor.Departamento = ObjCFDITimbre.Nomina.Receptor.Departamento - Nom.Receptor.Puesto = ObjCFDITimbre.Nomina.Receptor.Puesto - Nom.Receptor.RiesgoPuestoSpecified = True - Nom.Receptor.RiesgoPuesto = ObjCFDITimbre.Nomina.Receptor.CodigoRiesgoPuesto - Nom.Receptor.PeriodicidadPago = ObjCFDITimbre.Nomina.Receptor.TipoPeriodo - Nom.Receptor.BancoSpecified = True - Nom.Receptor.Banco = ObjCFDITimbre.Nomina.Receptor.CodigoBanco - Nom.Receptor.CuentaBancaria = ObjCFDITimbre.Nomina.Receptor.NumeroCuenta - Nom.Receptor.SalarioBaseCotAporSpecified = True - Nom.Receptor.SalarioBaseCotApor = ObjCFDITimbre.Nomina.Receptor.SBC.ToDecimal - Nom.Receptor.SalarioDiarioIntegradoSpecified = True - Nom.Receptor.SalarioDiarioIntegrado = ObjCFDITimbre.Nomina.Receptor.SDI.ToDecimal - Nom.Receptor.ClaveEntFed = ObjCFDITimbre.Nomina.Receptor.CodigoEntidadFederativa - - Dim nsNom As New System.Xml.Serialization.XmlSerializerNamespaces() - nsNom.Add("nomina12", "http://www.sat.gob.mx/nomina12") - Dim xmlNom As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(Nom, GetType(Profact.TimbraCFDI33.Complementos.Nomina12.Nomina), nsNom) - Dim docNom As New XmlDocument() - docNom.LoadXml(xmlNom) - LXmlComplementos.Add(docNom.DocumentElement) - TieneComplemento = True - - - End If -#End Region - -#End Region - -#Region "Detallista" - If Ventas.Cliente.AplicaDetallista Then - Dim detallista As Profact.TimbraCFDI33.Complementos.Detallista.detallista = New Profact.TimbraCFDI33.Complementos.Detallista.detallista - detallista.type = "SimpleInvoiceType" - detallista.contentVersion = "1.3.1" - detallista.documentStructureVersion = "AMC8.1" - detallista.documentStatus = Profact.TimbraCFDI33.Complementos.Detallista.detallistaDocumentStatus.ORIGINAL - - detallista.DeliveryNote = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaDeliveryNote - detallista.DeliveryNote.referenceIdentification = New String((1)) {} - detallista.DeliveryNote.referenceIdentification(0) = "1" - detallista.DeliveryNote.ReferenceDate = New DateTime - detallista.DeliveryNote.ReferenceDate = comprobante.Fecha - detallista.DeliveryNote.ReferenceDateSpecified = True - - detallista.requestForPaymentIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaRequestForPaymentIdentification - detallista.requestForPaymentIdentification.entityType = Profact.TimbraCFDI33.Complementos.Detallista.detallistaRequestForPaymentIdentificationEntityType.INVOICE - - detallista.specialInstruction = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSpecialInstruction((1)) {} - detallista.specialInstruction(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSpecialInstruction - detallista.specialInstruction(0).code = Profact.TimbraCFDI33.Complementos.Detallista.detallistaSpecialInstructionCode.ZZZ - Dim TotalTexto = New String() {Ventas.TotalTC.ToString.ToDouble.Texto2Letras.ToUpper()} - Dim propertyInfo = detallista.specialInstruction(0).GetType().GetProperty("text") - propertyInfo.SetValue(detallista.specialInstruction(0), Convert.ChangeType(TotalTexto, propertyInfo.PropertyType), Nothing) - - detallista.orderIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentification - detallista.orderIdentification.referenceIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentificationReferenceIdentification((1)) {} - detallista.orderIdentification.referenceIdentification(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentificationReferenceIdentification - detallista.orderIdentification.referenceIdentification(0).type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentificationReferenceIdentificationType.ON - detallista.orderIdentification.referenceIdentification(0).Value = Ventas.Det_OrdenCompra - detallista.orderIdentification.ReferenceDateSpecified = True - detallista.orderIdentification.ReferenceDate = Ventas.Det_FechaOrdenCompra.ToDate() - - detallista.AdditionalInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaReferenceIdentification((1)) {} - detallista.AdditionalInformation(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaReferenceIdentification - detallista.AdditionalInformation(0).type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaReferenceIdentificationType.ATZ - detallista.AdditionalInformation(0).Value = Ventas.Det_ContraRecibo - - detallista.DeliveryNote = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaDeliveryNote - detallista.DeliveryNote.ReferenceDate = Ventas.Det_FechaOrdenCompra.ToDate - detallista.DeliveryNote.referenceIdentification = New String((1)) {} - detallista.DeliveryNote.referenceIdentification(0) = Ventas.Det_ContraRecibo - - detallista.buyer = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaBuyer - detallista.buyer.gln = Ventas.Cliente.Detallista_GLNComprador - detallista.buyer.contactInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaBuyerContactInformation - detallista.buyer.contactInformation.personOrDepartmentName = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaBuyerContactInformationPersonOrDepartmentName - detallista.buyer.contactInformation.personOrDepartmentName.text = Ventas.Cliente.Detallista_Departamento - - detallista.seller = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSeller - detallista.seller.gln = Ventas.Cliente.Detallista_GLNVendedor - detallista.seller.alternatePartyIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSellerAlternatePartyIdentification - detallista.seller.alternatePartyIdentification.type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaSellerAlternatePartyIdentificationType.SELLER_ASSIGNED_IDENTIFIER_FOR_A_PARTY - detallista.seller.alternatePartyIdentification.Value = Ventas.Cliente.Detallista_NumProveedor - - 'detallista.shipTo = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaShipTo - 'detallista.shipTo.gln = "0000000000000" - 'detallista.shipTo.nameAndAddress = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaShipToNameAndAddress - 'detallista.shipTo.nameAndAddress.name = New String((1)) {} - 'detallista.shipTo.nameAndAddress.name(0) = Ventas.Cliente.Direccion - 'detallista.shipTo.nameAndAddress.streetAddressOne = New String((1)) {} - 'detallista.shipTo.nameAndAddress.streetAddressOne(0) = Ventas.Cliente.NoInt - 'detallista.shipTo.nameAndAddress.city = New String((1)) {} - 'detallista.shipTo.nameAndAddress.city(0) = Ventas.Cliente.Ciudad - 'detallista.shipTo.nameAndAddress.postalCode = New String((1)) {} - 'detallista.shipTo.nameAndAddress.postalCode(0) = Ventas.Cliente.CP - - detallista.paymentTerms = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTerms - detallista.paymentTerms.netPayment = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPayment - detallista.paymentTerms.netPayment.paymentTimePeriod = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPaymentPaymentTimePeriod - detallista.paymentTerms.netPayment.paymentTimePeriod.timePeriodDue = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPaymentPaymentTimePeriodTimePeriodDue - detallista.paymentTerms.netPayment.paymentTimePeriod.timePeriodDue.timePeriod = Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPaymentPaymentTimePeriodTimePeriodDueTimePeriod.DAYS - detallista.paymentTerms.netPayment.paymentTimePeriod.timePeriodDue.value = "0" - - detallista.paymentTerms.discountPayment = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsDiscountPayment - detallista.paymentTerms.discountPayment.percentage = If(Ventas.DescuentoTC > 0 AndAlso Ventas.SubTotalTC > 0, (Ventas.DescuentoTC * 100) / Ventas.SubTotalTC, 0).ToString().FormatoNumero() - - detallista.currency = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrency((1)) {} - detallista.currency(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrency - detallista.currency(0).currencyISOCode = If(Ventas.CveMoneda = 1, Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyISOCode.MXN, Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyISOCode.USD) - detallista.currency(0).currencyFunction = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyFunction((1)) {} - detallista.currency(0).currencyFunction(0) = Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyFunction.BILLING_CURRENCY - detallista.currency(0).rateOfChangeSpecified = True - detallista.currency(0).rateOfChange = 1 - - detallista.allowanceCharge = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceCharge(1) {} - detallista.allowanceCharge(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceCharge - detallista.allowanceCharge(0).monetaryAmountOrPercentage = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceChargeMonetaryAmountOrPercentage - detallista.allowanceCharge(0).monetaryAmountOrPercentage.rate = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceChargeMonetaryAmountOrPercentageRate - detallista.allowanceCharge(0).monetaryAmountOrPercentage.rate.base = Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceChargeMonetaryAmountOrPercentageRateBase.INVOICE_VALUE - detallista.allowanceCharge(0).monetaryAmountOrPercentage.rate.percentage = If(Ventas.DescuentoTC > 0 AndAlso Ventas.SubTotalTC > 0, (Ventas.DescuentoTC * 100) / Ventas.SubTotalTC, 0) - - Dim articuloCounter As Integer = 0 - For Each concepto As Profact.TimbraCFDI33.ComprobanteConcepto In comprobante.Conceptos - articuloCounter = (articuloCounter + 1) - Next - detallista.lineItem = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItem((articuloCounter)) {} - Dim counter As Integer = 0 - For Each concepto As Profact.TimbraCFDI33.ComprobanteConcepto In comprobante.Conceptos - detallista.lineItem(counter) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItem - detallista.lineItem(counter).type = "SimpleInvoiceLineItemType" - detallista.lineItem(counter).number = (counter + 1).ToString - detallista.lineItem(counter).tradeItemIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemIdentification - detallista.lineItem(counter).tradeItemIdentification.gtin = comprobante.Conceptos(counter).NoIdentificacion - detallista.lineItem(counter).alternateTradeItemIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentification(1) {} - detallista.lineItem(counter).alternateTradeItemIdentification(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentification - detallista.lineItem(counter).alternateTradeItemIdentification(0).type = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentificationType - detallista.lineItem(counter).alternateTradeItemIdentification(0).type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentificationType.BUYER_ASSIGNED - detallista.lineItem(counter).tradeItemDescriptionInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemDescriptionInformation - If (comprobante.Conceptos(counter).Descripcion.Length > 34) Then - detallista.lineItem(counter).tradeItemDescriptionInformation.longText = comprobante.Conceptos(counter).Descripcion.Substring(0, 34) - Else - detallista.lineItem(counter).tradeItemDescriptionInformation.longText = comprobante.Conceptos(counter).Descripcion - End If - detallista.lineItem(counter).invoicedQuantity = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemInvoicedQuantity - detallista.lineItem(counter).invoicedQuantity.unitOfMeasure = comprobante.Conceptos(counter).Unidad - detallista.lineItem(counter).invoicedQuantity.Text = New String((1)) {} - detallista.lineItem(counter).invoicedQuantity.Text(0) = comprobante.Conceptos(counter).Cantidad.ToString - - detallista.lineItem(counter).aditionalQuantity = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAditionalQuantity(1) {} - detallista.lineItem(counter).aditionalQuantity(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAditionalQuantity - detallista.lineItem(counter).aditionalQuantity(0).QuantityType = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAditionalQuantityQuantityType.NUM_CONSUMER_UNITS - detallista.lineItem(counter).aditionalQuantity(0).Text = New String((1)) {} - detallista.lineItem(counter).aditionalQuantity(0).Text(0) = "1" - - detallista.lineItem(counter).grossPrice = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemGrossPrice - detallista.lineItem(counter).grossPrice.Amount = comprobante.Conceptos(counter).ValorUnitario - - detallista.lineItem(counter).netPrice = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemNetPrice - detallista.lineItem(counter).netPrice.Amount = comprobante.Conceptos(counter).ValorUnitario - - detallista.lineItem(counter).AdditionalInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAdditionalInformation - detallista.lineItem(counter).AdditionalInformation.referenceIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAdditionalInformationReferenceIdentification - detallista.lineItem(counter).AdditionalInformation.referenceIdentification.type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAdditionalInformationReferenceIdentificationType.ON - detallista.lineItem(counter).AdditionalInformation.referenceIdentification.Value = "1587" - 'Impuestos - Dim tasa As Decimal = 0 - Dim importeImp As Decimal = 0 - Try - If (Not (comprobante.Impuestos.Traslados) Is Nothing) Then - For Each traslado As Profact.TimbraCFDI33.ComprobanteImpuestosTraslado In comprobante.Impuestos.Traslados - tasa = Decimal.Parse(traslado.TasaOCuota) - importeImp = (comprobante.Conceptos(counter).Importe * (tasa / 100)) - Next - End If - - Catch ex As System.Exception - - End Try - - detallista.lineItem(counter).tradeItemTaxInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformation(1) {} - detallista.lineItem(counter).tradeItemTaxInformation(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformation - detallista.lineItem(counter).tradeItemTaxInformation(0).taxTypeDescription = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformationTaxTypeDescription - detallista.lineItem(counter).tradeItemTaxInformation(0).taxTypeDescription = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformationTaxTypeDescription.VAT - detallista.lineItem(counter).tradeItemTaxInformation(0).tradeItemTaxAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformationTradeItemTaxAmount - detallista.lineItem(counter).tradeItemTaxInformation(0).tradeItemTaxAmount.taxPercentage = tasa - detallista.lineItem(counter).tradeItemTaxInformation(0).tradeItemTaxAmount.taxAmount = importeImp - - detallista.lineItem(counter).totalLineAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTotalLineAmount - detallista.lineItem(counter).totalLineAmount.grossAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTotalLineAmountGrossAmount - detallista.lineItem(counter).totalLineAmount.grossAmount.Amount = comprobante.Conceptos(counter).Importe - detallista.lineItem(counter).totalLineAmount.netAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTotalLineAmountNetAmount - detallista.lineItem(counter).totalLineAmount.netAmount.Amount = comprobante.Conceptos(counter).Importe - counter = (counter + 1) - Next - detallista.totalAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAmount - detallista.totalAmount.Amount = comprobante.SubTotal - - detallista.TotalAllowanceCharge = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAllowanceCharge(1) {} - detallista.TotalAllowanceCharge(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAllowanceCharge - detallista.TotalAllowanceCharge(0).allowanceOrChargeType = Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAllowanceChargeAllowanceOrChargeType.ALLOWANCE - detallista.TotalAllowanceCharge(0).Amount = Ventas.DescuentoTC - - Dim nombres As System.Xml.Serialization.XmlSerializerNamespaces = New System.Xml.Serialization.XmlSerializerNamespaces - nombres.Add("detallista", "http://www.sat.gob.mx/detallista") - Dim xmlDetallista As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(detallista, GetType(Profact.TimbraCFDI33.Complementos.Detallista.detallista), nombres) - - Dim docDetallista As XmlDocument = New XmlDocument - docDetallista.LoadXml(xmlDetallista) - comprobante.DetallistaSpecified = True - LXmlComplementos.Add(docDetallista.DocumentElement) - - TieneComplemento = True - End If -#End Region - - If TieneComplemento Then - comprobante.Complemento = New Profact.TimbraCFDI33.ComprobanteComplemento - comprobante.Complemento.Any = LXmlComplementos.ToArray() - End If - - sw.Stop() - swTiempo.AppendFormat("Armado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) - swmili = sw.ElapsedMilliseconds - sw.Start() - -#Region "Genera XML" - ' Try - ' cfdi.GenerarXMLBase64(llaveBase64, Clave) - ' cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) - ' Catch ex As Exception - - ' End Try - '//Timbramos el CFDI por medio del conector y guardamos resultado - Dim resultadoTimbre As Profact.TimbraCFDI.ResultadoTimbre - -#End Region - - sw.Stop() - swTiempo.AppendFormat("Genera: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) - swmili = sw.ElapsedMilliseconds - sw.Start() - -#Region "Timbra" - resultadoTimbre = cfdi.TimbraCFDI(comprobante) -#End Region - - sw.Stop() - swTiempo.AppendFormat("Timbrado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) - swmili = sw.ElapsedMilliseconds - sw.Start() - - 'Verifica el error - If resultadoTimbre.Exitoso Then - - 'Dim FechaCertificacion As DateTime - Dim FolioFiscal As String - - UUID = resultadoTimbre.FolioUUID - FolioFiscal = resultadoTimbre.FolioUUID - If FolioFiscal <> "" Then - resultadoTimbre.GuardaXml(RutaArchivo, NombreArchivoXML) - - - If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then - - 'Actualiza Estatus Factura - If Ventas.CveVenta > 0 Then - - - Dim ObjVentas As New ClsVentas() - If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", Now, Ventas.CveVenta, CvePAC:=UsuarioActual.Empresa.CvePAC) Then - Retorno = "" - Else - Retorno = "Error" - End If - ObjVentas.Dispose() - - - ''Actualiza Cliente (NumeroCuenta) - 'If Not UsuarioActual.CveEmpresa.Contiene(72, 80) Then - ' Dim Hilo2 As New System.Threading.Thread(Sub() ActualizaCliente(UsuarioActual.CveUsuario, Ventas.Cliente.NumCtaPago, Ventas.CveMetodoPago, Ventas.CveCliente)) - ' Hilo2.Start() - 'End If - - End If - End If - - If Not IO.Directory.Exists($"{UsuarioActual.Empresa.Ruta}CBB\") Then IO.Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}CBB\") - - Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\" - Dim NombreCBB As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" - resultadoTimbre.GuardaCodigoBidimensional(RutaCBB, NombreCBB) - - '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 - - If ObjCFDITimbre.Comprobante.TipoComprobante = "T" Then - Dim ObjInv As New ClsInventarios() - If ObjInv.UpdateMovimientoTimbrado(Ventas.Inv_CveMovimiento, 1, FolioFiscal, MinFecha) Then - Retorno = "" - Else - Retorno = "Error" - End If - ObjInv.Dispose() - End If - - 'Pendiente. Ruta guardar archivos - sw.Stop() - swTiempo.AppendFormat("Actualizado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) - swmili = sw.ElapsedMilliseconds - sw.Start() - - Retorno = "" - Else - Retorno = "No se pudo timbrar ante el SAT. UUID no generado." - End If - - - Else - Dim Resultados = Newtonsoft.Json.Linq.JArray.Parse(resultadoTimbre.Detalle) - If Resultados.Count > 0 Then - Retorno = Resultados(0)("Value").ToString() - MensajeErrorCFDI = Resultados(0)("Value").ToString() - Else - Retorno = resultadoTimbre.Detalle - MensajeErrorCFDI = resultadoTimbre.Detalle - End If - - End If - - GuardaLogTimbrado(swTiempo.ToString, UsuarioActual.Empresa.CvePAC) - Return Retorno - End Function - -#Region "F U N C I O N E S" - Private Function obtenerAtributo(cadena_xml As String, nodo As String, nombre_atributo As String) As String - Try - 'Variables - Dim valor As String - Dim inicio As Integer = 0 - Dim fin As Integer = 0 - Dim inicionodo As Integer = cadena_xml.IndexOf(nodo) - If inicionodo = -1 Then - Return "" - End If - 'Buscamos inicio - inicio = cadena_xml.IndexOf((Convert.ToString(" ") & nombre_atributo) + "=""", inicionodo) + nombre_atributo.Length + 3 - 'Buscamos el final - fin = cadena_xml.IndexOf("""", inicio) - 'Cortamos la cadena - valor = cadena_xml.Substring(inicio, fin - inicio) - 'Retorna el valor - Return valor - Catch - Return "" - End Try - End Function - Private Function TimbrarFacturaProFact(UsuarioActual As Usuario, Optional Ventas As Modelos.Factura = Nothing, Optional TmpDTConceptos As DataTable = Nothing, Optional TmpDTImpuestos As DataTable = Nothing, Optional TmpDTComplementos As DataTable = Nothing, Optional Ruta As String = "", Optional LstFordASN As ListBox = Nothing, Optional FordGSDBM As String = "", Optional ObjV As ClsVentas = Nothing) As Boolean - - Dim Ret As String = TimbrarFacturaProFactv33(Ventas, UsuarioActual) - Return If(Ret = "", True, False) - - End Function - Private Sub GeneraAddenda7Eleven(Archivo As String, TmpDTConceptos As DataTable, TmpDT7Eleven As DataTable) - Dim cfdi As String = "" - Dim SB As New StringBuilder - Try - Using sr As New StreamReader(Archivo) - - cfdi = sr.ReadToEnd() - - End Using - Catch e As Exception - Alert("The file could not be read:", TipoMensaje.MsgError) - - End Try - - cfdi = cfdi.Replace("", "") - - SB.Append(cfdi) - - SB.Append("") - SB.AppendFormat("", TmpDT7Eleven.Rows(0)("sevenElevenNumProveedor").ToString) - SB.AppendFormat("", TmpDT7Eleven.Rows(0)("sevenElevenFolio").ToString, TmpDT7Eleven.Rows(0)("sevenElevenTienda").ToString, TmpDT7Eleven.Rows(0)("sevenElevenFecha").ToString) - - For Each Row As DataRow In TmpDTConceptos.Rows - - SB.AppendFormat("", Row("Codigo"), Row("PS"), Row("Cantidad").ToString.ToDouble.FormatoNumero(), Row("PU").ToString.ToDouble.FormatoNumero()) - - Next - - SB.Append("") - - - Using outfile As New StreamWriter(Archivo) - outfile.Write(SB.ToString()) - End Using - - End Sub - Private Sub GeneraAddendaFord(Archivo As String, pFolio As String, LstFordASN As String, FordGSDBM As String) - Dim cfdi As String = "" - Dim SB As New StringBuilder - Try - Using sr As New StreamReader(Archivo) - - cfdi = sr.ReadToEnd() - - End Using - Catch e As Exception - Alert("The file could not be read:", TipoMensaje.MsgError) - - End Try - - - cfdi = cfdi.Replace("", "") - - SB.Append(cfdi) - - SB.Append("") - SB.AppendFormat("{0}", FordGSDBM.Trim.ToUpper) - - If pFolio <> "" Then SB.AppendFormat("{0}", pFolio) - 'If TxtFordASN2.Text.Trim <> "" Then SB.AppendFormat("{0}", TxtFordASN2.Text.Trim) - - For Each li As String In LstFordASN.Split(","c) - - If li <> "" Then SB.AppendFormat("{0}", li) - - Next - - SB.Append("") - - - Using outfile As New StreamWriter(Archivo) - outfile.Write(SB.ToString()) - End Using - - End Sub - Private Sub GeneraAddendaFord(Archivo As String, pFolio As String, LstFordASN As ListBox, FordGSDBM As String) - Dim cfdi As String = "" - Dim SB As New StringBuilder - Try - Using sr As New StreamReader(Archivo) - - cfdi = sr.ReadToEnd() - - End Using - Catch e As Exception - Alert("The file could not be read:", TipoMensaje.MsgError) - - End Try - - - cfdi = cfdi.Replace("", "") - - SB.Append(cfdi) - - SB.Append("") - SB.AppendFormat("{0}", FordGSDBM.Trim.ToUpper) - - If pFolio <> "" Then SB.AppendFormat("{0}", pFolio) - 'If TxtFordASN2.Text.Trim <> "" Then SB.AppendFormat("{0}", TxtFordASN2.Text.Trim) - - For Each li As ListItem In LstFordASN.Items - - SB.AppendFormat("{0}", li.Text) - - Next - - SB.Append("") - - - Using outfile As New StreamWriter(Archivo) - outfile.Write(SB.ToString()) - End Using - - End Sub - Private Function DecodeBase64(ByVal strXMLCodificado As String) As String - Try - Dim decbuff As Byte() = Convert.FromBase64String(strXMLCodificado) - Return System.Text.Encoding.UTF8.GetString(decbuff) - Catch - Return "" - End Try - End Function - Private Function CodificarABase64(strXML As String) As String - Dim utf8Bytes As Byte() = UTF8Encoding.UTF8.GetBytes(strXML) - Return Convert.ToBase64String(utf8Bytes) - End Function -#End Region - -End Class +Option Explicit On +Option Strict On + +Imports Extensiones +Imports System.IO +Imports System.Linq +Imports System.Xml +Imports System.Data +Public Class Timbrado + +#Region "P R O P I E D A D E S" + Public Property MensajeErrorCFDI As String + Public Property UUID As String = "" + Public Property CancelacionAcuse As String + Public Property CancelacionState As Integer + Public Property CancelacionMensaje As String + Public Property CancelacionFecha As Date + + + Public Class AcuseCancelacionSAT + Public Property CodigoEstatus As String + Public Property EsCancelable As String + Public Property Estado As String + Public Property EstatusCancelacion As String + End Class + +#End Region + + Public Shared Function VerificarVigenciaSAT(uuid As String, emisor As String, receptor As String, total As String, produccion As Boolean) As AcuseCancelacionSAT + Dim Retorno As AcuseCancelacionSAT = Nothing + Dim resp As Cancelacion.AcuseSat = New Cancelacion.AcuseSat() + Using ws As Cancelacion.CancelacionSoapClient = New Cancelacion.CancelacionSoapClient + Try + If Not produccion Then + Dim PACUsuario As String = "rene.molina@adsistemas.mx" + Dim PACContrasenia As String = "rene2018" + resp = ws.ConsultaVigenciaTest(emisor, PACUsuario, PACContrasenia, uuid, receptor, total) + Retorno = New AcuseCancelacionSAT() + Else + resp = ws.ConsultaVigencia(emisor, "UserTest", "1234567890", uuid, receptor, total) + Retorno = New AcuseCancelacionSAT() + End If + Catch ex As Exception + Return Nothing + End Try + + If Retorno IsNot Nothing Then + Retorno.CodigoEstatus = resp.CodigoEstatus + Retorno.Estado = resp.Estado + Retorno.EsCancelable = resp.EsCancelable + Retorno.EstatusCancelacion = resp.EstatusCancelacion + End If + + End Using + Return Retorno + End Function + 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 + Return False + End If + Else + Return False + End If + End If + + + MsgCancelacion.AppendFormat("CvePAC:{0}", CvePACCancelacion) + + Select Case CvePACCancelacion + Case 1 + MsgCancelacion.AppendFormat("1.1") + Try + Dim CFDi As New ClbNegBICFDv3_2.ClsNegEDI + Dim Respuesta As New ClbNegBICFDv3_2.ClsNegRespuesta + Respuesta = CFDi.CancelaCFdi(Empresa.BIUsuario, Empresa.BIContraseña, Empresa.Ruta & "Certificados\" & Empresa.ArchivoPfx, Empresa.ContraseñaKey, Empresa.RFC, FolioFiscal, "http://portalbiinform.com.mx/srvCFDi/service1.asmx") + + If Respuesta IsNot Nothing AndAlso Respuesta.SelloSAT <> "" Then + Dim xml64 As String = "" + Dim myXml As String = Respuesta.SelloSAT + Dim resp As XElement = XElement.Parse(myXml) + For Each elem As XElement In resp.Descendants + If elem.Name = "xmlBase64" Then xml64 = elem.Value + Next + + 'If Respuesta.UUDI.Contiene("0", "201", "202") Then + Dim xmlDoc As New System.Xml.XmlDocument() + xmlDoc.LoadXml(If(xml64 = "", Respuesta.SelloSAT, Encoding.UTF8.GetString(Convert.FromBase64String(xml64)))) + Dim AcuseChild = xmlDoc.ChildNodes.Cast(Of XmlNode).Where(Function(a) a.Name.Equals("Acuse", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() + + Dim FoliosChild = AcuseChild.ChildNodes.Cast(Of XmlNode).Where(Function(a) a.LocalName.Equals("Folios", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() + Dim SignatureChild = AcuseChild.ChildNodes.Cast(Of XmlNode).Where(Function(a) a.LocalName.Equals("Signature", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() + + Dim prefixFol As String = FoliosChild.Prefix + If prefixFol <> "" Then prefixFol = $"{prefixFol}:" 'se le agregan los ":" si tiene prefijo + + CancelacionState = xmlDoc.GetElementsByTagName($"{prefixFol}EstatusUUID")(0).InnerText.ToEntero + 'verificación basada en el resultado del xml. + If CancelacionState.Contiene(201, 202) Then + + Dim prefixSig = SignatureChild.Prefix + If prefixSig <> "" Then prefixSig = $"{prefixSig}:" 'se le agregan los ":" si tiene prefijo + Dim SignatureValue = xmlDoc.GetElementsByTagName($"{prefixSig}SignatureValue") + CancelacionAcuse = If(SignatureValue.Count < 1, SignatureValue(0).InnerText, SignatureValue(0).InnerText) + Try + CancelacionFecha = AcuseChild.Attributes("Fecha").Value.ToDate + Catch ex As Exception + CancelacionFecha = xmlDoc.GetElementsByTagName("CancelaCFDResult")(0).Attributes("Fecha").Value.ToDate + End Try + Retorno = True + End If + + 'End If + + Else + Me.GuardaLog(CFDi.MsgError) + End If + Respuesta = Nothing + CFDi = Nothing + Catch ex As Exception + GuardaLog($"{ex.Message}") + End Try + + Case 2 + MsgCancelacion.AppendFormat("2.1") + Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" + Dim UsuarioServicio As String = If(CvePACCancelacion = 2, Empresa.RFC, "rene.molina@adsistemas.mx") + Dim ClaveServicio As String = If(CvePACCancelacion = 2, Empresa.RFC.ToLower, "rene2018") + Dim Clave As String = Empresa.ContraseñaKey + Dim UrlServicio As String = "" ' Produccion + Select Case CvePACCancelacion + Case 2 + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" + Case 4 + UrlServicio = "http://192.168.0.2:8080/ADSistemas/Timbrado.asmx?WSDL" + End Select + + If Not Empresa.FacturaProduccion Then + ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + Select Case CvePACCancelacion + Case 2 + UsuarioServicio = "fgomez" + ClaveServicio = "12121212" + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" + Case 4 + UsuarioServicio = "UserTest" + ClaveServicio = "1234567890" + UrlServicio = "http://192.168.0.2:8080/ADSistemas/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 False + End If + If Not File.Exists(ArchivoLLave) Then + Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) + Return False + End If + If Empresa.ContraseñaKey = "" Then + Alert("La clave no puede ser vacía", TipoMensaje.MsgError) + Return False + End If +#End Region + +#Region "Variables" + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String, certBase64 As String + Dim cfdi As New RVCFDI.GeneraCFDI() + 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 False + 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 False + + End Try +#End Region + + + Dim base64 As String + Dim ObjCancelacion As New RVCancelacion.Cancelacion() + + Dim xmlCancelacion As String = ObjCancelacion.crearXMLCancelacion(certBase64, llaveBase64, Clave, FolioFiscal) + If (ObjCancelacion.MensajeDeError = "") Then + + base64 = CodificarABase64(xmlCancelacion) + + Dim objWS As RVCFDI.WSGeneraCFDI.Service = Nothing + Dim objAuthSoapHD As RVCFDI.WSGeneraCFDI.AuthSoapHd + Dim objResponse As RVCFDI.WSGeneraCFDI.StructCfd + Dim objCancel As RVCFDI.WSGeneraCFDI.StructCancel + + Try + + + 'Variables de consumo de servicio web + objWS = New RVCFDI.WSGeneraCFDI.Service() + objAuthSoapHD = New RVCFDI.WSGeneraCFDI.AuthSoapHd() + 'creacion de Autorizacion de cabecera Soap + objCancel = New RVCFDI.WSGeneraCFDI.StructCancel() + 'Configura el servicio + objWS.Url = UrlServicio + + objAuthSoapHD.strPassword = ClaveServicio + objAuthSoapHD.strUserName = UsuarioServicio + 'Coloca la cabecera + objWS.AuthSoapHdValue = objAuthSoapHD + 'Obtiene el resultado + objCancel = objWS.CancelTicket(base64) + 'Valida la respuesta + ''Codigos del SAT + ''201 - El folio se ha cancelado con éxito. + ''202 - El CFDI ya había sido cancelado previamente. + ''203 - UUID no corresponde al emisor. + ''204 - El CFDI no aplica para cancelación. + ''205 - El UUID no existe o no ha sido procesado por el SAT. + ''402 - El Contribuyente no se encuentra el la LCO o la validez de obligaciones se reporta como negativa. + CancelacionState = objCancel.state + CancelacionMensaje = objCancel.Descripcion + + If objCancel.state.Contiene(0, 201, 202) Then + CancelacionFecha = Now + + Select Case CvePACCancelacion + Case 2 + Dim solicitud As New WSRVConsultas.Service1SoapClient + Dim resp As New WSRVConsultas.resp_Acuse() + resp = solicitud.ConsultarAcuseCancelacion(RFCEmisor, UsuarioServicio, ClaveServicio, FolioFiscal, CancelacionFecha.ToShortDateString) + CancelacionMensaje = objCancel.Descripcion + + If (resp.Estado = 0) Then + + Dim xmlDoc As New System.Xml.XmlDocument() + xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml))) + Dim xpath As String = "Acuse/Folios" + Dim nodes = xmlDoc.SelectNodes(xpath) + CancelacionState = xmlDoc.GetElementsByTagName("EstatusUUID")(0).InnerText.ToEntero + + xpath = "Acuse/Signature" + nodes = xmlDoc.SelectNodes(xpath) + + CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText + CancelacionFecha = xmlDoc.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate + Retorno = True + Else + CancelacionAcuse = resp.MensajeDeError + Retorno = False + End If + solicitud = Nothing + Case 4 + + Dim solicitud As New WSGF.Service1SoapClient + Dim resp As New WSGF.StructXml() + resp = solicitud.GetAcuse(RFCEmisor, UsuarioServicio, ClaveServicio, FolioFiscal) + CancelacionMensaje = objCancel.Descripcion + + If (resp.Estado = 0) Then + + Dim xmlDoc As New System.Xml.XmlDocument() + xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(resp.CfdiB64))) + Dim xpath As String = "Acuse/Folios" + Dim nodes = xmlDoc.SelectNodes(xpath) + CancelacionState = xmlDoc.GetElementsByTagName("EstatusUUID")(0).InnerText.ToEntero + + xpath = "Acuse/Signature" + nodes = xmlDoc.SelectNodes(xpath) + + CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText + CancelacionFecha = xmlDoc.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate + Retorno = True + Else + CancelacionAcuse = resp.Descripcion + Retorno = False + End If + solicitud = Nothing + End Select + + + End If + Catch ex As Exception + CancelacionMensaje += $" | ex: {ex}" + Retorno = False + End Try + + 'Libera memoria + objWS.Dispose() + objResponse = Nothing + objAuthSoapHD = Nothing + GC.Collect() + End If + + + Case 3 + MsgCancelacion.AppendFormat("3.1") + Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" + Dim UsuarioServicio As String = Empresa.RFC + Dim ClaveServicio As String = Empresa.RFC.ToLower + Dim Clave As String = Empresa.ContraseñaKey + Dim UrlServicio As String = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" + Dim AmbienteProductivo As Boolean = True + + If Not Empresa.FacturaProduccion OrElse Empresa.CveEmpresa = 1 Then + UsuarioServicio = "fgomez" + ClaveServicio = "12121212" + Clave = "12345678a" + ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" '"http://108.60.211.43/rvltimbrado/service1.asmx" + AmbienteProductivo = False + End If + + +#Region "Valida" + If Not File.Exists(ArchivoCertificado) Then + Alert("El archivo de certificado no existe", TipoMensaje.MsgError) + Return False + End If + If Not File.Exists(ArchivoLLave) Then + Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) + Return False + End If + If Empresa.ContraseñaKey = "" Then + Alert("La clave no puede ser vacía", TipoMensaje.MsgError) + Return False + End If +#End Region + + Dim conector As New Profact.TimbraCFDI33.Conector(AmbienteProductivo) + + If Not AmbienteProductivo Then + conector.EstableceCredenciales("mvpNUXmQfK8=") + Else + conector.EstableceCredenciales("vSGxMFWnNRy/nDoowxqrqw==|Sia123654") + End If + + Dim resultadoCancelacion As Profact.TimbraCFDI.ResultadoCancelacionAck + resultadoCancelacion = conector.CancelaCFDIAck(RFCEmisor, FolioFiscal) + CancelacionFecha = Now + Dim resp As Profact.TimbraCFDI.ResultadoConsulta + resp = conector.ObtieneCFDI(RFCEmisor, FolioFiscal) + If resultadoCancelacion.Exitoso Then + CancelacionMensaje = resultadoCancelacion.Descripcion + Dim xmlDoc As New System.Xml.XmlDocument() + xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml))) + Dim xpath As String = "Acuse/Folios" + Dim nodes = xmlDoc.SelectNodes(xpath) + CancelacionState = xmlDoc.GetElementsByTagName("EstatusUUID")(0).InnerText.ToEntero + + xpath = "Acuse/Signature" + nodes = xmlDoc.SelectNodes(xpath) + + CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText + CancelacionFecha = xmlDoc.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate + Retorno = True + Else + CancelacionAcuse = resp.NumeroError + Retorno = False + End If + + Case 4 + MsgCancelacion.AppendFormat("4.1-") + Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" + Dim UsuarioServicio As String = If(CvePACCancelacion = 2, Empresa.RFC, "rene.molina@adsistemas.mx") + Dim ClaveServicio As String = If(CvePACCancelacion = 2, Empresa.RFC.ToLower, "rene2018") + Dim Clave As String = Empresa.ContraseñaKey + Dim UrlServicio As String = "" ' Produccion + + UrlServicio = "http://juancalderon-001-site1.ftempurl.com/timbrado.asmx?WSDL" + + If Not Empresa.FacturaProduccion Then + ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + + UsuarioServicio = "UserTest" + ClaveServicio = "1234567890" + UrlServicio = "http://juancalderon-001-site6.ftempurl.com/cancelacion.asmx?WSDL" + + End If + +#Region "Valida" + If Not File.Exists(ArchivoCertificado) Then + Alert("El archivo de certificado no existe", TipoMensaje.MsgError) + Return False + End If + If Not File.Exists(ArchivoLLave) Then + Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) + Return False + End If + If Empresa.ContraseñaKey = "" Then + Alert("La clave no puede ser vacía", TipoMensaje.MsgError) + Return False + End If +#End Region + +#Region "Variables" + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String, certBase64 As String + Dim objCan 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 False + 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 False + + End Try +#End Region + objCan.CancelacionCfdi = True + objCan.FechaCancelacion = System.DateTime.Now.AddMinutes(-120) ' operación requerida para que no se presente problemas con fechas adelantadas del PAC + MsgCancelacion.AppendFormat("4.3-") + objCan.GeneraCancelacionB64(certBase64, llaveBase64, Clave, FolioFiscal) + If (objCan.MensajeError = "") Then + MsgCancelacion.AppendFormat("4.4-") + objCan.CancelaCfdi(UsuarioServicio, ClaveServicio, UrlServicio, Empresa.FacturaProduccion) + MsgCancelacion.AppendFormat("4.5-") + '' Verifica el resultado, 0. cancelado, 202, cancelado previamente + If (objCan.CodigoError.Contiene(0, 202)) Then + + MsgCancelacion.AppendFormat("4.5.1-") + Dim xmlDoc As New System.Xml.XmlDocument() + xmlDoc.LoadXml(objCan.Xml) + Dim xpath As String = "Acuse/Folios" + Dim nodes = xmlDoc.SelectNodes(xpath) + + xpath = "Acuse/Signature" + nodes = xmlDoc.SelectNodes(xpath) + + CancelacionAcuse = xmlDoc.GetElementsByTagName("SignatureValue")(0).InnerText + CancelacionFecha = xmlDoc.DocumentElement.Attributes("Fecha").Value.ToDate + Retorno = True + MsgCancelacion.AppendFormat("4.5.2-") + End If + + End If + MsgCancelacion.AppendFormat("{0} --Código:{1} -- XML: {2}", objCan.MensajeError, objCan.CodigoError, objCan.Xml) + + End Select + + + If Not Retorno Then + GuardaLog($"****** Error al cancelar factura ****** Estatus: {CancelacionState} | Mensaje: {CancelacionMensaje} | Mensaje SAT: {MsgCancelacion.ToString} ") + End If + + Return Retorno + End Function + Public Function PreparaTimbrePago(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String, + ReceptorRFC As String, ReceptorNombre As String, Serie As String, Folio As String, FechaTimbrado As DateTime, + CuentaPago As String, FechaPago As DateTime, FormaPago As String, MonedaPago As String, Monto As Double, LugarExpedicion As String, + CuentaBeneficiario As String, TipoCambioP As Double, dttpagos As Data.DataTable, + Optional UsoCFDI As String = "P01", Optional CFDIRelacionado As String = "", Optional EsCancelacion As Boolean = False) As CFDITimbre + ' validación extra para cuando es cancelación requiere el folio relacionado + If EsCancelacion AndAlso CFDIRelacionado = "" Then + Return Nothing + End If + + Dim Timbre As New CFDITimbre + + Timbre.Comprobante.TipoComprobante = "P" + Timbre.Comprobante.Folio = Folio + Timbre.Comprobante.Serie = Serie + Timbre.Comprobante.Fecha = FechaTimbrado + Timbre.Comprobante.FormadePago = "" + Timbre.Comprobante.CondicionesdePago = "" + Timbre.Comprobante.MetodoPago = "" + Timbre.Comprobante.Subtotal = 0 + Timbre.Comprobante.Descuentos = 0 + Timbre.Comprobante.Moneda = "XXX" + Timbre.Comprobante.TipoCambio = "" + Timbre.Comprobante.Total = 0 + + Timbre.Comprobante.LugarExpedicion = LugarExpedicion + + Timbre.Emisor.RegimenFiscal = EmisorRegimenFiscal + Timbre.Emisor.Nombre = EmisorNombre + Timbre.Emisor.RFC = EmisorRFC + + Timbre.Receptor.RFC = ReceptorRFC + Timbre.Receptor.Nombre = ReceptorNombre + Timbre.Receptor.UsoCFDI = UsoCFDI + + If CFDIRelacionado <> "-1" And CFDIRelacionado <> "" Then + Timbre.CFDIRelacionados.TipoRelacion = "04" + Timbre.CFDIRelacionados.UUID.Add(CFDIRelacionado) + End If + + 'detalles + + Dim concepto As New CFDIConceptos With {.Cantidad = 1, + .Descripcion = "Pago", + .ValorUnitario = 0, + .Importe = 0, + .Unidad = "", + .ClaveUnidad = "ACT", + .ClaveProdServ = "84111506", + .Noidentificacion = ""} + Timbre.Conceptos.Add(concepto) + + Select Case FormaPago + Case "01" + CuentaPago = "" + CuentaBeneficiario = "" + + End Select + + Dim ImporteCancelacion As Decimal = 1 + Dim MonedaCancelacion As String = "MXN" + Dim TipoCambioCancelacion As Double = 1 + If EsCancelacion Then MonedaPago = MonedaCancelacion + 'como registra un peso por cada fatura que se cancele, se tiene que multiplicar por el numero de facturas, para que se pueda emitir el timbre + If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then ImporteCancelacion = ImporteCancelacion * dttpagos.Rows.Count + Timbre.ComplementoPagos.CtaOrdenante = CuentaPago + Timbre.ComplementoPagos.CtaBeneficiario = CuentaBeneficiario + Timbre.ComplementoPagos.FechaPago = FechaPago + Timbre.ComplementoPagos.FormaDePagoP = FormaPago + Timbre.ComplementoPagos.MonedaP = MonedaPago + Timbre.ComplementoPagos.Monto = If(EsCancelacion, ImporteCancelacion, Monto) + Timbre.ComplementoPagos.TipoCambioP = If(EsCancelacion, TipoCambioCancelacion, TipoCambioP) + + + Dim VentaFolioFiscal, VentaSerie, VentaFolio, VentaAbreviaturaSAT, VentaMetodoPago As String + Dim VentaImportePago, VentaImporteSaldoInsoluto, VentaImporteSaldoAnterior, VentaTipoCambio, PorcentajeIVA, PorcentajeIEPS As Decimal + Dim VentaNumParcialidad As Integer + + If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then + + For Each dr As Data.DataRow In dttpagos.Rows + VentaFolioFiscal = dr("FolioFiscal").ToString + VentaSerie = dr("VentaSerie").ToString + VentaFolio = dr("VentaFolio").ToString + VentaAbreviaturaSAT = dr("VentaAbreviaturaSAT").ToString + VentaMetodoPago = dr("MetodoPago").ToString + VentaImportePago = dr("VentaImportePagado").ToString.ToDecimal + VentaImporteSaldoInsoluto = dr("ImpSaldoInsoluto").ToString.ToDecimal + VentaImporteSaldoAnterior = dr("ImpSaldoAnterior").ToString.ToDecimal + VentaTipoCambio = dr("TipoCambio").ToString.ToDecimal + VentaNumParcialidad = dr("NumParcialidad").ToString.ToEntero + PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal + PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal + ' si la moneda es igual, se omite el tipo de cambio de la venta + If MonedaPago = VentaAbreviaturaSAT Then VentaTipoCambio = 0 + + 'condiciones especiales para el pago en pesos, facturas en moneda extranjera + If MonedaPago = "MXN" AndAlso VentaAbreviaturaSAT <> "MXN" Then + VentaTipoCambio = 1 / VentaTipoCambio + End If + + ' For Each drr As Data.DataRow In DtFacturasPagadas.Rows + Dim doc As New CFDIComplementoPagosDocsRelacionados With {.IdDocumento = VentaFolioFiscal, + .Serie = VentaSerie, + .Folio = VentaFolio, + .MonedaDR = VentaAbreviaturaSAT, + .MetodoDePagoDR = VentaMetodoPago, + .ImpPagado = If(EsCancelacion, 1, VentaImportePago), + .ImpSaldoInsoluto = If(EsCancelacion, VentaImporteSaldoAnterior - 1, VentaImporteSaldoInsoluto), + .ImpSaldoAnt = VentaImporteSaldoAnterior, + .TipoCambioDR = VentaTipoCambio, + .NumParcialidad = VentaNumParcialidad} 'If(drr("MetodoPago").ToString = "PUE", 0, drr("NumParcialidad").ToString.ToEntero)} + Timbre.ComplementoPagos.DocumentosRelacionados.Add(doc) + + Next + End If + 'If drr("IVA").ToString.ToDouble > 0 Then + If PorcentajeIVA > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = VentaImportePago * PorcentajeIVA, .TasaOCuota = PorcentajeIVA, .Impuesto = "002"}) + 'Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = 0, .TasaOCuota = 0, .Impuesto = "002"}) + + If PorcentajeIEPS > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.Base = VentaImportePago * PorcentajeIEPS, .TasaOCuota = PorcentajeIEPS, .Impuesto = "003"}) + + + 'Next + + Return Timbre + + End Function + Public Function TimbrarFactura(UsuarioActual As Usuario, Ventas As Modelos.Factura, Optional CvePACEspecial As Integer = -1) As Boolean + + Dim Retorno As Boolean = False + Dim tCvePAC As Integer = UsuarioActual.Empresa.CvePAC + If CvePACEspecial <> -1 Then tCvePAC = CvePACEspecial + + Select Case tCvePAC + Case 1 + ' Retorno = TimbrarFacturaBIInform33(UsuarioActual, Ventas, FM, TmpDTConceptos, TmpDTImpuestos, TmpDT7Eleven, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) + Dim Ret As String = TimbrarFacturaBIInform33(Ventas, UsuarioActual) + Retorno = If(Ret = "", True, False) + + Case 2 + 'Retorno = TimbrarFacturaRealVirtual(UsuarioActual, Ventas, TmpDTConceptos, TmpDTImpuestos, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) + Dim Ret As String = TimbrarFacturaRealVirtualv33(Ventas, UsuarioActual) + Retorno = If(Ret = "", True, False) + + Case 3 + Retorno = TimbrarFacturaProFact(UsuarioActual, Ventas) + 'Retorno = TimbrarFacturaProFact(UsuarioActual, Ventas, TmpDTConceptos, TmpDTImpuestos, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) + Case 4 + + Dim Ret As String = TimbrarFacturaGoCFDIv33(Ventas, UsuarioActual) + Retorno = If(Ret = "", True, False) + + End Select + + + Return Retorno + End Function + Public Function TimbrarFacturaBIInform33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String + + + Dim Retorno As String = "" + + 'Dim SucMatriz As SubProyectoModel = Ventas.SubProyectoMatriz + 'Dim SucEmpresa As SubProyectoModel = Ventas.SubProyecto + 'Dim SucCliente As SucursalModel = Ventas.ClienteSucursal + Dim ObjCFDITimbre As CFDITimbre = Ventas.Timbre + Dim ArchivoLLave As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoCer}" + Dim ArchivoPFX As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoPfx}" + Dim UsuarioServicio As String = UsuarioActual.Empresa.RFC + Dim ClaveServicio As String = UsuarioActual.Empresa.RFC.ToLower + Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey + Dim EmisorRFC As String = UsuarioActual.Empresa.RFC + Dim UrlServicio As String = "http://portalbiinform.com.mx/srvCFDi33/service1.asmx" ' Produccion + Dim RutaArchivo As String = $"{UsuarioActual.Empresa.Ruta}XML\{Ventas.TipoDocto}\" + Dim NombreArchivoXML As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}" + Dim TimbraProduccion As Boolean = True + + 'Dim sevenElevenNumProveedor = TmpDT7Eleven.Rows(0)("sevenElevenNumProveedor").ToString + 'Dim sevenElevenFolio = TmpDT7Eleven.Rows(0)("sevenElevenFolio").ToString + 'Dim sevenElevenTienda = TmpDT7Eleven.Rows(0)("sevenElevenTienda").ToString + 'Dim sevenElevenFecha = TmpDT7Eleven.Rows(0)("sevenElevenFecha").ToString + + If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then + UsuarioServicio = UsuarioActual.Empresa.BIUsuario + ClaveServicio = UsuarioActual.Empresa.BIContraseña + Clave = "12345678a" + EmisorRFC = "AAA010101AAA" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + UrlServicio = "http://portalmacropro.com.mx/srvCFDi33prueba/service1.asmx" + TimbraProduccion = False + End If + + Dim CFDi As New ClbNegBICFDv3_3.ClsNegEDI + Dim ObjFemsa As New ClbNegBICFDv3_3.ClsNegAddFemsa + Dim ObjDetallista As New ClbNegBICFDv3_3.ClsNegEDICompDet + Dim ImpLoc As New ClbNegBICFDv3_3.ClsNegEDICompImplocal + + Dim Msg As String = String.Empty + 'Nodo Comprobante + Dim clbcomp As ClbNegBICFDv3_3.TipoDeComprobante = If(ObjCFDITimbre.Comprobante.TipoComprobante = "I", ClbNegBICFDv3_3.TipoDeComprobante.I, If(ObjCFDITimbre.Comprobante.TipoComprobante = "E", ClbNegBICFDv3_3.TipoDeComprobante.E, If(ObjCFDITimbre.Comprobante.TipoComprobante = "P", ClbNegBICFDv3_3.TipoDeComprobante.P, ClbNegBICFDv3_3.TipoDeComprobante.T))) + Msg = CFDi.comprobantecfd(0, 0, ObjCFDITimbre.Comprobante.Serie, + ObjCFDITimbre.Comprobante.Folio.ToString, + ObjCFDITimbre.Comprobante.Fecha, + ObjCFDITimbre.Comprobante.FormadePago, + ObjCFDITimbre.Comprobante.CondicionesdePago, + ObjCFDITimbre.Comprobante.Subtotal, + ObjCFDITimbre.Comprobante.Descuentos, + ObjCFDITimbre.Comprobante.TipoCambio.ToDecimal, + ObjCFDITimbre.Comprobante.Moneda, + ObjCFDITimbre.Comprobante.Total, + ObjCFDITimbre.Comprobante.MetodoPago, + clbcomp, + ObjCFDITimbre.Comprobante.LugarExpedicion, + ObjCFDITimbre.Comprobante.Confirmacion) + + If Msg = String.Empty Then + 'Nodo emisor + Msg = CFDi.EmisorCfd(If(UsuarioActual.Empresa.FacturaProduccion, UsuarioActual.Empresa.RFC, "AAA010101AAA"), UsuarioActual.Empresa.Empresa, UsuarioActual.Empresa.CodigoRegimenFiscal) + If Msg = String.Empty Then + + 'Nodo receptor + Msg = CFDi.ReceptorCfd(Ventas.Cliente.RFC, Ventas.Cliente.Nombre, "", "", Ventas.ClaveUsoCFDI) + If Msg = String.Empty Then + + 'Nodo conceptos, se agregan los PS + Dim HasErrorConceptos As Boolean = False + + If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then + For Each concep As CFDIConceptos In ObjCFDITimbre.Conceptos + CFDi.ConceptosCfd(concep.ClaveProdServ, concep.Cantidad, concep.Unidad, concep.Noidentificacion, concep.Descripcion, concep.ValorUnitario, concep.Importe, concep.ClaveUnidad, concep.Descuento) + For Each imp As CFDIConceptosImpuestos In concep.Impuestos + Dim clbImp As ClbNegBICFDv3_3.Impuesto = If(imp.Impuesto = "002", ClbNegBICFDv3_3.Impuesto.IVA, If(imp.Impuesto = "003", ClbNegBICFDv3_3.Impuesto.IEPS, ClbNegBICFDv3_3.Impuesto.ISR)) + Dim clbTipo As ClbNegBICFDv3_3.TipoFactor = If(imp.TipoFactor = "Tasa", ClbNegBICFDv3_3.TipoFactor.Tasa, If(imp.TipoFactor = "Cuota", ClbNegBICFDv3_3.TipoFactor.Cuota, ClbNegBICFDv3_3.TipoFactor.Exento)) + Dim Posicion As Integer = imp.TasaOCuota.ToString.IndexOf(".") + If imp.TrasladooRetencion = "T" Then + CFDi.ConceptosTrasladosCfd(imp.Base, clbImp, clbTipo, imp.TasaOCuota.ToString.PadRight(imp.TasaOCuota.ToString.Length + (6 - imp.TasaOCuota.ToString.Substring(Posicion, imp.TasaOCuota.ToString.Length - 1).Length.ToEntero + 1), Convert.ToChar("0")), imp.Importe) + Else + CFDi.ConceptosRetencionesCfd(imp.Base, clbImp, clbTipo, imp.TasaOCuota.ToString.PadRight(imp.TasaOCuota.ToString.Length + (6 - imp.TasaOCuota.ToString.Substring(Posicion, imp.TasaOCuota.ToString.Length - 1).Length.ToEntero + 1), Convert.ToChar("0")), imp.Importe) + End If + + Next + Next + End If + + + If Not HasErrorConceptos Then + 'Nodo Impuestos, se agrega el total de impuestos + Msg = CFDi.ImpuestosCfd(Ventas.RetIVATC + Ventas.RetISRTC, Ventas.IVATC) + If Msg = String.Empty Then + + Dim HasErrorRetenciones As Boolean = False + 'Nodo Impuestos-retenciones + + + For Each Ret In ObjCFDITimbre.Retenciones + Dim clbImp As ClbNegBICFDv3_3.Impuesto = If(Ret.Impuesto = "002", ClbNegBICFDv3_3.Impuesto.IVA, If(Ret.Impuesto = "003", ClbNegBICFDv3_3.Impuesto.IEPS, ClbNegBICFDv3_3.Impuesto.ISR)) + Msg = CFDi.ImpuestosRetencionesCfd(clbImp, Ret.Importe.ToDecimal) + Next + + If Not HasErrorRetenciones Then + + 'Nodo Impuestos-traslado + Dim HasErrorIVA As Boolean = False + ''se acumulan los importes + For Each Tras In ObjCFDITimbre.Traslados + Dim Posicion As Integer = Tras.TasaOCuota.ToString.IndexOf(".") + Dim tipfact As ClbNegBICFDv3_3.TipoFactor = If(Tras.TipoFactor = "Tasa", ClbNegBICFDv3_3.TipoFactor.Tasa, If(Tras.TipoFactor = "Cuota", ClbNegBICFDv3_3.TipoFactor.Cuota, ClbNegBICFDv3_3.TipoFactor.Exento)) + Msg = CFDi.ImpuestosTrasladosCfd(ClbNegBICFDv3_3.Impuesto.IVA, Tras.TasaOCuota.ToString.PadRight(Tras.TasaOCuota.ToString.Length + (6 - Tras.TasaOCuota.ToString.Substring(Posicion, Tras.TasaOCuota.ToString.Length - 1).Length.ToEntero + 1), Convert.ToChar("0")), Tras.Importe, tipfact) + Next + + + If Not HasErrorIVA Then + 'Nodo Impuestos locales + 'JJMQ 20150826: Se habilitó de nueva cuenta impuestos locales + Dim HasErrorImpuestosLocales As Boolean = False + Dim TieneImpuestosLocales As Boolean = False + + + If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 Then + + For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales + If ret.Importe > 0 Then + Msg = ImpLoc.RetencionesLocales(ret.ImpuestoLocalRetenido, ret.TasaRetencion, ret.Importe) + TieneImpuestosLocales = True + End If + Next + End If + + CFDi.CompImplocal = ImpLoc + If Msg <> String.Empty Then HasErrorImpuestosLocales = True + + If Not HasErrorImpuestosLocales Then + + + + 'Agrega Adenda FEMSA + Dim HasErrorFEMSA As Boolean = False + If Ventas.Cliente.AplicaFEMSA Then + + Msg = ObjFemsa.Carga(Ventas.FemsaFactura.FEMSA_Version, Ventas.ClaseDoctoSat, Ventas.FemsaFactura.FEMSA_NumSociedad, Ventas.FemsaFactura.FEMSA_NumProveedor, Ventas.FemsaFactura.FEMSA_NumPedido, + Ventas.MonedaAbreviatura, Ventas.FemsaFactura.FEMSA_NumEntrada, Ventas.FemsaFactura.FEMSA_NumRemision, Ventas.FemsaFactura.FEMSA_NumSocio, Ventas.FemsaFactura.FEMSA_CentroCosto, + Ventas.FemsaFactura.FEMSA_IPeriodoLiquidacion, Ventas.FemsaFactura.FEMSA_FPeriodoLiquidacion, Ventas.FemsaFactura.FEMSA_CodRetencion1, Ventas.FemsaFactura.FEMSA_CodRetencion2, + Ventas.FemsaFactura.FEMSA_Mail) + If Msg <> String.Empty Then HasErrorFEMSA = True + End If + + If Not HasErrorFEMSA Then + If Ventas.Cliente.AplicaFEMSA Then Msg = CFDi.AddendaFemsa(ObjFemsa) + If Msg = String.Empty Then + 'Agrega Complemento Detallista + Dim HasErrorDetallista As Boolean = False + If Ventas.Cliente.AplicaDetallista Then + 'Desarrollar Detallista + If Msg <> String.Empty Then HasErrorDetallista = True + '1 + Msg = ObjDetallista._1_1R_requestForPaymentIdentification(ClbNegBICFDv3_3.CompDetEntityType.INVOICE) + If Msg <> String.Empty Then HasErrorDetallista = True + '2 + Dim LstInstruccionComercial As New List(Of String) + LstInstruccionComercial.Add(Ventas.TotalTC.ToString.ToDouble.Texto2Letras.ToUpper) + Msg = ObjDetallista._2_1O_SpecialInstruction(ClbNegBICFDv3_3.CompDetCode.ZZZ, LstInstruccionComercial) + If Msg <> String.Empty Then HasErrorDetallista = True + '3 + Msg = ObjDetallista._3_1R_OrderIdentification_ReferenceIdentification("ON", Ventas.Det_OrdenCompra) + If Msg <> String.Empty Then HasErrorDetallista = True + Msg = ObjDetallista._3_2O_OrderIdentification_ReferenceDate(Ventas.Det_FechaOrdenCompra.ToDate) + If Msg <> String.Empty Then HasErrorDetallista = True + '4 + Msg = ObjDetallista._4_1R_AdditionalInformation_ReferenceIdentification("DQ", Ventas.Det_ContraRecibo) + If Msg <> String.Empty Then HasErrorDetallista = True + '5 + Msg = ObjDetallista._5_1R_DeliveryNote_ReferenceIdentification(Ventas.Det_ContraRecibo) + If Msg <> String.Empty Then HasErrorDetallista = True + Msg = ObjDetallista._5_2O_DeliveryNote_ReferenceDate(Ventas.Det_FechaOrdenCompra.ToDate) + If Msg <> String.Empty Then HasErrorDetallista = True + '6 + Msg = ObjDetallista._6_1R_Buyer(Ventas.Cliente.Detallista_GLNComprador, Ventas.Cliente.Detallista_Departamento) + If Msg <> String.Empty Then HasErrorDetallista = True + '7 + Msg = ObjDetallista._7_1R_Seller(Ventas.Cliente.Detallista_GLNVendedor, "SELLER_ASSIGNED_IDENTIFIER_FOR_A_PARTY", Ventas.Cliente.Detallista_NumProveedor) + If Msg <> String.Empty Then HasErrorDetallista = True + '8 + Msg = ObjDetallista._8_1O_AllowanceCharge(ClbNegBICFDv3_3.CompDetNetAllowanceChargeType.ALLOWANCE_GLOBAL, + ClbNegBICFDv3_3.CompDetNetSettlementType.OFF_INVOICE, + "0", + ClbNegBICFDv3_3.CompDetNetSpecialServicesType.AJ, + ClbNegBICFDv3_3.CompDetNetMonetaryAmountOrPercentageBase.INVOICE_VALUE, + If(Ventas.DescuentoTC > 0 AndAlso Ventas.SubTotalTC > 0, (Ventas.DescuentoTC * 100) / Ventas.SubTotalTC, 0)) + If Msg <> String.Empty Then HasErrorDetallista = True + '9 + Dim LineNumber As Integer = 1 + If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then + For Each Row As DataRow In Ventas.DtDetalle.Rows + Dim PS As String = If(Row("PS").ToString.Length = 1, Row("Obs").ToString, If(Row("PS").ToString.Length = 0, "", Row("PS").ToString & " ") & Row("Obs").ToString & If(Row("Obs").ToString.Trim.Length > 0, vbLf, "")) & vbLf + Msg = ObjDetallista._9_1R_LineItem("SimpleInvoidLineItemType", + LineNumber, + Row("Codigo").ToString, + ClbNegBICFDv3_3.CompDetAlternateTradeItemIdentification.SUPPLIER_ASSIGNED, + Row("Codigo").ToString, + ClbNegBICFDv3_3.CompDetNetLanguage.ES, + If((Row("Codigo").ToString & If(Row("Codigo").ToString.Length > 0, "-", "") & PS).Length > 35, (Row("Codigo").ToString & If(Row("Codigo").ToString.Length > 0, "-", "") & PS).Substring(0, 34), (Row("Codigo").ToString & If(Row("Codigo").ToString.Length > 0, "-", "") & PS)), + If(Row("UM").ToString.ToLower = "no aplica", "NA", Row("UM").ToString), + Row("Cantidad").ToString, + Row("PU").ToString.ToDecimal, + Row("PU").ToString.ToDecimal * (1 + Row("IVA").ToString.ToDecimal), + Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, + (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) * (1 + Row("IVA").ToString.ToDecimal)) + LineNumber = LineNumber + 1 + Next + End If + If Msg <> String.Empty Then HasErrorDetallista = True + '10 + Msg = ObjDetallista._10_1R_TotalAmount(Ventas.SubTotalTC) + If Msg <> String.Empty Then HasErrorDetallista = True + '11 + Msg = ObjDetallista._11_1R_TotalAllowanceCharge(ClbNegBICFDv3_3.CompDetNetAllowanceOrChargeType.ALLOWANCE, + ClbNegBICFDv3_3.CompDetNetSpecialServicesType.AA, + Ventas.DescuentoTC) + If Msg <> String.Empty Then HasErrorDetallista = True + End If + If Not HasErrorDetallista Then + If Ventas.Cliente.AplicaDetallista Then Msg = CFDi.ClomplementoDetallistaCfd(ObjDetallista) + If Msg <> String.Empty Then HasErrorDetallista = True + 'Timbrar + + 'Web Services de producción: http://biinform.com.mx/srvCFDi/service1.asmx + 'Web Services de pruebasd: http://biinform.com.mx/srvCFDiPrueba/service1.asmx + + + + + If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "XML\") Then System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "XML\") + If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "XML\" & Ventas.TipoDocto) Then System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "XML\" & Ventas.TipoDocto) + + 'GENERAR TIMBRE + CFDi.Generar(ArchivoPFX, + UsuarioActual.Empresa.ContraseñaKey, + ArchivoCertificado, + $"{RutaArchivo }{NombreArchivoXML}.xml", + UsuarioActual.Empresa.Ruta & "Certificados\", + UsuarioServicio, + ClaveServicio, + UrlServicio, + True) + + + If CFDi.MsgError <> String.Empty Then + OnError($"Ocurrió un error al generar el timbre, el mensaje del SAT fue: {CFDi.MsgError}. Emp:{UsuarioActual.CveEmpresa}. MetPag: {Ventas.ClaveMetodoPagoSAT}", New Exception(CFDi.MsgError)) + Retorno = $"Ocurrió un error al generar el timbre, el mensaje del SAT fue: {CFDi.MsgError}. Emp:{UsuarioActual.CveEmpresa}. MetPag: {Ventas.ClaveMetodoPagoSAT}" + Else + Dim CBB As New ClbNegBICFDv3_3.ClsNegCBBGenerar() + Dim FechaCertificacion As DateTime + Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String + + FolioFiscal = CFDi.Timbrado.UUDI 'XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText + NoSerieCertificado = CFDi.Timbrado.NoCertificadoSAT + FechaCertificacion = CFDi.Timbrado.FechaTimbrado + SelloCFDi = CFDi.Timbrado.SelloCFD + SelloSAT = CFDi.Timbrado.SelloSAT + NoSerieCertificadoContribuyente = CFDi.Timbrado.NoCertificado + + + Dim ObjVentas As New ClsVentas() + If Not ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=1) Then + Retorno = "No se pudo registrar el folio fiscal" + End If + ObjVentas.Dispose() + + + ''Actualiza Cliente (NumeroCuenta) + 'If Not UsuarioActual.CveEmpresa.Contiene(72, 80) Then + ' Dim Hilo2 As New System.Threading.Thread(Sub() ActualizaCliente(UsuarioActual.CveUsuario, Ventas.Cliente.NumCtaPago, Ventas.CveMetodoPago, Ventas.CveCliente)) + ' Hilo2.Start() + 'End If + + + Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Ventas.Cliente.RFC, Ventas.TotalTC, FolioFiscal, RutaCBB) + + ''Genero la addenda de 7-Eleven + 'If sevenElevenNumProveedor <> "" AndAlso sevenElevenFolio <> "" AndAlso sevenElevenTienda <> "" AndAlso sevenElevenFecha <> "" AndAlso sevenElevenFecha <> "__/__/____" Then + ' Dim RutaCadena As String = $"{Ruta}XML\{Ventas.TipoDocto}\{Ventas.SerieFolio}.xml" '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)) + + ' GeneraAddenda7Eleven(RutaCadena, TmpDTConceptos, TmpDT7Eleven) + 'End If + + '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 + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Complemento Detallista" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Complemento Detallista", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AddendaFemsa" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AddendaFemsa", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AddendaFemsa" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: AdendaFEMSA", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: RetencionesLocales" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: RetencionesLocales", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosTrasladoCfd" + Me.OnError("El SAT regresó el siguieente mensaje: " & Msg & ". Objeto: ImpuestosTrasladoCfd", New Exception) + End If + + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosRetencionesCfd " + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosRetencionesCfd ", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosCfd" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ImpuestosCfd", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ConceptosCfd" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ConceptosCfd", New Exception) + End If + + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ReceptorCfd" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: ReceptorCfd", New Exception) + End If + + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: EmisorCfd" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: EmisorCfd", New Exception) + End If + Else + Retorno = "El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Comprobante" + Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Comprobante", New Exception) + End If + MensajeErrorCFDI = Retorno + Return Retorno + End Function + Public Function TimbrarFacturaRealVirtualv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String + 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(UsuarioActual.Empresa.CvePAC = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") + Dim ClaveServicio As String = If(UsuarioActual.Empresa.CvePAC = 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 UsuarioActual.Empresa.CvePAC + Case 2 + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" + Case 4 + UrlServicio = "http://192.168.0.2:8080/ADSistemas/Timbrado.asmx?WSDL" + 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 UsuarioActual.Empresa.CvePAC + 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://192.168.0.2:8080/ADSistemas/Timbrado.asmx?WSDLL" + End Select + End If + +#Region "Valida" + If Not File.Exists(ArchivoCertificado) Then + Alert("El archivo de certificado no existe", TipoMensaje.MsgError) + Return "" + End If + If Not File.Exists(ArchivoLLave) Then + Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) + Return "" + End If + If UsuarioActual.Empresa.ContraseñaKey = "" Then + Alert("La clave no puede ser vacía", TipoMensaje.MsgError) + Return "" + End If +#End Region + +#Region "Variables" + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String, certBase64 As String + Dim cfdi As New RVCFDI33.GeneraCFDI() + 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 "" + 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 "" + + 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.agregarCertificado(ArchivoCertificado) +#End Region + + +#Region "Comprobante" + + cfdi.agregarComprobante33( + 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.agregarCfdiRelacionados(ObjCFDITimbre.CFDIRelacionados.TipoRelacion) + For Each uid As String In ObjCFDITimbre.CFDIRelacionados.UUID + cfdi.agregarCfdiRelacionado(uid) + Next + End If +#Region "Emisor" + ' cfdi.agregarCfdiRelacionados() + cfdi.agregarEmisor(EmisorRFC, UsuarioActual.Empresa.Empresa, UsuarioActual.Empresa.CodigoRegimenFiscal) + +#End Region + +#Region "Receptor" + + cfdi.agregarReceptor(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.agregarConcepto(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.agregarImpuestoConceptoTraslado(imp.Base, imp.Impuesto, imp.TipoFactor, imp.TasaOCuota, imp.Importe) + Else + cfdi.agregarImpuestoConceptoRetenido(imp.Base, imp.Impuesto, imp.TipoFactor, imp.TasaOCuota, imp.Importe) + End If + Next + If concep.CuentaPredial <> "" Then cfdi.agregarCuentaPredial(concep.CuentaPredial) + Next + End If + +#End Region + + If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then + +#Region "Impuestos" + + cfdi.agregarImpuestos(ObjCFDITimbre.TotalImpuestosRetenidos, ObjCFDITimbre.TotalImpuestosTrasladados) + +#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.agregarRetencion(Ret.Impuesto, Ret.Importe) + Next + End If + + ''se acumulan los importes + For Each Tras In ObjCFDITimbre.Traslados + cfdi.agregarTraslado(Tras.Impuesto, Tras.TipoFactor, Tras.TasaOCuota, Tras.Importe) + Next +#End Region + +#Region "Impuestos Locales" + + If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 Then + cfdi.agregarImpuestosLocales("1.0", ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe), 0) + For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales + If ret.Importe > 0 Then + cfdi.agregarRetencionesLocales(ret.ImpuestoLocalRetenido, ret.TasaRetencion, ret.Importe) + End If + Next + End If + + If Ventas.CveComplementoTimbrado > 0 Then + + Select Case Ventas.CveComplementoTimbrado + Case 5 'INE Proceso Ordinario Directivo Estatal" + cfdi.agregarIne11("Ordinario", "Directivo Estatal", "0") + + cfdi.agregarEntidad(Ventas.ComplementoINE.INEEntidad, "") + cfdi.agregarIneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) + Case 6 'INE Proceso Ordinario Ejecutivo Estatal" + cfdi.agregarIne11("Ordinario", "Ejecutivo Estatal", "0") + + cfdi.agregarEntidad(Ventas.ComplementoINE.INEEntidad, "") + cfdi.agregarIneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) + Case 7 'INE Proceso Ordinario Ejecutivo Nacional" + + cfdi.agregarIne11("Ordinario", "Ejecutivo Nacional", Ventas.ComplementoINE.INEIdContabilidad.ToString) + Case 8 'INE PreCampaña + cfdi.agregarIne11(Ventas.ComplementoINE.INETipoProceso, "", "0") + + cfdi.agregarEntidad(Ventas.ComplementoINE.INEEntidad, Ventas.ComplementoINE.INETipoComite) + cfdi.agregarIneContabilidad(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.agregarComercioExterior11(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.agregarComercioExterior11Emisor(If(EmisorRFC.Length >= 12, "", ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CURP)) + cfdi.agregarComercioExterior11Domicilio(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.agregarComercioExterior11Receptor(ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib) + cfdi.agregarComercioExterior11DomicilioReceptor(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.agregarComercioExterior11Destinatario(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.agregarComercioExterior11Mercancia(concep.NoIdentificacion, concep.FraccionArancelaria, concep.CantidadAduana, concep.UnidadAduana, concep.ValorUnitarioAduana, concep.ValorDolares) + If concep.DescripcionesEspecificas.Marca <> "" Then + cfdi.agregarComercioExterior11MercanciaDescripcionesEspeciales(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.agregarPago10(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.agregarPago10DoctoRelacionado(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.agregarPago10Impuestos(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.agregarPago10Retencion(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.agregarPago10Traslado(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.agregarNomina12(ObjCFDITimbre.Nomina.Version, ObjCFDITimbre.Nomina.TipoNomina, ObjCFDITimbre.Nomina.FechaPago.ToString, ObjCFDITimbre.Nomina.FechaInicio, ObjCFDITimbre.Nomina.FechaFin, ObjCFDITimbre.Nomina.NumDiasPagados.ToString, If(ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0, ObjCFDITimbre.Nomina.TotalPercepciones.ToString, ""), If(ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0, ObjCFDITimbre.Nomina.TotalDeducciones.ToString, ""), If(ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0, ObjCFDITimbre.Nomina.TotalOtrosPagos.ToString, "")) + + cfdi.agregarNominaEmisor12(ObjCFDITimbre.Emisor.CURP, If(ObjCFDITimbre.Nomina.Receptor.TipoContrato = "99", "", ObjCFDITimbre.Emisor.RegistroPatronal), ObjCFDITimbre.Emisor.RFC) + + If UsuarioActual.Empresa.UsaAC Then cfdi.agregarNominaEmisorEntidadSNCF12("IF", "90") + + If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then + Dim TotalIndemnizacion As String = If(ObjCFDITimbre.Nomina.TotalIndemnizacion > 0, ObjCFDITimbre.Nomina.TotalIndemnizacion.ToString, "") + Dim TotalJubilacion As String = If(ObjCFDITimbre.Nomina.TotalJubilacion > 0, ObjCFDITimbre.Nomina.TotalJubilacion.ToString, "") + cfdi.agregarNominaPercepciones12(ObjCFDITimbre.Nomina.TotalSueldos.ToString, TotalIndemnizacion, TotalJubilacion, ObjCFDITimbre.Nomina.TotalPercepcionesGravado.ToString, ObjCFDITimbre.Nomina.TotalPercepcionesExento.ToString) + For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones + cfdi.agregarNominaPercepcionesPercepcion12(percep.TipoPercepcion, percep.Clave, percep.Concepto, Math.Round(percep.ImporteGravado, 2).ToString, Math.Round(percep.ImporteExento, 2).ToString) + Next + End If + 'cfdi.agregarNominaReceptorSubContratacion12("AAD990814BP6", "50") + 'cfdi.agregarNominaPercepcionesPercepcionAccionesOTitulos12("100", "200"); + 'cfdi.agregarNominaPercepcionesSeparacionIndemnizacion12("100", "10", "1000", "100", "50"); + 'cfdi.agregarNominaPercepcionesJubilacionPensionRetiro12("50", "100", "10", "100", "0"); + + If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then + For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras + cfdi.agregarNominaPercepcionesPercepcionHorasExtra12(HoraExtra.Dias, HoraExtra.TipoHoras, HoraExtra.HorasExtra.ToString, HoraExtra.ImportePagado.ToString) + 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.agregarNominaIncapacidadesIncapacidad12(Incap.DiasIncapacidad, Incap.TipoIncapacidad, Incap.Importe.ToString) + Next + End If + + If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then + cfdi.agregarNominaDeducciones12(If(Not ObjCFDITimbre.Nomina.TotalDeduccionesOtras.ToString.ToDecimal > 0, "", ObjCFDITimbre.Nomina.TotalDeduccionesOtras.ToString), If(Not ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos.ToString.ToDecimal > 0, "", Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2).ToString)) + For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones + cfdi.agregarNominaDeduccionesDeduccion12(deduc.TipoDeduccion, deduc.Clave, deduc.Concepto, Math.Round(deduc.Importe, 2).ToString) + 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.agregarNominaOtrosPagosOtroPago12(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe.ToString) + If otpag.TipoOtroPago = "002" Then + cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12(otpag.Importe.ToString) + End If + + Next + End If + End If + + +#Region "Receptor" + + cfdi.agregarNominaReceptor12(ObjCFDITimbre.Nomina.Receptor.CURP, + ObjCFDITimbre.Nomina.Receptor.NSS, + ObjCFDITimbre.Nomina.Receptor.FechaInicioContrato, + 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.ToString, + ObjCFDITimbre.Nomina.Receptor.SDI.ToString, + ObjCFDITimbre.Nomina.Receptor.CodigoEntidadFederativa) + + + End If +#End Region + +#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.GenerarXMLBase64(llaveBase64, Clave) + cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) + ArchivoGenerado = True + Catch ex As Exception + Retorno = cfdi.MensajeError + MensajeErrorCFDI = cfdi.MensajeError + End Try + +#End Region + sw.Stop() + swTiempo.AppendFormat("Guardado: ({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 FechaCertificacion As DateTime + 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 + + File.WriteAllText(String.Format("{0}{1}.xml", RutaArchivo, NombreArchivoXML), cfdi.XmlTimbrado, System.Text.UTF8Encoding.UTF8) + + + If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then + + 'Actualiza Estatus Factura + If Ventas.CveVenta > 0 Then + + Dim ObjVentas As New ClsVentas() + If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=UsuarioActual.Empresa.CvePAC) Then + Retorno = "" + Else + Retorno = "Error" + End If + ObjVentas.Dispose() + + + ''Actualiza Cliente (NumeroCuenta) + 'If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then + ' Dim Hilo2 As New System.Threading.Thread(Sub() ActualizaCliente(UsuarioActual.CveUsuario, Ventas.Cliente.NumCtaPago, Ventas.CveMetodoPago, Ventas.CveCliente)) + ' Hilo2.Start() + 'End If + + '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, UsuarioActual.Empresa.CvePAC, 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\") + + Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" + Dim b As Byte() = cfdi.ConvertirQrCode($"?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={FolioFiscal}") + File.WriteAllBytes(RutaCBB, b) + + 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 + End If + End If + + GuardaLogTimbrado(swTiempo.ToString, UsuarioActual.Empresa.CvePAC) +#End Region + 'GC.Collect() + Return Retorno + End Function + Public Function TimbrarFacturaGoCFDIv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String + 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(UsuarioActual.Empresa.CvePAC = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") + Dim ClaveServicio As String = If(UsuarioActual.Empresa.CvePAC = 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 UsuarioActual.Empresa.CvePAC + Case 2 + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" + Case 4 + UrlServicio = "http://juancalderon-001-site1.ftempurl.com/timbrado.asmx?WSDL" + 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 UsuarioActual.Empresa.CvePAC + 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) + Next + End If + +#End Region + + If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then + +#Region "Impuestos" + + cfdi.Impuestos(ObjCFDITimbre.TotalImpuestosRetenidos, ObjCFDITimbre.TotalImpuestosTrasladados) + +#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.Importe) + 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:=UsuarioActual.Empresa.CvePAC) 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, UsuarioActual.Empresa.CvePAC, 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, UsuarioActual.Empresa.CvePAC) + Return Retorno + End Function + Public Sub GuardaLogTimbrado(Str As String, CvePAC As Integer) + Dim ArchivoW As StreamWriter + Dim strLineaTMP As String + + ' strLineaTMP = Chr(13) & Chr(10) & Day(Now) & "/" & Month(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minuto & ". " & Str & Chr(13) & Chr(10) + strLineaTMP = String.Format("{0}{1} .. PAC: {2} - {3} ..{4}:{5}", Chr(13), Chr(10), CvePAC, Str, DateTime.Now.ToShortDateString, DateTime.Now.ToShortTimeString) + Try + ArchivoW = New StreamWriter(String.Format("{0}\LogTimbrado.txt", AppDomain.CurrentDomain.BaseDirectory), True, System.Text.Encoding.UTF8) + Catch ex As UnauthorizedAccessException + 'Alert("No hay permisos para guardar en el Log.", Extensiones.TipoMensaje.MsgError) + Exit Sub + Catch ex As Exception + Exit Sub + End Try + + Try + ArchivoW.WriteLine(strLineaTMP) + Catch + End Try + + ArchivoW.Close() + ArchivoW.Dispose() + End Sub + Public Function TimbrarFacturaProFactv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String + Dim sw As New Diagnostics.Stopwatch + Dim swTiempo As New StringBuilder + Dim swmili As Long = 0 + sw.Start() + + Dim Retorno As String = "" + Dim ObjCFDITimbre As CFDITimbre = Ventas.Timbre + ' 'Sucursal matriz de la empresa + Dim ArchivoLLave As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoCer}" + Dim UsuarioServicio As String = UsuarioActual.Empresa.RFC + Dim ClaveServicio As String = UsuarioActual.Empresa.RFC.ToLower + Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey + Dim EmisorRFC As String = UsuarioActual.Empresa.RFC + Dim UrlServicio As String = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" ' Produccion + Dim RutaArchivo As String = $"{UsuarioActual.Empresa.Ruta}XML\{Ventas.TipoDocto}\" + Dim NombreArchivoXML As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}" + Dim SubTotal As Decimal = 0 + Dim AmbienteProductivo As Boolean = True + If Not Directory.Exists(RutaArchivo) Then Directory.CreateDirectory(RutaArchivo) + + If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then + AmbienteProductivo = False + UsuarioServicio = "fgomez" + ClaveServicio = "12121212" + Clave = "12345678a" + EmisorRFC = "AAA010101AAA" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" '"http://108.60.211.43/rvltimbrado/service1.asmx" + End If + + +#Region "Valida" + If Not File.Exists(ArchivoCertificado) Then + Alert("El archivo de certificado no existe", TipoMensaje.MsgError) + Return "" + End If + If Not File.Exists(ArchivoLLave) Then + Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) + Return "" + End If + If UsuarioActual.Empresa.ContraseñaKey = "" Then + Alert("La clave no puede ser vacía", TipoMensaje.MsgError) + Return "" + End If +#End Region + +#Region "Variables" + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String, certBase64 As String + + Dim complemento As String = "" + Dim complementoConcepto As String = "" + '//Inicializamos el conector el parámetro indica el ambiente en el que se utilizará + '//Fasle = Ambiente de pruebas + '//True = Ambiente de producción + Dim cfdi As New Profact.TimbraCFDI33.Conector(AmbienteProductivo) + Dim comprobante As New Profact.TimbraCFDI33.Comprobante() + + If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then + cfdi.EstableceCredenciales("mvpNUXmQfK8=") + Else + cfdi.EstableceCredenciales($"vSGxMFWnNRy/nDoowxqrqw==|Sia123654") + End If + +#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 "" + 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 "" + + End Try + sw.Stop() + swTiempo.AppendFormat("Verificado : ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() +#End Region + + +#Region "Comprobante" + + + If ObjCFDITimbre.Comprobante.Serie <> "" Then comprobante.Serie = ObjCFDITimbre.Comprobante.Serie + comprobante.Folio = ObjCFDITimbre.Comprobante.Folio + comprobante.Version = "3.3" + comprobante.Fecha = ObjCFDITimbre.Comprobante.Fecha + comprobante.FormaPago = ObjCFDITimbre.Comprobante.FormadePago + If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then comprobante.CondicionesDePago = ObjCFDITimbre.Comprobante.CondicionesdePago + + comprobante.SubTotal = ObjCFDITimbre.Comprobante.Subtotal + If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then + comprobante.DescuentoSpecified = True + comprobante.Descuento = ObjCFDITimbre.Comprobante.Descuentos + End If + comprobante.Moneda = ObjCFDITimbre.Comprobante.Moneda + comprobante.TipoCambio = ObjCFDITimbre.Comprobante.TipoCambio.ToDecimal + comprobante.TipoCambioSpecified = If(ObjCFDITimbre.Comprobante.Moneda <> "XXX", True, False) + comprobante.Total = ObjCFDITimbre.Comprobante.Total + comprobante.TipoDeComprobante = ObjCFDITimbre.Comprobante.TipoComprobante + comprobante.FormaPagoSpecified = If(ObjCFDITimbre.Comprobante.FormadePago <> "", True, False) + comprobante.MetodoPago = ObjCFDITimbre.Comprobante.MetodoPago + comprobante.MetodoPagoSpecified = If(ObjCFDITimbre.Comprobante.MetodoPago <> "", True, False) + comprobante.LugarExpedicion = ObjCFDITimbre.Comprobante.LugarExpedicion + +#Region "Emisor" + comprobante.Emisor = New Profact.TimbraCFDI33.ComprobanteEmisor() + comprobante.Emisor.Rfc = EmisorRFC + comprobante.Emisor.Nombre = UsuarioActual.Empresa.Empresa + comprobante.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal + +#End Region + +#Region "Receptor" + comprobante.Receptor = New Profact.TimbraCFDI33.ComprobanteReceptor() + comprobante.Receptor.Rfc = ObjCFDITimbre.Receptor.RFC + comprobante.Receptor.Nombre = ObjCFDITimbre.Receptor.Nombre + comprobante.Receptor.UsoCFDI = ObjCFDITimbre.Receptor.UsoCFDI + +#End Region + +#End Region + +#Region "Conceptos" + + 'Nodo conceptos, se agregan los PS + comprobante.Conceptos = New Profact.TimbraCFDI33.ComprobanteConcepto(ObjCFDITimbre.Conceptos.Count - 1) {} + + If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then + Dim i As Integer = 0 + Dim j As Integer = 0 + Dim k As Integer = 0 + For Each concep As CFDIConceptos In ObjCFDITimbre.Conceptos + comprobante.Conceptos(i) = New Profact.TimbraCFDI33.ComprobanteConcepto() + comprobante.Conceptos(i).Cantidad = concep.Cantidad + + If concep.Unidad <> "" Then comprobante.Conceptos(i).Unidad = concep.Unidad + comprobante.Conceptos(i).ClaveUnidad = concep.ClaveUnidad + comprobante.Conceptos(i).Descripcion = concep.Descripcion + comprobante.Conceptos(i).ValorUnitario = concep.ValorUnitario + comprobante.Conceptos(i).Importe = concep.Importe + comprobante.Conceptos(i).ClaveProdServ = concep.ClaveProdServ + + If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then + comprobante.Conceptos(i).Descuento = concep.Descuento + comprobante.Conceptos(i).DescuentoSpecified = True + End If + + If concep.Noidentificacion <> "" Then comprobante.Conceptos(i).NoIdentificacion = concep.Noidentificacion + + j = 0 + k = 0 + If Not ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("P", "N") Then + comprobante.Conceptos(i).Impuestos = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestos() + comprobante.Conceptos(i).Impuestos.Traslados = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosTraslado(concep.Impuestos.FindAll(Function(p As CFDIConceptosImpuestos) p.TrasladooRetencion = "T").Count - 1) {} + If concep.Impuestos.FindAll(Function(p As CFDIConceptosImpuestos) p.TrasladooRetencion <> "T").Count > 0 Then + comprobante.Conceptos(i).Impuestos.Retenciones = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosRetencion(concep.Impuestos.FindAll(Function(p As CFDIConceptosImpuestos) p.TrasladooRetencion <> "T").Count - 1) {} + + End If + For Each imp As CFDIConceptosImpuestos In concep.Impuestos + If imp.TrasladooRetencion = "T" Then + comprobante.Conceptos(i).Impuestos.Traslados(j) = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosTraslado() + comprobante.Conceptos(i).Impuestos.Traslados(j).Base = imp.Base + comprobante.Conceptos(i).Impuestos.Traslados(j).Impuesto = imp.Impuesto + comprobante.Conceptos(i).Impuestos.Traslados(j).TipoFactor = imp.TipoFactor + comprobante.Conceptos(i).Impuestos.Traslados(j).Importe = imp.Importe + comprobante.Conceptos(i).Impuestos.Traslados(j).ImporteSpecified = True + comprobante.Conceptos(i).Impuestos.Traslados(j).TasaOCuota = imp.TasaOCuota.FormatoNumero(6) + comprobante.Conceptos(i).Impuestos.Traslados(j).TasaOCuotaSpecified = True + j += 1 + Else + comprobante.Conceptos(i).Impuestos.Retenciones(k) = New Profact.TimbraCFDI33.ComprobanteConceptoImpuestosRetencion() + comprobante.Conceptos(i).Impuestos.Retenciones(k).Base = imp.Base + comprobante.Conceptos(i).Impuestos.Retenciones(k).Impuesto = imp.Impuesto + comprobante.Conceptos(i).Impuestos.Retenciones(k).TipoFactor = imp.TipoFactor + comprobante.Conceptos(i).Impuestos.Retenciones(k).Importe = imp.Importe + comprobante.Conceptos(i).Impuestos.Retenciones(k).TasaOCuota = imp.TasaOCuota.ToString.ToDecimal + k += 1 + End If + Next + End If + i += 1 + Next + End If + +#End Region + + + Dim LXmlComplementos As New List(Of XmlElement)() + Dim TieneComplemento As Boolean = False + + If ObjCFDITimbre.Comprobante.TipoComprobante.Contiene("I", "E") Then + +#Region "Impuestos" + + + comprobante.Impuestos = New Profact.TimbraCFDI33.ComprobanteImpuestos() + comprobante.Impuestos.Traslados = New Profact.TimbraCFDI33.ComprobanteImpuestosTraslado(ObjCFDITimbre.Traslados.Count - 1) {} + + Dim y As Integer = 0 + + For Each Tras In ObjCFDITimbre.Traslados + comprobante.Impuestos.Traslados(y) = New Profact.TimbraCFDI33.ComprobanteImpuestosTraslado() + comprobante.Impuestos.Traslados(y).Impuesto = Tras.Impuesto + comprobante.Impuestos.Traslados(y).TipoFactor = Tras.TipoFactor + comprobante.Impuestos.Traslados(y).TasaOCuota = Tras.TasaOCuota.FormatoNumero(6) + comprobante.Impuestos.Traslados(y).Importe = Tras.Importe + y += 1 + Next + + comprobante.Impuestos.TotalImpuestosTrasladados = ObjCFDITimbre.TotalImpuestosTrasladados + comprobante.Impuestos.TotalImpuestosTrasladadosSpecified = True + + If ObjCFDITimbre.TotalImpuestosRetenidos > 0 Then + comprobante.Impuestos.Retenciones = New Profact.TimbraCFDI33.ComprobanteImpuestosRetencion(ObjCFDITimbre.Retenciones.Count - 1) {} + + Dim w As Integer = 0 + + For Each Ret In ObjCFDITimbre.Retenciones + comprobante.Impuestos.Retenciones(w) = New Profact.TimbraCFDI33.ComprobanteImpuestosRetencion() + comprobante.Impuestos.Retenciones(w).Impuesto = Ret.Impuesto + comprobante.Impuestos.Retenciones(w).Importe = Ret.Importe.ToDecimal + w += 1 + Next + + comprobante.Impuestos.TotalImpuestosRetenidos = ObjCFDITimbre.TotalImpuestosRetenidos + comprobante.Impuestos.TotalImpuestosRetenidosSpecified = True + End If + + + +#End Region + + +#Region "Impuestos Locales" + + + If ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe) > 0 Then + Dim Imp = New Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocales() + Imp.version = "1.0" + Imp.TotaldeRetenciones = ObjCFDITimbre.RetencionesLocales.Sum(Function(x) x.Importe).FormatoNumero().ToDecimal + Imp.TotaldeTraslados = 0 + Imp.RetencionesLocales = New Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocalesRetencionesLocales(ObjCFDITimbre.RetencionesLocales.Count - 1) {} + Dim i As Integer = 0 + For Each ret As CFDIRetencionesLocales In ObjCFDITimbre.RetencionesLocales + If ret.Importe > 0 Then + Imp.RetencionesLocales(i) = New Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocalesRetencionesLocales() + Imp.RetencionesLocales(i).ImpLocRetenido = ret.ImpuestoLocalRetenido + Imp.RetencionesLocales(i).TasadeRetencion = ret.TasaRetencion.FormatoNumero().ToDecimal + Imp.RetencionesLocales(i).Importe = ret.Importe.FormatoNumero().ToDecimal + i += 1 + End If + Next + + Dim nsImpLocal As New System.Xml.Serialization.XmlSerializerNamespaces() + nsImpLocal.Add("implocal", "http://www.sat.gob.mx/implocal") + Dim xmlImpLocal As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(Imp, GetType(Profact.TimbraCFDI.Complementos.ImpuestoLocal.ImpuestosLocales), nsImpLocal) + Dim docImpLocal As New XmlDocument() + docImpLocal.LoadXml(xmlImpLocal) + LXmlComplementos.Add(docImpLocal.DocumentElement) + comprobante.ImpLocalSpecified = True + TieneComplemento = True + 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 + Dim ComExt = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExterior() + ComExt.Version = "1.1" + ComExt.MotivoTrasladoSpecified = True + ComExt.MotivoTraslado = ObjCFDITimbre.Complementos.ComercioExterior11.MotivoTraslado + ComExt.TipoOperacion = ObjCFDITimbre.Complementos.ComercioExterior11.TipoOperacion + ComExt.ClaveDePedimentoSpecified = True + ComExt.ClaveDePedimento = ObjCFDITimbre.Complementos.ComercioExterior11.ClavedePedimento + ComExt.CertificadoOrigenSpecified = True + ComExt.CertificadoOrigen = ObjCFDITimbre.Complementos.ComercioExterior11.CertificadoOrigen.ToEntero + If ObjCFDITimbre.Complementos.ComercioExterior11.NumCertificadoOrigen <> "" Then + ComExt.NumCertificadoOrigen = ObjCFDITimbre.Complementos.ComercioExterior11.NumCertificadoOrigen + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.NumeroExportadorConfiable <> "" Then + ComExt.NumeroExportadorConfiable = ObjCFDITimbre.Complementos.ComercioExterior11.NumeroExportadorConfiable + End If + ComExt.IncotermSpecified = True + ComExt.Incoterm = ObjCFDITimbre.Complementos.ComercioExterior11.Incoterm + ComExt.SubdivisionSpecified = True + ComExt.Subdivision = ObjCFDITimbre.Complementos.ComercioExterior11.Subdivision.ToEntero + If ObjCFDITimbre.Complementos.ComercioExterior11.Observaciones <> "" Then + ComExt.Observaciones = ObjCFDITimbre.Complementos.ComercioExterior11.Observaciones + End If + ComExt.TipoCambioUSDSpecified = True + ComExt.TipoCambioUSD = ObjCFDITimbre.Complementos.ComercioExterior11.TipoCambioUSD + ComExt.TotalUSDSpecified = True + ComExt.TotalUSD = ObjCFDITimbre.Complementos.ComercioExterior11.TotalUSD + + 'EMISOR + ComExt.Emisor = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorEmisor() + If EmisorRFC.Length < 12 Then + ComExt.Emisor.Curp = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CURP + End If + ComExt.Emisor.Domicilio = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorEmisorDomicilio + ComExt.Emisor.Domicilio.Calle = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Calle + ComExt.Emisor.Domicilio.CodigoPostal = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.CP + ComExt.Emisor.Domicilio.ColoniaSpecified = True + ComExt.Emisor.Domicilio.Colonia = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Colonia + ComExt.Emisor.Domicilio.Estado = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Estado + If ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Localidad <> "" Then + ComExt.Emisor.Domicilio.LocalidadSpecified = False + ComExt.Emisor.Domicilio.Localidad = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Localidad + End If + ComExt.Emisor.Domicilio.MunicipioSpecified = True + ComExt.Emisor.Domicilio.Municipio = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Municipio + ComExt.Emisor.Domicilio.NumeroExterior = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.NumeroExterior + ComExt.Emisor.Domicilio.NumeroInterior = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.NumeroInterior + ComExt.Emisor.Domicilio.Pais = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Pais + If ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Referencia <> "" Then + ComExt.Emisor.Domicilio.Referencia = ObjCFDITimbre.Complementos.ComercioExterior11.Emisor.Referencia + End If + + 'RECEPTOR + ComExt.Receptor = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorReceptor + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib <> "" Then + ComExt.Receptor.NumRegIdTrib = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumRegIdTrib + End If + ComExt.Receptor.Domicilio = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorReceptorDomicilio + ComExt.Receptor.Domicilio.Calle = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Calle + ComExt.Receptor.Domicilio.CodigoPostal = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.CP + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Colonia <> "" Then + ComExt.Receptor.Domicilio.Colonia = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Colonia + End If + ComExt.Receptor.Domicilio.Estado = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Estado + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Localidad <> "" Then + ComExt.Receptor.Domicilio.Localidad = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Localidad + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Municipio <> "" Then + ComExt.Receptor.Domicilio.Municipio = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Municipio + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroExterior <> "" Then + ComExt.Receptor.Domicilio.NumeroExterior = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroExterior + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroInterior <> "" Then + ComExt.Receptor.Domicilio.NumeroInterior = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.NumeroInterior + End If + ComExt.Receptor.Domicilio.Pais = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Pais + If ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Referencia <> "" Then + ComExt.Receptor.Domicilio.Referencia = ObjCFDITimbre.Complementos.ComercioExterior11.Receptor.Referencia + End If + + 'DESTINATARIO + ComExt.Destinatario = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatario(0) {} + ComExt.Destinatario(0) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatario() + ComExt.Destinatario(0).Nombre = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Nombre + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib <> "" Then + ComExt.Destinatario(0).NumRegIdTrib = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumRegIdTrib + End If + ComExt.Destinatario(0).Domicilio = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatarioDomicilio(0) {} + ComExt.Destinatario(0).Domicilio(0) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorDestinatarioDomicilio() + ComExt.Destinatario(0).Domicilio(0).Calle = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Calle + ComExt.Destinatario(0).Domicilio(0).CodigoPostal = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.CP + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Colonia <> "" Then + ComExt.Destinatario(0).Domicilio(0).Colonia = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Colonia + End If + ComExt.Destinatario(0).Domicilio(0).Estado = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Estado + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Localidad <> "" Then + ComExt.Destinatario(0).Domicilio(0).Localidad = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Localidad + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Municipio <> "" Then + ComExt.Destinatario(0).Domicilio(0).Municipio = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Municipio + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior <> "" Then + ComExt.Destinatario(0).Domicilio(0).NumeroExterior = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroExterior + End If + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior <> "" Then + ComExt.Destinatario(0).Domicilio(0).NumeroInterior = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.NumeroInterior + End If + ComExt.Destinatario(0).Domicilio(0).Pais = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Pais + If ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Referencia <> "" Then + ComExt.Destinatario(0).Domicilio(0).Referencia = ObjCFDITimbre.Complementos.ComercioExterior11.Destinatario.Referencia + End If + + 'MERCANCIAS + If ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias IsNot Nothing AndAlso ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias.Count > 0 Then + ComExt.Mercancias = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercancia(ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias.Count - 1) {} + Dim i As Integer + For Each concep As CFDIComercioExterior11Mercancias In ObjCFDITimbre.Complementos.ComercioExterior11.Mercancias + ComExt.Mercancias(i) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercancia() + ComExt.Mercancias(i).NoIdentificacion = concep.NoIdentificacion + ComExt.Mercancias(i).FraccionArancelariaSpecified = True + ComExt.Mercancias(i).FraccionArancelaria = concep.FraccionArancelaria + ComExt.Mercancias(i).CantidadAduanaSpecified = True + ComExt.Mercancias(i).CantidadAduana = concep.CantidadAduana + ComExt.Mercancias(i).UnidadAduanaSpecified = True + ComExt.Mercancias(i).UnidadAduana = concep.UnidadAduana + ComExt.Mercancias(i).ValorUnitarioAduanaSpecified = True + ComExt.Mercancias(i).ValorUnitarioAduana = concep.ValorUnitarioAduana + ComExt.Mercancias(i).ValorDolares = concep.ValorDolares + If concep.DescripcionesEspecificas.Marca <> "" Then + ComExt.Mercancias(i).DescripcionesEspecificas = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercanciaDescripcionesEspecificas(0) {} + ComExt.Mercancias(i).DescripcionesEspecificas(0) = New Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExteriorMercanciaDescripcionesEspecificas() + If concep.DescripcionesEspecificas.Marca <> "" Then + ComExt.Mercancias(i).DescripcionesEspecificas(0).Marca = concep.DescripcionesEspecificas.Marca + End If + If concep.DescripcionesEspecificas.Modelo <> "" Then + ComExt.Mercancias(i).DescripcionesEspecificas(0).Modelo = concep.DescripcionesEspecificas.Modelo + End If + If concep.DescripcionesEspecificas.SubModelo <> "" Then + ComExt.Mercancias(i).DescripcionesEspecificas(0).SubModelo = concep.DescripcionesEspecificas.SubModelo + End If + If concep.DescripcionesEspecificas.NumeroSerie <> "" Then + ComExt.Mercancias(i).DescripcionesEspecificas(0).NumeroSerie = concep.DescripcionesEspecificas.NumeroSerie + End If + End If + i += 1 + Next + End If + Dim nsComer As New System.Xml.Serialization.XmlSerializerNamespaces() + nsComer.Add("cce11", "http://www.sat.gob.mx/ComercioExterior11") + Dim xmlComer As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(ComExt, GetType(Profact.TimbraCFDI33.Complementos.ComercioExterior11.ComercioExterior), nsComer) + Dim docComer As New XmlDocument() + docComer.LoadXml(xmlComer) + LXmlComplementos.Add(docComer.DocumentElement) + comprobante.ComercioExterior11Specified = True + TieneComplemento = True + End If + End If + +#End Region + + + + + + + End If + +#Region "Complemento Pago" + + If ObjCFDITimbre.Comprobante.TipoComprobante = "P" Then + Dim ComPag = New Profact.TimbraCFDI33.Complementos.Pagos10.Pagos() + ComPag.Pago = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPago(0) {} + ComPag.Pago(0) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPago() + ComPag.Pago(0).FechaPago = ObjCFDITimbre.ComplementoPagos.FechaPago.ToString("yyyy-MM-ddTHH:mm:ss").ToDate() + ComPag.Pago(0).FormaDePagoP = ObjCFDITimbre.ComplementoPagos.FormaDePagoP + ComPag.Pago(0).MonedaP = ObjCFDITimbre.ComplementoPagos.MonedaP + ComPag.Pago(0).TipoCadPagoSpecified = If(ObjCFDITimbre.ComplementoPagos.MonedaP = "MXN", False, True) + ComPag.Pago(0).TipoCambioP = ObjCFDITimbre.ComplementoPagos.TipoCambioP.ToDecimal + ComPag.Pago(0).Monto = ObjCFDITimbre.ComplementoPagos.Monto.ToDecimal + If ObjCFDITimbre.ComplementoPagos.NumOperacion <> "" Then + ComPag.Pago(0).NumOperacion = ObjCFDITimbre.ComplementoPagos.NumOperacion + End If + If ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaOrd <> "" Then + ComPag.Pago(0).RfcEmisorCtaOrd = ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaOrd + End If + If ObjCFDITimbre.ComplementoPagos.NomBancoOrdExt <> "" Then + ComPag.Pago(0).NomBancoOrdExt = ObjCFDITimbre.ComplementoPagos.NomBancoOrdExt + End If + If ObjCFDITimbre.ComplementoPagos.CtaOrdenante <> "" Then + ComPag.Pago(0).CtaOrdenante = ObjCFDITimbre.ComplementoPagos.CtaOrdenante + End If + If ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaBen <> "" Then + ComPag.Pago(0).RfcEmisorCtaBen = ObjCFDITimbre.ComplementoPagos.RfcEmisorCtaBen + End If + If ObjCFDITimbre.ComplementoPagos.CtaBeneficiario <> "" Then + ComPag.Pago(0).CtaBeneficiario = ObjCFDITimbre.ComplementoPagos.CtaBeneficiario + End If + ComPag.Pago(0).TipoCadPago = ObjCFDITimbre.ComplementoPagos.TipoCadPago + If ObjCFDITimbre.ComplementoPagos.CertPago <> "" Then + ComPag.Pago(0).CertPago = System.Text.Encoding.Default.GetBytes(ObjCFDITimbre.ComplementoPagos.CertPago).ToString + End If + If ObjCFDITimbre.ComplementoPagos.CadPago <> "" Then + ComPag.Pago(0).CadPago = ObjCFDITimbre.ComplementoPagos.CadPago + End If + If ObjCFDITimbre.ComplementoPagos.SelloPago <> "" Then + ComPag.Pago(0).SelloPago = System.Text.Encoding.Default.GetBytes(ObjCFDITimbre.ComplementoPagos.SelloPago).ToString + End If + + If ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados.Count > 0 Then + ComPag.Pago(0).DoctoRelacionado = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoDoctoRelacionado(ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados.Count - 1) {} + Dim i As Integer + For Each doc As CFDIComplementoPagosDocsRelacionados In ObjCFDITimbre.ComplementoPagos.DocumentosRelacionados + ComPag.Pago(0).DoctoRelacionado(i) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoDoctoRelacionado() + ComPag.Pago(0).DoctoRelacionado(i).IdDocumento = doc.IdDocumento + If Not String.IsNullOrEmpty(doc.Serie) Then + ComPag.Pago(0).DoctoRelacionado(i).Serie = doc.Serie + End If + ComPag.Pago(0).DoctoRelacionado(i).Folio = doc.Folio + ComPag.Pago(0).DoctoRelacionado(i).MonedaDR = doc.MonedaDR + ComPag.Pago(0).DoctoRelacionado(i).TipoCambioDRSpecified = If(doc.TipoCambioDR.ToDecimal = 0, False, True) + ComPag.Pago(0).DoctoRelacionado(i).TipoCambioDR = doc.TipoCambioDR.ToDecimal + ComPag.Pago(0).DoctoRelacionado(i).MetodoDePagoDR = doc.MetodoDePagoDR + ComPag.Pago(0).DoctoRelacionado(i).NumParcialidad = doc.NumParcialidad.ToString + + ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoAntSpecified = True + ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoAnt = doc.ImpSaldoAnt.ToDecimal + + ComPag.Pago(0).DoctoRelacionado(i).ImpPagadoSpecified = True + ComPag.Pago(0).DoctoRelacionado(i).ImpPagado = doc.ImpPagado.ToDecimal + + ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoInsolutoSpecified = True + ComPag.Pago(0).DoctoRelacionado(i).ImpSaldoInsoluto = doc.ImpSaldoInsoluto.ToDecimal + i += 1 + Next + + 'Estos impuestos aplicarían para anticipos + If ObjCFDITimbre.ComplementoPagos.TotalImpuestosRetenidos > 0 OrElse ObjCFDITimbre.ComplementoPagos.TotalImpuestosTrasladados > 0 Then + ComPag.Pago(0).Impuestos = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestos(0) {} + ComPag.Pago(0).Impuestos(0) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestos() + ComPag.Pago(0).Impuestos(0).TotalImpuestosRetenidosSpecified = True + ComPag.Pago(0).Impuestos(0).TotalImpuestosRetenidos = ObjCFDITimbre.ComplementoPagos.TotalImpuestosRetenidos.ToDecimal + ComPag.Pago(0).Impuestos(0).TotalImpuestosTrasladadosSpecified = True + ComPag.Pago(0).Impuestos(0).TotalImpuestosTrasladados = ObjCFDITimbre.ComplementoPagos.TotalImpuestosTrasladados.ToDecimal + + If (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "R").Count > 0 Then + Dim x As Integer + ComPag.Pago(0).Impuestos(0).Retenciones = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosRetencion((ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "R").Count - 1) {} + For Each Ret As CFDIConceptosImpuestos In (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "R") + ComPag.Pago(0).Impuestos(0).Retenciones(x) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosRetencion() + ComPag.Pago(0).Impuestos(0).Retenciones(x).Impuesto = Ret.Impuesto + ComPag.Pago(0).Impuestos(0).Retenciones(x).Importe = Ret.Importe + x += 1 + Next + End If + If (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(x) x.TrasladooRetencion = "T").Count > 0 Then + Dim x As Integer + ComPag.Pago(0).Impuestos(0).Traslados = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosTraslado((ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "T").Count - 1) {} + For Each Tra As CFDIConceptosImpuestos In (ObjCFDITimbre.ComplementoPagos.Impuestos).Where(Function(w) w.TrasladooRetencion = "T") + ComPag.Pago(0).Impuestos(0).Traslados(x) = New Profact.TimbraCFDI33.Complementos.Pagos10.PagosPagoImpuestosTraslado() + ComPag.Pago(0).Impuestos(0).Traslados(x).Impuesto = Tra.Impuesto + ComPag.Pago(0).Impuestos(0).Traslados(x).TipoFactor = Tra.TipoFactor + ComPag.Pago(0).Impuestos(0).Traslados(x).TasaOCuota = Tra.TasaOCuota.ToString + ComPag.Pago(0).Impuestos(0).Traslados(x).Importe = Tra.Importe + x += 1 + Next + End If + + End If + + + Dim nsComp As New System.Xml.Serialization.XmlSerializerNamespaces() + nsComp.Add("pago10", "http://www.sat.gob.mx/Pagos") + Dim xmlComp As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(ComPag, GetType(Profact.TimbraCFDI33.Complementos.Pagos10.Pagos), nsComp) + Dim docComp As New XmlDocument() + docComp.LoadXml(xmlComp) + comprobante.PagosSpecified = True + LXmlComplementos.Add(docComp.DocumentElement) + TieneComplemento = True + End If + + End If +#End Region + +#Region "Nomina12" + If ObjCFDITimbre.Comprobante.TipoComprobante = "N" Then + Dim Nom = New Profact.TimbraCFDI33.Complementos.Nomina12.Nomina() + 'cfdi.Esquema.AgregarEsquema("http://www.sat.gob.mx/nomina12 http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd") + Nom.Version = ObjCFDITimbre.Nomina.Version + Nom.TipoNomina = ObjCFDITimbre.Nomina.TipoNomina + Nom.FechaPago = ObjCFDITimbre.Nomina.FechaPago + Nom.FechaInicialPago = ObjCFDITimbre.Nomina.FechaInicio.ToDate + Nom.FechaFinalPago = ObjCFDITimbre.Nomina.FechaFin.ToDate + Nom.NumDiasPagados = ObjCFDITimbre.Nomina.NumDiasPagados.ToString + Nom.TotalPercepcionesSpecified = True + Nom.TotalPercepciones = ObjCFDITimbre.Nomina.TotalPercepciones.ToDecimal + Nom.TotalDeduccionesSpecified = True + Nom.TotalDeducciones = ObjCFDITimbre.Nomina.TotalDeducciones.ToDecimal + Nom.TotalOtrosPagosSpecified = True + Nom.TotalOtrosPagos = ObjCFDITimbre.Nomina.TotalOtrosPagos.ToDecimal + + Nom.Emisor = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaEmisor + Nom.Emisor.Curp = ObjCFDITimbre.Emisor.CURP + Nom.Emisor.RegistroPatronal = ObjCFDITimbre.Emisor.RegistroPatronal + Nom.Emisor.RfcPatronOrigen = ObjCFDITimbre.Emisor.RFC + + If UsuarioActual.Empresa.UsaAC Then Nom.Emisor.EntidadSNCF.OrigenRecurso = "IF" : Nom.Emisor.EntidadSNCF.MontoRecursoPropio = 90 + + If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then + Dim TotalIndemnizacion As String = If(ObjCFDITimbre.Nomina.TotalIndemnizacion > 0, ObjCFDITimbre.Nomina.TotalIndemnizacion.ToString, "") + Dim TotalJubilacion As String = If(ObjCFDITimbre.Nomina.TotalJubilacion > 0, ObjCFDITimbre.Nomina.TotalJubilacion.ToString, "") + Nom.Percepciones = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepciones + Nom.Percepciones.TotalSueldosSpecified = True + Nom.Percepciones.TotalSueldos = ObjCFDITimbre.Nomina.TotalSueldos.ToDecimal + Nom.Percepciones.TotalSeparacionIndemnizacionSpecified = True + Nom.Percepciones.TotalSeparacionIndemnizacion = TotalIndemnizacion.ToDecimal + Nom.Percepciones.TotalJubilacionPensionRetiroSpecified = True + Nom.Percepciones.TotalJubilacionPensionRetiro = TotalJubilacion.ToDecimal + Nom.Percepciones.TotalGravado = ObjCFDITimbre.Nomina.TotalPercepcionesGravado.ToDecimal + Nom.Percepciones.TotalExento = ObjCFDITimbre.Nomina.TotalPercepcionesExento.ToDecimal + Nom.Percepciones.Percepcion = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcion(ObjCFDITimbre.Nomina.Percepciones.Count - 1) {} + Dim i As Integer = 0 + For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones + Nom.Percepciones.Percepcion(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcion() + Nom.Percepciones.Percepcion(i).TipoPercepcion = percep.TipoPercepcion + Nom.Percepciones.Percepcion(i).Clave = percep.Clave + Nom.Percepciones.Percepcion(i).Concepto = percep.Concepto + Nom.Percepciones.Percepcion(i).ImporteGravado = Math.Round(percep.ImporteGravado, 2).ToString.ToDecimal + Nom.Percepciones.Percepcion(i).ImporteExento = Math.Round(percep.ImporteExento, 2).ToString.ToDecimal + + If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then + Nom.Percepciones.Percepcion(i).HorasExtra = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcionHorasExtra(ObjCFDITimbre.Nomina.HorasExtras.Count - 1) {} + Dim x As Integer = 0 + For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras + Nom.Percepciones.Percepcion(i).HorasExtra(x) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaPercepcionesPercepcionHorasExtra() + Nom.Percepciones.Percepcion(i).HorasExtra(x).Dias = HoraExtra.Dias.ToEntero + Nom.Percepciones.Percepcion(i).HorasExtra(x).TipoHoras = HoraExtra.TipoHoras + Nom.Percepciones.Percepcion(i).HorasExtra(x).HorasExtra = HoraExtra.HorasExtra.ToEntero + Nom.Percepciones.Percepcion(i).HorasExtra(x).ImportePagado = HoraExtra.ImportePagado.ToDecimal + x += 1 + Next + End If + + i += 1 + Next + End If + 'cfdi.agregarNominaReceptorSubContratacion12("AAD990814BP6", "50") + 'cfdi.agregarNominaPercepcionesPercepcionAccionesOTitulos12("100", "200"); + 'cfdi.agregarNominaPercepcionesSeparacionIndemnizacion12("100", "10", "1000", "100", "50"); + 'cfdi.agregarNominaPercepcionesJubilacionPensionRetiro12("50", "100", "10", "100", "0"); + + + + If ObjCFDITimbre.Nomina.Incapacidades IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Incapacidades.Count > 0 Then + Nom.Incapacidades = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaIncapacidad(ObjCFDITimbre.Nomina.Incapacidades.Count - 1) {} + Dim i As Integer = 0 + For Each Incap As CFDINominaIncapacidades In ObjCFDITimbre.Nomina.Incapacidades + Nom.Incapacidades(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaIncapacidad() + Nom.Incapacidades(i).DiasIncapacidad = Incap.DiasIncapacidad.ToEntero + Nom.Incapacidades(i).TipoIncapacidad = Incap.TipoIncapacidad + Nom.Incapacidades(i).ImporteMonetarioSpecified = True + Nom.Incapacidades(i).ImporteMonetario = Incap.Importe.ToDecimal + i += 1 + Next + End If + + If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then + Nom.Deducciones = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaDeducciones() + Nom.Deducciones.TotalOtrasDeduccionesSpecified = True + Nom.Deducciones.TotalOtrasDeducciones = Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesOtras, 2) + Nom.Deducciones.TotalImpuestosRetenidosSpecified = True + Nom.Deducciones.TotalImpuestosRetenidos = Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2) + Nom.Deducciones.Deduccion = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaDeduccionesDeduccion(ObjCFDITimbre.Nomina.Deducciones.Count - 1) {} + Dim i As Integer = 0 + For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones + Nom.Deducciones.Deduccion(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaDeduccionesDeduccion() + Nom.Deducciones.Deduccion(i).TipoDeduccion = deduc.TipoDeduccion + Nom.Deducciones.Deduccion(i).Clave = deduc.Clave + Nom.Deducciones.Deduccion(i).Concepto = deduc.Concepto + Nom.Deducciones.Deduccion(i).Importe = Math.Round(deduc.Importe, 2) + i += 1 + 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 + Nom.OtrosPagos = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPago(ObjCFDITimbre.Nomina.OtrosPagos.Count - 1) {} + Dim i As Integer = 0 + For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos + Nom.OtrosPagos(i) = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPago() + Nom.OtrosPagos(i).TipoOtroPago = otpag.TipoOtroPago + Nom.OtrosPagos(i).Clave = otpag.Clave + Nom.OtrosPagos(i).Concepto = otpag.Concepto + Nom.OtrosPagos(i).Importe = otpag.Importe.ToDecimal + If otpag.TipoOtroPago = "002" Then + Nom.OtrosPagos(i).SubsidioAlEmpleo = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPagoSubsidioAlEmpleo() + Nom.OtrosPagos(i).SubsidioAlEmpleo.SubsidioCausado = otpag.Importe.ToDecimal + End If + i += 1 + Next + End If + End If + + +#Region "Receptor" + Nom.Receptor = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaReceptor() + Nom.Receptor.Curp = ObjCFDITimbre.Nomina.Receptor.CURP + Nom.Receptor.NumSeguridadSocial = ObjCFDITimbre.Nomina.Receptor.NSS + Nom.Receptor.FechaInicioRelLaboralSpecified = True + Nom.Receptor.FechaInicioRelLaboral = ObjCFDITimbre.Nomina.Receptor.FechaInicioContrato.ToDate + Nom.Receptor.Antigüedad = ObjCFDITimbre.Nomina.Receptor.Antiguedad + Nom.Receptor.TipoContrato = ObjCFDITimbre.Nomina.Receptor.TipoContrato + 'Nom.Receptor.Sindicalizado = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaReceptorSindicalizado() + 'Nom.Receptor.Sindicalizado = ObjCFDITimbre.Nomina.Receptor.Sindicalizado + Nom.Receptor.TipoJornadaSpecified = True + Nom.Receptor.TipoJornada = ObjCFDITimbre.Nomina.Receptor.CodigoTipoJornada + Nom.Receptor.TipoRegimen = ObjCFDITimbre.Nomina.Receptor.CodigoRegimenContratacion + Nom.Receptor.NumEmpleado = ObjCFDITimbre.Nomina.Receptor.CodigoEmpleado + Nom.Receptor.Departamento = ObjCFDITimbre.Nomina.Receptor.Departamento + Nom.Receptor.Puesto = ObjCFDITimbre.Nomina.Receptor.Puesto + Nom.Receptor.RiesgoPuestoSpecified = True + Nom.Receptor.RiesgoPuesto = ObjCFDITimbre.Nomina.Receptor.CodigoRiesgoPuesto + Nom.Receptor.PeriodicidadPago = ObjCFDITimbre.Nomina.Receptor.TipoPeriodo + Nom.Receptor.BancoSpecified = True + Nom.Receptor.Banco = ObjCFDITimbre.Nomina.Receptor.CodigoBanco + Nom.Receptor.CuentaBancaria = ObjCFDITimbre.Nomina.Receptor.NumeroCuenta + Nom.Receptor.SalarioBaseCotAporSpecified = True + Nom.Receptor.SalarioBaseCotApor = ObjCFDITimbre.Nomina.Receptor.SBC.ToDecimal + Nom.Receptor.SalarioDiarioIntegradoSpecified = True + Nom.Receptor.SalarioDiarioIntegrado = ObjCFDITimbre.Nomina.Receptor.SDI.ToDecimal + Nom.Receptor.ClaveEntFed = ObjCFDITimbre.Nomina.Receptor.CodigoEntidadFederativa + + Dim nsNom As New System.Xml.Serialization.XmlSerializerNamespaces() + nsNom.Add("nomina12", "http://www.sat.gob.mx/nomina12") + Dim xmlNom As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(Nom, GetType(Profact.TimbraCFDI33.Complementos.Nomina12.Nomina), nsNom) + Dim docNom As New XmlDocument() + docNom.LoadXml(xmlNom) + LXmlComplementos.Add(docNom.DocumentElement) + TieneComplemento = True + + + End If +#End Region + +#End Region + +#Region "Detallista" + If Ventas.Cliente.AplicaDetallista Then + Dim detallista As Profact.TimbraCFDI33.Complementos.Detallista.detallista = New Profact.TimbraCFDI33.Complementos.Detallista.detallista + detallista.type = "SimpleInvoiceType" + detallista.contentVersion = "1.3.1" + detallista.documentStructureVersion = "AMC8.1" + detallista.documentStatus = Profact.TimbraCFDI33.Complementos.Detallista.detallistaDocumentStatus.ORIGINAL + + detallista.DeliveryNote = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaDeliveryNote + detallista.DeliveryNote.referenceIdentification = New String((1)) {} + detallista.DeliveryNote.referenceIdentification(0) = "1" + detallista.DeliveryNote.ReferenceDate = New DateTime + detallista.DeliveryNote.ReferenceDate = comprobante.Fecha + detallista.DeliveryNote.ReferenceDateSpecified = True + + detallista.requestForPaymentIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaRequestForPaymentIdentification + detallista.requestForPaymentIdentification.entityType = Profact.TimbraCFDI33.Complementos.Detallista.detallistaRequestForPaymentIdentificationEntityType.INVOICE + + detallista.specialInstruction = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSpecialInstruction((1)) {} + detallista.specialInstruction(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSpecialInstruction + detallista.specialInstruction(0).code = Profact.TimbraCFDI33.Complementos.Detallista.detallistaSpecialInstructionCode.ZZZ + Dim TotalTexto = New String() {Ventas.TotalTC.ToString.ToDouble.Texto2Letras.ToUpper()} + Dim propertyInfo = detallista.specialInstruction(0).GetType().GetProperty("text") + propertyInfo.SetValue(detallista.specialInstruction(0), Convert.ChangeType(TotalTexto, propertyInfo.PropertyType), Nothing) + + detallista.orderIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentification + detallista.orderIdentification.referenceIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentificationReferenceIdentification((1)) {} + detallista.orderIdentification.referenceIdentification(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentificationReferenceIdentification + detallista.orderIdentification.referenceIdentification(0).type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaOrderIdentificationReferenceIdentificationType.ON + detallista.orderIdentification.referenceIdentification(0).Value = Ventas.Det_OrdenCompra + detallista.orderIdentification.ReferenceDateSpecified = True + detallista.orderIdentification.ReferenceDate = Ventas.Det_FechaOrdenCompra.ToDate() + + detallista.AdditionalInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaReferenceIdentification((1)) {} + detallista.AdditionalInformation(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaReferenceIdentification + detallista.AdditionalInformation(0).type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaReferenceIdentificationType.ATZ + detallista.AdditionalInformation(0).Value = Ventas.Det_ContraRecibo + + detallista.DeliveryNote = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaDeliveryNote + detallista.DeliveryNote.ReferenceDate = Ventas.Det_FechaOrdenCompra.ToDate + detallista.DeliveryNote.referenceIdentification = New String((1)) {} + detallista.DeliveryNote.referenceIdentification(0) = Ventas.Det_ContraRecibo + + detallista.buyer = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaBuyer + detallista.buyer.gln = Ventas.Cliente.Detallista_GLNComprador + detallista.buyer.contactInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaBuyerContactInformation + detallista.buyer.contactInformation.personOrDepartmentName = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaBuyerContactInformationPersonOrDepartmentName + detallista.buyer.contactInformation.personOrDepartmentName.text = Ventas.Cliente.Detallista_Departamento + + detallista.seller = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSeller + detallista.seller.gln = Ventas.Cliente.Detallista_GLNVendedor + detallista.seller.alternatePartyIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaSellerAlternatePartyIdentification + detallista.seller.alternatePartyIdentification.type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaSellerAlternatePartyIdentificationType.SELLER_ASSIGNED_IDENTIFIER_FOR_A_PARTY + detallista.seller.alternatePartyIdentification.Value = Ventas.Cliente.Detallista_NumProveedor + + 'detallista.shipTo = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaShipTo + 'detallista.shipTo.gln = "0000000000000" + 'detallista.shipTo.nameAndAddress = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaShipToNameAndAddress + 'detallista.shipTo.nameAndAddress.name = New String((1)) {} + 'detallista.shipTo.nameAndAddress.name(0) = Ventas.Cliente.Direccion + 'detallista.shipTo.nameAndAddress.streetAddressOne = New String((1)) {} + 'detallista.shipTo.nameAndAddress.streetAddressOne(0) = Ventas.Cliente.NoInt + 'detallista.shipTo.nameAndAddress.city = New String((1)) {} + 'detallista.shipTo.nameAndAddress.city(0) = Ventas.Cliente.Ciudad + 'detallista.shipTo.nameAndAddress.postalCode = New String((1)) {} + 'detallista.shipTo.nameAndAddress.postalCode(0) = Ventas.Cliente.CP + + detallista.paymentTerms = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTerms + detallista.paymentTerms.netPayment = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPayment + detallista.paymentTerms.netPayment.paymentTimePeriod = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPaymentPaymentTimePeriod + detallista.paymentTerms.netPayment.paymentTimePeriod.timePeriodDue = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPaymentPaymentTimePeriodTimePeriodDue + detallista.paymentTerms.netPayment.paymentTimePeriod.timePeriodDue.timePeriod = Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsNetPaymentPaymentTimePeriodTimePeriodDueTimePeriod.DAYS + detallista.paymentTerms.netPayment.paymentTimePeriod.timePeriodDue.value = "0" + + detallista.paymentTerms.discountPayment = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaPaymentTermsDiscountPayment + detallista.paymentTerms.discountPayment.percentage = If(Ventas.DescuentoTC > 0 AndAlso Ventas.SubTotalTC > 0, (Ventas.DescuentoTC * 100) / Ventas.SubTotalTC, 0).ToString().FormatoNumero() + + detallista.currency = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrency((1)) {} + detallista.currency(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrency + detallista.currency(0).currencyISOCode = If(Ventas.CveMoneda = 1, Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyISOCode.MXN, Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyISOCode.USD) + detallista.currency(0).currencyFunction = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyFunction((1)) {} + detallista.currency(0).currencyFunction(0) = Profact.TimbraCFDI33.Complementos.Detallista.detallistaCurrencyCurrencyFunction.BILLING_CURRENCY + detallista.currency(0).rateOfChangeSpecified = True + detallista.currency(0).rateOfChange = 1 + + detallista.allowanceCharge = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceCharge(1) {} + detallista.allowanceCharge(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceCharge + detallista.allowanceCharge(0).monetaryAmountOrPercentage = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceChargeMonetaryAmountOrPercentage + detallista.allowanceCharge(0).monetaryAmountOrPercentage.rate = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceChargeMonetaryAmountOrPercentageRate + detallista.allowanceCharge(0).monetaryAmountOrPercentage.rate.base = Profact.TimbraCFDI33.Complementos.Detallista.detallistaAllowanceChargeMonetaryAmountOrPercentageRateBase.INVOICE_VALUE + detallista.allowanceCharge(0).monetaryAmountOrPercentage.rate.percentage = If(Ventas.DescuentoTC > 0 AndAlso Ventas.SubTotalTC > 0, (Ventas.DescuentoTC * 100) / Ventas.SubTotalTC, 0) + + Dim articuloCounter As Integer = 0 + For Each concepto As Profact.TimbraCFDI33.ComprobanteConcepto In comprobante.Conceptos + articuloCounter = (articuloCounter + 1) + Next + detallista.lineItem = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItem((articuloCounter)) {} + Dim counter As Integer = 0 + For Each concepto As Profact.TimbraCFDI33.ComprobanteConcepto In comprobante.Conceptos + detallista.lineItem(counter) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItem + detallista.lineItem(counter).type = "SimpleInvoiceLineItemType" + detallista.lineItem(counter).number = (counter + 1).ToString + detallista.lineItem(counter).tradeItemIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemIdentification + detallista.lineItem(counter).tradeItemIdentification.gtin = comprobante.Conceptos(counter).NoIdentificacion + detallista.lineItem(counter).alternateTradeItemIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentification(1) {} + detallista.lineItem(counter).alternateTradeItemIdentification(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentification + detallista.lineItem(counter).alternateTradeItemIdentification(0).type = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentificationType + detallista.lineItem(counter).alternateTradeItemIdentification(0).type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAlternateTradeItemIdentificationType.BUYER_ASSIGNED + detallista.lineItem(counter).tradeItemDescriptionInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemDescriptionInformation + If (comprobante.Conceptos(counter).Descripcion.Length > 34) Then + detallista.lineItem(counter).tradeItemDescriptionInformation.longText = comprobante.Conceptos(counter).Descripcion.Substring(0, 34) + Else + detallista.lineItem(counter).tradeItemDescriptionInformation.longText = comprobante.Conceptos(counter).Descripcion + End If + detallista.lineItem(counter).invoicedQuantity = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemInvoicedQuantity + detallista.lineItem(counter).invoicedQuantity.unitOfMeasure = comprobante.Conceptos(counter).Unidad + detallista.lineItem(counter).invoicedQuantity.Text = New String((1)) {} + detallista.lineItem(counter).invoicedQuantity.Text(0) = comprobante.Conceptos(counter).Cantidad.ToString + + detallista.lineItem(counter).aditionalQuantity = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAditionalQuantity(1) {} + detallista.lineItem(counter).aditionalQuantity(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAditionalQuantity + detallista.lineItem(counter).aditionalQuantity(0).QuantityType = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAditionalQuantityQuantityType.NUM_CONSUMER_UNITS + detallista.lineItem(counter).aditionalQuantity(0).Text = New String((1)) {} + detallista.lineItem(counter).aditionalQuantity(0).Text(0) = "1" + + detallista.lineItem(counter).grossPrice = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemGrossPrice + detallista.lineItem(counter).grossPrice.Amount = comprobante.Conceptos(counter).ValorUnitario + + detallista.lineItem(counter).netPrice = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemNetPrice + detallista.lineItem(counter).netPrice.Amount = comprobante.Conceptos(counter).ValorUnitario + + detallista.lineItem(counter).AdditionalInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAdditionalInformation + detallista.lineItem(counter).AdditionalInformation.referenceIdentification = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAdditionalInformationReferenceIdentification + detallista.lineItem(counter).AdditionalInformation.referenceIdentification.type = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemAdditionalInformationReferenceIdentificationType.ON + detallista.lineItem(counter).AdditionalInformation.referenceIdentification.Value = "1587" + 'Impuestos + Dim tasa As Decimal = 0 + Dim importeImp As Decimal = 0 + Try + If (Not (comprobante.Impuestos.Traslados) Is Nothing) Then + For Each traslado As Profact.TimbraCFDI33.ComprobanteImpuestosTraslado In comprobante.Impuestos.Traslados + tasa = Decimal.Parse(traslado.TasaOCuota) + importeImp = (comprobante.Conceptos(counter).Importe * (tasa / 100)) + Next + End If + + Catch ex As System.Exception + + End Try + + detallista.lineItem(counter).tradeItemTaxInformation = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformation(1) {} + detallista.lineItem(counter).tradeItemTaxInformation(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformation + detallista.lineItem(counter).tradeItemTaxInformation(0).taxTypeDescription = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformationTaxTypeDescription + detallista.lineItem(counter).tradeItemTaxInformation(0).taxTypeDescription = Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformationTaxTypeDescription.VAT + detallista.lineItem(counter).tradeItemTaxInformation(0).tradeItemTaxAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTradeItemTaxInformationTradeItemTaxAmount + detallista.lineItem(counter).tradeItemTaxInformation(0).tradeItemTaxAmount.taxPercentage = tasa + detallista.lineItem(counter).tradeItemTaxInformation(0).tradeItemTaxAmount.taxAmount = importeImp + + detallista.lineItem(counter).totalLineAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTotalLineAmount + detallista.lineItem(counter).totalLineAmount.grossAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTotalLineAmountGrossAmount + detallista.lineItem(counter).totalLineAmount.grossAmount.Amount = comprobante.Conceptos(counter).Importe + detallista.lineItem(counter).totalLineAmount.netAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaLineItemTotalLineAmountNetAmount + detallista.lineItem(counter).totalLineAmount.netAmount.Amount = comprobante.Conceptos(counter).Importe + counter = (counter + 1) + Next + detallista.totalAmount = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAmount + detallista.totalAmount.Amount = comprobante.SubTotal + + detallista.TotalAllowanceCharge = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAllowanceCharge(1) {} + detallista.TotalAllowanceCharge(0) = New Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAllowanceCharge + detallista.TotalAllowanceCharge(0).allowanceOrChargeType = Profact.TimbraCFDI33.Complementos.Detallista.detallistaTotalAllowanceChargeAllowanceOrChargeType.ALLOWANCE + detallista.TotalAllowanceCharge(0).Amount = Ventas.DescuentoTC + + Dim nombres As System.Xml.Serialization.XmlSerializerNamespaces = New System.Xml.Serialization.XmlSerializerNamespaces + nombres.Add("detallista", "http://www.sat.gob.mx/detallista") + Dim xmlDetallista As String = Profact.TimbraCFDI.XMLUtilerias.SerializaObjeto(detallista, GetType(Profact.TimbraCFDI33.Complementos.Detallista.detallista), nombres) + + Dim docDetallista As XmlDocument = New XmlDocument + docDetallista.LoadXml(xmlDetallista) + comprobante.DetallistaSpecified = True + LXmlComplementos.Add(docDetallista.DocumentElement) + + TieneComplemento = True + End If +#End Region + + If TieneComplemento Then + comprobante.Complemento = New Profact.TimbraCFDI33.ComprobanteComplemento + comprobante.Complemento.Any = LXmlComplementos.ToArray() + End If + + sw.Stop() + swTiempo.AppendFormat("Armado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + +#Region "Genera XML" + ' Try + ' cfdi.GenerarXMLBase64(llaveBase64, Clave) + ' cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) + ' Catch ex As Exception + + ' End Try + '//Timbramos el CFDI por medio del conector y guardamos resultado + Dim resultadoTimbre As Profact.TimbraCFDI.ResultadoTimbre + +#End Region + + sw.Stop() + swTiempo.AppendFormat("Genera: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + +#Region "Timbra" + resultadoTimbre = cfdi.TimbraCFDI(comprobante) +#End Region + + sw.Stop() + swTiempo.AppendFormat("Timbrado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + + 'Verifica el error + If resultadoTimbre.Exitoso Then + + 'Dim FechaCertificacion As DateTime + Dim FolioFiscal As String + + UUID = resultadoTimbre.FolioUUID + FolioFiscal = resultadoTimbre.FolioUUID + If FolioFiscal <> "" Then + resultadoTimbre.GuardaXml(RutaArchivo, NombreArchivoXML) + + + If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then + + 'Actualiza Estatus Factura + If Ventas.CveVenta > 0 Then + + + Dim ObjVentas As New ClsVentas() + If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", Now, Ventas.CveVenta, CvePAC:=UsuarioActual.Empresa.CvePAC) Then + Retorno = "" + Else + Retorno = "Error" + End If + ObjVentas.Dispose() + + + ''Actualiza Cliente (NumeroCuenta) + 'If Not UsuarioActual.CveEmpresa.Contiene(72, 80) Then + ' Dim Hilo2 As New System.Threading.Thread(Sub() ActualizaCliente(UsuarioActual.CveUsuario, Ventas.Cliente.NumCtaPago, Ventas.CveMetodoPago, Ventas.CveCliente)) + ' Hilo2.Start() + 'End If + + End If + End If + + If Not IO.Directory.Exists($"{UsuarioActual.Empresa.Ruta}CBB\") Then IO.Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}CBB\") + + Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\" + Dim NombreCBB As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" + resultadoTimbre.GuardaCodigoBidimensional(RutaCBB, NombreCBB) + + '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 + + If ObjCFDITimbre.Comprobante.TipoComprobante = "T" Then + Dim ObjInv As New ClsInventarios() + If ObjInv.UpdateMovimientoTimbrado(Ventas.Inv_CveMovimiento, 1, FolioFiscal, MinFecha) Then + Retorno = "" + Else + Retorno = "Error" + End If + ObjInv.Dispose() + End If + + 'Pendiente. Ruta guardar archivos + sw.Stop() + swTiempo.AppendFormat("Actualizado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) + swmili = sw.ElapsedMilliseconds + sw.Start() + + Retorno = "" + Else + Retorno = "No se pudo timbrar ante el SAT. UUID no generado." + End If + + + Else + Dim Resultados = Newtonsoft.Json.Linq.JArray.Parse(resultadoTimbre.Detalle) + If Resultados.Count > 0 Then + Retorno = Resultados(0)("Value").ToString() + MensajeErrorCFDI = Resultados(0)("Value").ToString() + Else + Retorno = resultadoTimbre.Detalle + MensajeErrorCFDI = resultadoTimbre.Detalle + End If + + End If + + GuardaLogTimbrado(swTiempo.ToString, UsuarioActual.Empresa.CvePAC) + Return Retorno + End Function + +#Region "F U N C I O N E S" + Private Function obtenerAtributo(cadena_xml As String, nodo As String, nombre_atributo As String) As String + Try + 'Variables + Dim valor As String + Dim inicio As Integer = 0 + Dim fin As Integer = 0 + Dim inicionodo As Integer = cadena_xml.IndexOf(nodo) + If inicionodo = -1 Then + Return "" + End If + 'Buscamos inicio + inicio = cadena_xml.IndexOf((Convert.ToString(" ") & nombre_atributo) + "=""", inicionodo) + nombre_atributo.Length + 3 + 'Buscamos el final + fin = cadena_xml.IndexOf("""", inicio) + 'Cortamos la cadena + valor = cadena_xml.Substring(inicio, fin - inicio) + 'Retorna el valor + Return valor + Catch + Return "" + End Try + End Function + Private Function TimbrarFacturaProFact(UsuarioActual As Usuario, Optional Ventas As Modelos.Factura = Nothing, Optional TmpDTConceptos As DataTable = Nothing, Optional TmpDTImpuestos As DataTable = Nothing, Optional TmpDTComplementos As DataTable = Nothing, Optional Ruta As String = "", Optional LstFordASN As ListBox = Nothing, Optional FordGSDBM As String = "", Optional ObjV As ClsVentas = Nothing) As Boolean + + Dim Ret As String = TimbrarFacturaProFactv33(Ventas, UsuarioActual) + Return If(Ret = "", True, False) + + End Function + Private Sub GeneraAddenda7Eleven(Archivo As String, TmpDTConceptos As DataTable, TmpDT7Eleven As DataTable) + Dim cfdi As String = "" + Dim SB As New StringBuilder + Try + Using sr As New StreamReader(Archivo) + + cfdi = sr.ReadToEnd() + + End Using + Catch e As Exception + Alert("The file could not be read:", TipoMensaje.MsgError) + + End Try + + cfdi = cfdi.Replace("", "") + + SB.Append(cfdi) + + SB.Append("") + SB.AppendFormat("", TmpDT7Eleven.Rows(0)("sevenElevenNumProveedor").ToString) + SB.AppendFormat("", TmpDT7Eleven.Rows(0)("sevenElevenFolio").ToString, TmpDT7Eleven.Rows(0)("sevenElevenTienda").ToString, TmpDT7Eleven.Rows(0)("sevenElevenFecha").ToString) + + For Each Row As DataRow In TmpDTConceptos.Rows + + SB.AppendFormat("", Row("Codigo"), Row("PS"), Row("Cantidad").ToString.ToDouble.FormatoNumero(), Row("PU").ToString.ToDouble.FormatoNumero()) + + Next + + SB.Append("") + + + Using outfile As New StreamWriter(Archivo) + outfile.Write(SB.ToString()) + End Using + + End Sub + Private Sub GeneraAddendaFord(Archivo As String, pFolio As String, LstFordASN As String, FordGSDBM As String) + Dim cfdi As String = "" + Dim SB As New StringBuilder + Try + Using sr As New StreamReader(Archivo) + + cfdi = sr.ReadToEnd() + + End Using + Catch e As Exception + Alert("The file could not be read:", TipoMensaje.MsgError) + + End Try + + + cfdi = cfdi.Replace("", "") + + SB.Append(cfdi) + + SB.Append("") + SB.AppendFormat("{0}", FordGSDBM.Trim.ToUpper) + + If pFolio <> "" Then SB.AppendFormat("{0}", pFolio) + 'If TxtFordASN2.Text.Trim <> "" Then SB.AppendFormat("{0}", TxtFordASN2.Text.Trim) + + For Each li As String In LstFordASN.Split(","c) + + If li <> "" Then SB.AppendFormat("{0}", li) + + Next + + SB.Append("") + + + Using outfile As New StreamWriter(Archivo) + outfile.Write(SB.ToString()) + End Using + + End Sub + Private Sub GeneraAddendaFord(Archivo As String, pFolio As String, LstFordASN As ListBox, FordGSDBM As String) + Dim cfdi As String = "" + Dim SB As New StringBuilder + Try + Using sr As New StreamReader(Archivo) + + cfdi = sr.ReadToEnd() + + End Using + Catch e As Exception + Alert("The file could not be read:", TipoMensaje.MsgError) + + End Try + + + cfdi = cfdi.Replace("", "") + + SB.Append(cfdi) + + SB.Append("") + SB.AppendFormat("{0}", FordGSDBM.Trim.ToUpper) + + If pFolio <> "" Then SB.AppendFormat("{0}", pFolio) + 'If TxtFordASN2.Text.Trim <> "" Then SB.AppendFormat("{0}", TxtFordASN2.Text.Trim) + + For Each li As ListItem In LstFordASN.Items + + SB.AppendFormat("{0}", li.Text) + + Next + + SB.Append("") + + + Using outfile As New StreamWriter(Archivo) + outfile.Write(SB.ToString()) + End Using + + End Sub + Private Function DecodeBase64(ByVal strXMLCodificado As String) As String + Try + Dim decbuff As Byte() = Convert.FromBase64String(strXMLCodificado) + Return System.Text.Encoding.UTF8.GetString(decbuff) + Catch + Return "" + End Try + End Function + Private Function CodificarABase64(strXML As String) As String + Dim utf8Bytes As Byte() = UTF8Encoding.UTF8.GetBytes(strXML) + Return Convert.ToBase64String(utf8Bytes) + End Function +#End Region + +End Class From 93278dc8767ea656d77488c6b31204cb38dc4397 Mon Sep 17 00:00:00 2001 From: janeth arvizu Date: Fri, 16 Aug 2019 11:08:35 -0700 Subject: [PATCH 11/23] =?UTF-8?q?Actualizaci=C3=B3n=20de=20correo=20con=20?= =?UTF-8?q?el=20nuevo=20dominio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Empresas/70/Formatos/Factura.rdlc | 10253 ++++++++++++++-------------- localhost.sln | 45 + 2 files changed, 5172 insertions(+), 5126 deletions(-) create mode 100644 localhost.sln diff --git a/Empresas/70/Formatos/Factura.rdlc b/Empresas/70/Formatos/Factura.rdlc index 2169075f5..1bb08282d 100644 --- a/Empresas/70/Formatos/Factura.rdlc +++ b/Empresas/70/Formatos/Factura.rdlc @@ -1,5127 +1,5128 @@ - - - - - - true - - - - - Tipo - - - - - - - Textbox3 - 0.90692in - 5.662in - 0.5cm - 2.24597in - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - Fecha y hora de emisión - - - - - - - - - - - - - - - - Textbox3 - 0.46414in - 5.662in - 0.5cm - 2.24597in - 1 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =IIF(Parameters!Serie.Value.ToString="",Parameters!Folio.Value,Parameters!Serie.Value & "-" &Parameters!Folio.Value) - - - - - - - Textbox3 - 0.22455in - 5.662in - 0.60856cm - 2.24597in - 2 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!TipoDocumento.Value - - - - - - - Textbox3 - 0.0412cm - 5.662in - 0.5cm - 2.24597in - 3 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - AD SISTEMAS SOLUCIONES EN TI SA DE CV - - - - - - - - - R.F.C. ASS151026R37 - - - - 0cm - 0cm - - - - - - www.adsistemas.mx|facturacion@adsistemas.mx - - - - 0cm - 0cm - - - - Textbox4 - 1.93416in - 0.50583in - 3.62386in - 4 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!CadenaOriginal.Value - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - External - =Parameters!QR.Value - FitProportional - 5.38305in - 0.04026in - 1.3497in - 1.5531in - 6 - - - - - - Embedded - logo - FitProportional - 0.07204cm - 1.40623cm - 2.88998cm - 2.5499cm - 7 - - - - - - true - - - - - =Parameters!Fecha.Value - - - - - - - Textbox3 - 0.66099in - 5.662in - 0.25114in - 2.24597in - 8 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!Tipo.Value & Parameters!Ref.Value - - - - - - - Textbox3 - 1.10364in - 5.662in - 0.25635in - 2.24597in - 9 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - Domicilio Fiscal - - - - - - - - - Paseo Florido, 62 A, Col Nueva Galicia, - - - - 0cm - 0cm - - - - - - C.P.: 83240, Hermosillo, Sonora, México. - - - - 0cm - 0cm - - - - - - Tel.: (662) 216-2270 - - - - 0cm - 0cm - - - - Textbox10 - 0.51102in - 1.93416in - 0.65513in - 1.79619in - 10 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - Lugar de Expedición - - - - - - - - - =Parameters!DomicilioSucursal.Value - - - - - - - Textbox10 - 0.51102in - 3.77202in - 0.65513in - 1.786in - 11 - - - Top - - - - true - true - - - - - Nombre - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!ClienteNombre.Value - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Dirección - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!ClienteDireccion.Value - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Cuidad - - - - - - - #4f81bd - - 1.25pt - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!ClienteLugar.Value - - - - - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Folio Fiscal: - - - - - - - Textbox54 - 5.38382in - 1.64412in - 0.18056in - 4.03672in - 18 - - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - No. Serie del Certificado del SAT: - - - - - - - Textbox54 - 5.57827in - 1.64412in - 0.18056in - 4.03672in - 19 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Fecha y Hora de certificación: - - - - - - - Textbox54 - 5.78932in - 1.64412in - 0.19444in - 4.03672in - 20 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Certificado del Contribuyente: - - - - - - - Textbox54 - 5.99493in - 1.64412in - 0.19445in - 4.03672in - 21 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!FolioFiscal.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!SerieCertificadoSAT.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!FechaCertificacion.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!CertificadoContribuyente.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Regímen: Regímen General de Ley Personas Morales; Condiciones de pago: - - - - =IIF(Parameters!CondicionPago.Value.ToString="","No Identificado",Parameters!CondicionPago.Value) - - - - ; Método de Pago: - - - - =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) - - - - ; Num. Cta Pago: - - - - =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Éste documento es una representacion impresa de un CFDi - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - true - true - - - - - P A G A R E con Folio - - - - =Parameters!Serie.Value - - - - - - - - - =Parameters!Folio.Value - - - - Por éste pagare prometo (emos) pagar incondicionalmente a la orden de AD Sistemas Soluciones en TI, S.A de C.V, a su vencimiento el - - - - =Parameters!Vencimiento.Value - - - - , en Hermosillo, Sonora o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ - - - - =Parameters!Total.Value - - - - SON: ( - - - - =Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) - - - - ). Valor recibido a mi (nuestra) entera satisfacción. la falta de pago de éste documento a su vencimiento dará derecho a AD Sistemas Soluciones en TI, S.A de C.V o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a - - - - =CDATE(Parameters!Fecha.Value).ToString("dd/MM/yyyy") - - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Nombre: - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Dirección: - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!ClienteNombre.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!ClienteDireccion.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - - - - - White - - - Black - - - White - - - White - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Acepto de conformidad - - - - - - 2pt - 2pt - 2pt - 2pt - - - - 0.29357cm - 0.08375cm - 0cm - 0.57653cm - 7 - - - - - - 0.29357cm - 0.71971cm - 0cm - 0.57653cm - 8 - - - - - - 0.29357cm - 1.35545cm - 0cm - 0.57653cm - 9 - - - - - - 0.29357cm - 1.66152cm - 0cm - 0.57653cm - 10 - - - - - - 0.29357cm - 2.29748cm - 0cm - 0.57653cm - 11 - - - - - - 0.29357cm - 2.93322cm - 0cm - 0.57653cm - 12 - - - - - - 0.29357cm - 3.60266cm - 0cm - 0.57653cm - 13 - - - - - - 0.29357cm - 4.23862cm - 0cm - 0.57653cm - 14 - - - - - - 0.29357cm - 4.87436cm - 0cm - 0.57653cm - 15 - - - - - - 0.29357cm - 5.18043cm - 0cm - 0.57653cm - 16 - - - - - - 0.29357cm - 5.81639cm - 0cm - 0.57653cm - 17 - - - - - - 0.29357cm - 6.45213cm - 0cm - 0.57653cm - 18 - - - - - - 0.29357cm - 7.13239cm - 0cm - 0.57653cm - 19 - - - - - - 0.29357cm - 7.76835cm - 0cm - 0.57653cm - 20 - - - - - - 0.29357cm - 8.40409cm - 0cm - 0.57653cm - 21 - - - - - - 0.29357cm - 8.71016cm - 0cm - 0.57653cm - 22 - - - - - - 0.29357cm - 9.34612cm - 0cm - 0.57653cm - 23 - - - - - - 0.29357cm - 9.98186cm - 0cm - 0.57653cm - 24 - - - - - - 0.29357cm - 14.06281cm - 0cm - 0.57653cm - 25 - - - - - - 0.29357cm - 14.69877cm - 0cm - 0.57653cm - 26 - - - - - - 0.29357cm - 15.33451cm - 0cm - 0.57653cm - 27 - - - - - - 0.29357cm - 15.64058cm - 0cm - 0.57653cm - 28 - - - - - - 0.29357cm - 16.27654cm - 0cm - 0.57653cm - 29 - - - - - - 0.29357cm - 16.91228cm - 0cm - 0.57653cm - 30 - - - - - - 0.29357cm - 10.60588cm - 0cm - 0.57653cm - 31 - - - - - - 0.29357cm - 11.24184cm - 0cm - 0.57653cm - 32 - - - - - - 0.29357cm - 11.87758cm - 0cm - 0.57653cm - 33 - - - - - - 0.29357cm - 12.18365cm - 0cm - 0.57653cm - 34 - - - - - - 0.29357cm - 12.81961cm - 0cm - 0.57653cm - 35 - - - - - - 0.29357cm - 13.45535cm - 0cm - 0.57653cm - 36 - - - - - - 0.29357cm - 18.40663cm - 0cm - 0.57653cm - 37 - - - - - - 0.29357cm - 19.04259cm - 0cm - 0.57653cm - 38 - - - - - - 0.29357cm - 17.74353cm - 0cm - 0.57653cm - 39 - - - - - - true - 20.23207cm - 0.0019cm - 4.14042cm - 20.06179cm - 28 - - = (Parameters!AplicaPagare.Value="0") - - - - - - - - - - 2.12527cm - - - 2.02474cm - - - 10.17786cm - - - 2.52862cm - - - 3.15415cm - - - - - 0.6cm - - - - - true - true - - - - - Cantidad - - - - - - - Textbox34 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Unidad - - - - - - - Textbox53 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Descripción - - - - - - - Textbox79 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - P. Unitario - - - - - - - Textbox84 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Importe - - - - - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.49417cm - - - - - true - true - - - - - =Fields!Cantidad.Value - - - - - - - - - - - - - #eb831f - - - #eb831f - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!UM.Value - - - - - - - UM1 - - - - - - - - - - #eb831f - - - #eb831f - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!PS.Value & " " &Fields!Obs.Value - - - - - - - - - - - - - #eb831f - - - #eb831f - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!PU.Value - - - - - - - PU1 - - - - - - - - - - #eb831f - - - #eb831f - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Cantidad.Value*Fields!PU.Value - - - - - - - Textbox88 - - - - - - - - - - #eb831f - - - #eb831f - - 2pt - 2pt - 2pt - 2pt - es-MX - - - - - - - - 0.16344cm - - - - - true - true - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - - - After - - - - - - Before - - - - DsOC - 4.5569cm - 0.11468cm - 1.25761cm - 20.01064cm - 29 - - - - - - true - - - - - RFC: - - - - =Parameters!ClienteRFC.Value - - - - - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - 0.81609in - - - 0.69462in - - - 0.72263in - - - - - 0.19645in - - - - - true - true - - - - - Impuesto - - - - - - - Textbox22 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Tasa - - - - - - - Textbox15 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Importe - - - - - - - Textbox29 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.14436in - - - - - true - true - - - - - =Fields!Impuesto.Value - - - - - - - Cantidad1 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!tasa.Value - - - - - - - UM - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Importe.Value - - - - - - - Codigo - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - After - - - - - - - DataSet3 - 2.65189in - 5.68499in - 0.34081in - 2.23334in - 31 - - - - - - - - - 3.11466cm - - - - - 0.6cm - - - - - true - true - - - - - =Fields!Importe.Value - - - - - - - Importe - - - 2pt - 2pt - 2pt - 2pt - es-MX - - - - - - - - - - - - - - - - - - - =Fields!ImpuestoLocal.Value - - - - 2.48915cm - - - true - true - - - - - =Fields!ImpuestoLocal.Value - - - - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - DataSet1 - 5.83876cm - 14.4684cm - 0.6cm - 5.60381cm - 32 - - - - - - - - - 3.33075cm - - - 10.99712cm - - - - - 0.6cm - - - - - true - true - - - - - =Parameters!Observaciones.Value - - - - - - - Textbox128 - - - - - - - - - - - - - - 1pt - - 2pt - 2pt - 2pt - 2pt - - - 2 - - - - - - - 0.6cm - - - - - true - true - - - - - Importe con letra: - - - - - - - Textbox126 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #eb831f - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - ="SON: " & Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) - - - - - - - Textbox127 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - Forma de pago: - - - - - - - Textbox130 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #eb831f - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!FormaPago.Value - - - - - - - Textbox131 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - Uso CFDI: - - - - - - - Textbox2 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #eb831f - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!UsoCFDI.Value - - - - - - - Textbox44 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 1.8cm - - - - - true - true - - - - - Sello digital del CFDI: - - - - - - - Textbox132 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #eb831f - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!SelloCFDI.Value - - - - - - - Textbox133 - - - Top - 2pt - 2pt - 2pt - 2pt - - - - - - - - 1.2cm - - - - - true - true - - - - - Sello del SAT: - - - - - - - Textbox134 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #eb831f - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!SelloSAT.Value - - - - - - - Textbox135 - - - Top - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - Cadena original del complemento de certificación digital del SAT: - - - - - - - Textbox136 - - - - - - - - - - - - - - 1pt - - #eb831f - Middle - 2pt - 2pt - 2pt - 2pt - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - DsOC - 5.84979cm - 0.14053cm - 6cm - 14.32787cm - 33 - - - - - - - - true - true - - - - - CFDI Relacionados - - - - - - - Textbox5 - 0.11382cm - 0.05336cm - 0.54004cm - 20.00281cm - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Tipo Relación: - - - - - - - Textbox29 - 0.83025cm - 4.33636cm - 0.41981cm - 5.31841cm - 1 - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!TipoRelacionTexto.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - 2.42456cm - - - 2.05585cm - - - 3.03631cm - - - 7.7847cm - - - - - 0.44125cm - - - - - true - true - - - - - Folio - - - - - - - Textbox10 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Fecha - - - - - - - Textbox12 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Importe - - - - - - - Textbox21 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Folio Fiscal - - - - - - - Textbox11 - - - #eb831f - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.41479cm - - - - - true - true - - - - - =Fields!SerieFolio.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Fecha.Value - - - - - - - Fecha - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Importe.Value - - - - - - - Importe1 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!FolioFiscal.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - - After - - - - - - - DataSet4 - 1.39643cm - 2.83462cm - 0.85604cm - 15.30142cm - 3 - - - - - - true - true - - - - - VERSION 3.3 - - - - - - - Textbox5 - 2.28775cm - 17.08931cm - 0.6cm - 3.06609cm - 4 - - - 2pt - 2pt - 2pt - 2pt - - - - true - 17.18306cm - 0.04112cm - 2.97096cm - 20.1554cm - 34 - - =Microsoft.VisualBasic.Interaction.IIF(First(Fields!SerieFolio.Value, "DataSet4") <> "", False, True) - - - - - - - 24.37249cm - + + + + + + Textbox3 + 0.90692in + 5.662in + 0.5cm + 2.24597in + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Fecha y hora de emisión + + + + + + + + + + + + + + + + Textbox3 + 0.46414in + 5.662in + 0.5cm + 2.24597in + 1 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =IIF(Parameters!Serie.Value.ToString="",Parameters!Folio.Value,Parameters!Serie.Value & "-" &Parameters!Folio.Value) + + + + + + + Textbox3 + 0.22455in + 5.662in + 0.60856cm + 2.24597in + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!TipoDocumento.Value + + + + + + + Textbox3 + 0.0412cm + 5.662in + 0.5cm + 2.24597in + 3 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + AD SISTEMAS SOLUCIONES EN TI SA DE CV + + + + + + + + + R.F.C. ASS151026R37 + + + + 0cm + 0cm + + + + + + www.adsistemas.mx|facturacion@adssistemas.mx + + + + 0cm + 0cm + + + + Textbox4 + 1.93416in + 0.50583in + 3.62386in + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!CadenaOriginal.Value + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + External + =Parameters!QR.Value + FitProportional + 5.38305in + 0.04026in + 1.3497in + 1.5531in + 6 + + + + + + Embedded + logo + FitProportional + 0.07204cm + 1.40623cm + 2.88998cm + 2.5499cm + 7 + + + + + + true + + + + + =Parameters!Fecha.Value + + + + + + + Textbox3 + 0.66099in + 5.662in + 0.25114in + 2.24597in + 8 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!Tipo.Value & Parameters!Ref.Value + + + + + + + Textbox3 + 1.10364in + 5.662in + 0.25635in + 2.24597in + 9 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Domicilio Fiscal + + + + + + + + + Paseo Florido, 62 A, Col Nueva Galicia, + + + + 0cm + 0cm + + + + + + C.P.: 83240, Hermosillo, Sonora, México. + + + + 0cm + 0cm + + + + + + Tel.: (662) 216-2270 + + + + 0cm + 0cm + + + + Textbox10 + 0.51102in + 1.93416in + 0.65513in + 1.79619in + 10 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Lugar de Expedición + + + + + + + + + =Parameters!DomicilioSucursal.Value + + + + + + + Textbox10 + 0.51102in + 3.77202in + 0.65513in + 1.786in + 11 + + + Top + + + + true + true + + + + + Nombre + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteNombre.Value + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Dirección + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteDireccion.Value + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Ciudad + + + + + + + #4f81bd + + 1.25pt + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteLugar.Value + + + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Folio Fiscal: + + + + + + + Textbox54 + 5.38382in + 1.64412in + 0.18056in + 4.03672in + 18 + + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + No. Serie del Certificado del SAT: + + + + + + + Textbox54 + 5.57827in + 1.64412in + 0.18056in + 4.03672in + 19 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha y Hora de certificación: + + + + + + + Textbox54 + 5.78932in + 1.64412in + 0.19444in + 4.03672in + 20 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Certificado del Contribuyente: + + + + + + + Textbox54 + 5.99493in + 1.64412in + 0.19445in + 4.03672in + 21 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FolioFiscal.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!SerieCertificadoSAT.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FechaCertificacion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!CertificadoContribuyente.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Regímen: Regímen General de Ley Personas Morales; Condiciones de pago: + + + + =IIF(Parameters!CondicionPago.Value.ToString="","No Identificado",Parameters!CondicionPago.Value) + + + + ; Método de Pago: + + + + =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) + + + + ; Num. Cta Pago: + + + + =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Éste documento es una representacion impresa de un CFDi + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + true + true + + + + + P A G A R E con Folio + + + + =Parameters!Serie.Value + + + + - + + + + =Parameters!Folio.Value + + + + Por éste pagare prometo (emos) pagar incondicionalmente a la orden de AD Sistemas Soluciones en TI, S.A de C.V, a su vencimiento el + + + + =Parameters!Vencimiento.Value + + + + , en Hermosillo, Sonora o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ + + + + =Parameters!Total.Value + + + + SON: ( + + + + =Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) + + + + ). Valor recibido a mi (nuestra) entera satisfacción. la falta de pago de éste documento a su vencimiento dará derecho a AD Sistemas Soluciones en TI, S.A de C.V o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a + + + + =CDATE(Parameters!Fecha.Value).ToString("dd/MM/yyyy") + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Nombre: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Dirección: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ClienteNombre.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ClienteDireccion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + + + + + White + + + Black + + + White + + + White + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Acepto de conformidad + + + + + + 2pt + 2pt + 2pt + 2pt + + + + 0.29357cm + 0.08375cm + 0cm + 0.57653cm + 7 + + + + + + 0.29357cm + 0.71971cm + 0cm + 0.57653cm + 8 + + + + + + 0.29357cm + 1.35545cm + 0cm + 0.57653cm + 9 + + + + + + 0.29357cm + 1.66152cm + 0cm + 0.57653cm + 10 + + + + + + 0.29357cm + 2.29748cm + 0cm + 0.57653cm + 11 + + + + + + 0.29357cm + 2.93322cm + 0cm + 0.57653cm + 12 + + + + + + 0.29357cm + 3.60266cm + 0cm + 0.57653cm + 13 + + + + + + 0.29357cm + 4.23862cm + 0cm + 0.57653cm + 14 + + + + + + 0.29357cm + 4.87436cm + 0cm + 0.57653cm + 15 + + + + + + 0.29357cm + 5.18043cm + 0cm + 0.57653cm + 16 + + + + + + 0.29357cm + 5.81639cm + 0cm + 0.57653cm + 17 + + + + + + 0.29357cm + 6.45213cm + 0cm + 0.57653cm + 18 + + + + + + 0.29357cm + 7.13239cm + 0cm + 0.57653cm + 19 + + + + + + 0.29357cm + 7.76835cm + 0cm + 0.57653cm + 20 + + + + + + 0.29357cm + 8.40409cm + 0cm + 0.57653cm + 21 + + + + + + 0.29357cm + 8.71016cm + 0cm + 0.57653cm + 22 + + + + + + 0.29357cm + 9.34612cm + 0cm + 0.57653cm + 23 + + + + + + 0.29357cm + 9.98186cm + 0cm + 0.57653cm + 24 + + + + + + 0.29357cm + 14.06281cm + 0cm + 0.57653cm + 25 + + + + + + 0.29357cm + 14.69877cm + 0cm + 0.57653cm + 26 + + + + + + 0.29357cm + 15.33451cm + 0cm + 0.57653cm + 27 + + + + + + 0.29357cm + 15.64058cm + 0cm + 0.57653cm + 28 + + + + + + 0.29357cm + 16.27654cm + 0cm + 0.57653cm + 29 + + + + + + 0.29357cm + 16.91228cm + 0cm + 0.57653cm + 30 + + + + + + 0.29357cm + 10.60588cm + 0cm + 0.57653cm + 31 + + + + + + 0.29357cm + 11.24184cm + 0cm + 0.57653cm + 32 + + + + + + 0.29357cm + 11.87758cm + 0cm + 0.57653cm + 33 + + + + + + 0.29357cm + 12.18365cm + 0cm + 0.57653cm + 34 + + + + + + 0.29357cm + 12.81961cm + 0cm + 0.57653cm + 35 + + + + + + 0.29357cm + 13.45535cm + 0cm + 0.57653cm + 36 + + + + + + 0.29357cm + 18.40663cm + 0cm + 0.57653cm + 37 + + + + + + 0.29357cm + 19.04259cm + 0cm + 0.57653cm + 38 + + + + + + 0.29357cm + 17.74353cm + 0cm + 0.57653cm + 39 + + + + + + true + 20.23207cm + 0.0019cm + 4.14042cm + 20.06179cm + 28 + + = (Parameters!AplicaPagare.Value="0") + + + + + + + + + + 2.12527cm + + + 2.02474cm + + + 10.17786cm + + + 2.52862cm + + + 3.15415cm + + + + + 0.6cm + + + + + true + true + + + + + Cantidad + + + + + + + Textbox34 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Unidad + + + + + + + Textbox53 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Descripción + + + + + + + Textbox79 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + P. Unitario + + + + + + + Textbox84 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Importe + + + + + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.49417cm + + + + + true + true + + + + + =Fields!Cantidad.Value + + + + + + + + + + + + + #eb831f + + + #eb831f + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!UM.Value + + + + + + + UM1 + + + + + + + + + + #eb831f + + + #eb831f + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PS.Value & " " &Fields!Obs.Value + + + + + + + + + + + + + #eb831f + + + #eb831f + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PU.Value + + + + + + + PU1 + + + + + + + + + + #eb831f + + + #eb831f + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Cantidad.Value*Fields!PU.Value + + + + + + + Textbox88 + + + + + + + + + + #eb831f + + + #eb831f + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.16344cm + + + + + true + true + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + Before + + + + DsOC + 4.5569cm + 0.11468cm + 1.25761cm + 20.01064cm + 29 + + + + + + true + + + + + RFC: + + + + =Parameters!ClienteRFC.Value + + + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 0.81609in + + + 0.69462in + + + 0.72263in + + + + + 0.19645in + + + + + true + true + + + + + Impuesto + + + + + + + Textbox22 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Tasa + + + + + + + Textbox15 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Importe + + + + + + + Textbox29 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.14436in + + + + + true + true + + + + + =Fields!Impuesto.Value + + + + + + + Cantidad1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!tasa.Value + + + + + + + UM + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Codigo + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet3 + 2.65189in + 5.68499in + 0.34081in + 2.23334in + 31 + + + + + + + + + 3.11466cm + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + + + + + + + + + + + + =Fields!ImpuestoLocal.Value + + + + 2.48915cm + + + true + true + + + + + =Fields!ImpuestoLocal.Value + + + + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + DataSet1 + 5.83876cm + 14.4684cm + 0.6cm + 5.60381cm + 32 + + + + + + + + + 3.33075cm + + + 10.99712cm + + + + + 0.6cm + + + + + true + true + + + + + =Parameters!Observaciones.Value + + + + + + + Textbox128 + + + + + + + + + + + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + Importe con letra: + + + + + + + Textbox126 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #eb831f + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + ="SON: " & Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) + + + + + + + Textbox127 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Forma de pago: + + + + + + + Textbox130 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #eb831f + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FormaPago.Value + + + + + + + Textbox131 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Uso CFDI: + + + + + + + Textbox2 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #eb831f + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!UsoCFDI.Value + + + + + + + Textbox44 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 1.8cm + + + + + true + true + + + + + Sello digital del CFDI: + + + + + + + Textbox132 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #eb831f + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SelloCFDI.Value + + + + + + + Textbox133 + + + Top + 2pt + 2pt + 2pt + 2pt + + + + + + + + 1.2cm + + + + + true + true + + + + + Sello del SAT: + + + + + + + Textbox134 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #eb831f + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SelloSAT.Value + + + + + + + Textbox135 + + + Top + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Cadena original del complemento de certificación digital del SAT: + + + + + + + Textbox136 + + + + + + + + + + + + + + 1pt + + #eb831f + Middle + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + DsOC + 5.84979cm + 0.14053cm + 6cm + 14.32787cm + 33 + + + + + + + + true + true + + + + + CFDI Relacionados + + + + + + + Textbox5 + 0.11382cm + 0.05336cm + 0.54004cm + 20.00281cm + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Tipo Relación: + + + + + + + Textbox29 + 0.83025cm + 4.33636cm + 0.41981cm + 5.31841cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!TipoRelacionTexto.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.42456cm + + + 2.05585cm + + + 3.03631cm + + + 7.7847cm + + + + + 0.44125cm + + + + + true + true + + + + + Folio + + + + + + + Textbox10 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Fecha + + + + + + + Textbox12 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Importe + + + + + + + Textbox21 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Folio Fiscal + + + + + + + Textbox11 + + + #eb831f + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.41479cm + + + + + true + true + + + + + =Fields!SerieFolio.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Fecha.Value + + + + + + + Fecha + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Importe1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!FolioFiscal.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet4 + 1.39643cm + 2.83462cm + 0.85604cm + 15.30142cm + 3 + + + + + + true + true + + + + + VERSION 3.3 + + + + + + + Textbox5 + 2.28775cm + 17.08931cm + 0.6cm + 3.06609cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + true + 17.18306cm + 0.04112cm + 2.97096cm + 20.1554cm + 34 + + =Microsoft.VisualBasic.Interaction.IIF(First(Fields!SerieFolio.Value, "DataSet4") <> "", False, True) + + + + + + + 24.37249cm + - - - - - - Textbox3 - 0.92083in - 5.70042in - 0.5cm - 2.24597in - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - Fecha y hora de emisión - - - - - - - - - - - - - - - - Textbox3 - 0.47805in - 5.70042in - 0.5cm - 2.24597in - 1 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =IIF(Parameters!Serie.Value.ToString="",Parameters!Folio.Value,Parameters!Serie.Value & "-" &Parameters!Folio.Value) - - - - - - - Textbox3 - 0.23846in - 5.70042in - 0.60856cm - 2.24597in - 2 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!TipoDocumento.Value - - - - - - - Textbox3 - 0.07652cm - 5.70042in - 0.5cm - 2.24597in - 3 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - SERVICIOS ESPECIALIZADOS EN TI - - - - - - - - - R.F.C CAVP830823NZ4 - - - - - - - - - - - - - - - - Textbox4 - 0.03532cm - 2.02954in - 0.51102in - 3.5931in - 4 - - - 2pt - 2pt - 2pt - 2pt - - - - External - =Parameters!QR.Value - FitProportional - 5.92196in - 0.08246in - 0.95455in - 1.49755in - 5 - - - - - - true - - - - - =Parameters!Fecha.Value - - - - - - - Textbox3 - 0.6749in - 5.70042in - 0.25114in - 2.24597in - 6 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!Tipo.Value & Parameters!Ref.Value - - - - - - - Textbox3 - 1.11755in - 5.70042in - 0.25635in - 2.24597in - 7 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - DOMICILIO FISCAL - - - - - - - - - PASEO FLORIDO No.Ext: 62, No.Int: A, Col: NUEVA GALICIA, CP: 83245, HERMOSILLO,SONORA, MEXICO - - - - - - - Textbox10 - 0.52493in - 1.52623in - 0.65513in - 2.06754in - 8 - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - LUGAR DE EXPEDICIÓN - - - - - - - - - =Parameters!DomicilioSucursal.Value - - - - - - - Textbox10 - 0.52493in - 3.6859in - 0.65513in - 1.93674in - 9 - - - Top - - - - true - true - - - - - Nombre - - - - - - - - - - #4182bb - 1pt - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!ClienteNombre.Value - - - - - - - - - - #4182bb - 1pt - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Dirección - - - - - - - - - - #4182bb - 1pt - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!ClienteDireccion.Value - - - - - - - - - - #4182bb - 1pt - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Ciudad - - - - - - - #4182bb - - 1pt - - 2pt - 2pt - 2pt - 2pt - - - - true - - - - - =Parameters!ClienteLugar.Value - - - - - - - - - - - - - - #4182bb - 1pt - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Folio Fiscal: - - - - - - - Textbox54 - 5.89981in - 1.68632in - 0.18056in - 4.03672in - 16 - - - - - - - White - - - - - - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - No. Serie del Certificado del SAT: - - - - - - - Textbox54 - 6.09426in - 1.68632in - 0.18056in - 4.03672in - 17 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Fecha y Hora de certificación: - - - - - - - Textbox54 - 6.29281in - 1.68632in - 0.19444in - 4.03672in - 18 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Certificado del Contribuyente: - - - - - - - Textbox54 - 6.49842in - 1.68632in - 0.19445in - 4.03672in - 19 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!FolioFiscal.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!SerieCertificadoSAT.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!FechaCertificacion.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!CertificadoContribuyente.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Régímen: Sociedad Anónima de Capital Variable; Condiciones de pago: - - - - =IIF(Parameters!CondicionPago.Value.ToString="","No Identificado",Parameters!CondicionPago.Value) - - - - ; Método de Pago: - - - - =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) - - - - ; Num. Cta Pago: - - - - =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Éste documento es una representación impresa de un CFDi - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - true - true - - - - - P A G A R E con Folio - - - - =Parameters!Serie.Value - - - - - - - - - =Parameters!Folio.Value - - - - Por éste pagare prometo (emos) pagar incondicionalmente a la orden de Soluciones en Telemedición JAR SA de CV, a su vencimiento el - - - - =Parameters!Vencimiento.Value - - - - , en Hermosillo, Sonora o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ - - - - =Parameters!Total.Value - - - - SON: ( - - - - =Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) - - - - ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a Soluciones en Telemedición JAR SA de CV o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a - - - - =CDATE(Parameters!Fecha.Value).ToString("dd/MM/yyyy") - - - - - - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Nombre: - - - - =Parameters!ClienteNombre.Value - - - - - - - =Parameters!ClienteDireccion.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Acepto de conformidad - - - - - - 2pt - 2pt - 2pt - 2pt - - - - 0.29357cm - 0.09963cm - 0cm - 0.57653cm - 3 - - - - - - 0.29357cm - 0.73559cm - 0cm - 0.57653cm - 4 - - - - - - 0.29357cm - 1.35545cm - 0cm - 0.57653cm - 5 - - - - - - 0.29357cm - 1.80439cm - 0cm - 0.57653cm - 6 - - - - - - 0.29357cm - 2.37686cm - 0cm - 0.57653cm - 7 - - - - - - 0.29357cm - 3.01789cm - 0cm - 0.57653cm - 8 - - - - - - 0.29357cm - 3.65558cm - 0cm - 0.57653cm - 9 - - - - - - 0.29357cm - 4.29154cm - 0cm - 0.57653cm - 10 - - - - - - 0.29357cm - 4.92728cm - 0cm - 0.57653cm - 11 - - - - - - 0.29357cm - 5.25981cm - 0cm - 0.57653cm - 12 - - - - - - 0.29357cm - 5.89576cm - 0cm - 0.57653cm - 13 - - - - - - 0.29357cm - 6.50505cm - 0cm - 0.57653cm - 14 - - - - - - 0.29357cm - 7.18531cm - 0cm - 0.57653cm - 15 - - - - - - 0.29357cm - 7.82127cm - 0cm - 0.57653cm - 16 - - - - - - 0.29357cm - 8.48346cm - 0cm - 0.57653cm - 17 - - - - - - 0.29357cm - 8.81599cm - 0cm - 0.57653cm - 18 - - - - - - 0.29357cm - 9.45195cm - 0cm - 0.57653cm - 19 - - - - - - 0.29357cm - 10.11415cm - 0cm - 0.57653cm - 20 - - - - - - 0.29357cm - 14.08927cm - 0cm - 0.57653cm - 21 - - - - - - 0.29357cm - 14.72523cm - 0cm - 0.57653cm - 22 - - - - - - 0.29357cm - 15.33451cm - 0cm - 0.57653cm - 23 - - - - - - 0.29357cm - 15.64058cm - 0cm - 0.57653cm - 24 - - - - - - 0.29357cm - 16.27654cm - 0cm - 0.57653cm - 25 - - - - - - 0.29357cm - 16.91228cm - 0cm - 0.57653cm - 26 - - - - - - 0.29357cm - 10.76463cm - 0cm - 0.57653cm - 27 - - - - - - 0.29357cm - 11.42705cm - 0cm - 0.57653cm - 28 - - - - - - 0.29357cm - 12.06279cm - 0cm - 0.57653cm - 29 - - - - - - 0.29357cm - 12.36886cm - 0cm - 0.57653cm - 30 - - - - - - 0.29357cm - 12.89898cm - 0cm - 0.57653cm - 31 - - - - - - 0.29357cm - 13.53472cm - 0cm - 0.57653cm - 32 - - - - - - 0.29357cm - 18.40663cm - 0cm - 0.57653cm - 33 - - - - - - 0.29357cm - 19.04259cm - 0cm - 0.57653cm - 34 - - - - - - 0.29357cm - 17.74353cm - 0cm - 0.57653cm - 35 - - - - - - 3.29402cm - 15.33451cm - 0cm - 4.58211cm - 36 - - - - - - true - 18.43647cm - 0.23734cm - 4.04843cm - 20.06179cm - 26 - - = (Parameters!AplicaPagare.Value="0" ORelse Parameters!AplicaPagare.Value="") - - - - - - - - - - 2.12527cm - - - 2.02474cm - - - 10.17786cm - - - 2.52862cm - - - 3.15415cm - - - - - 0.52063cm - - - - - true - - - - - Cantidad - - - - - - - Textbox34 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - - - - - Unidad - - - - - - - Textbox53 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - - - - - Descripción - - - - - - - Textbox79 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - - - - - P. Unitario - - - - - - - Textbox84 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - - - - - Importe - - - - - - - - - - - - - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.4148cm - - - - - true - true - - - - - =Fields!Cantidad.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!UM.Value - - - - - - - UM1 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!PS.Value &Fields!Obs.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!PU.Value - - - - - - - PU1 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Cantidad.Value*Fields!PU.Value - - - - - - - Textbox88 - - - 2pt - 2pt - 2pt - 2pt - es-MX - - - - - - - - 0.08406cm - - - - - true - true - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - - - - - - - - - 1pt - - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - - - After - - - - - - Before - - - - DsOC - 4.59222cm - 0.21226cm - 1.01949cm - 20.01064cm - 27 - - - - - - true - - - - - RFC: - - - - =Parameters!ClienteRFC.Value - - - - - - - - - - - - - - #4182bb - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - 0.81245in - - - 0.69098in - - - 0.69475in - - - - - 0.19645in - - - - - true - true - - - - - Impuesto - - - - - - - Textbox22 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Tasa - - - - - - - Textbox15 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Importe - - - - - - - Textbox29 - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.14436in - - - - - true - true - - - - - =Fields!Impuesto.Value - - - - - - - Cantidad1 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!tasa.Value - - - - - - - UM - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Importe.Value - - - - - - - Codigo - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - After - - - - - - - DataSet3 - 2.54983in - 5.77254in - 0.34081in - 2.19818in - 29 - - - - - - - - - 3.01975cm - - - - - 0.6cm - - - - - true - true - - - - - =Fields!Importe.Value - - - - - - - Importe - - - 2pt - 2pt - 2pt - 2pt - es-MX - - - - - - - - - - - - - - - - - - - =Fields!ImpuestoLocal.Value - - - - 2.56368cm - - - true - true - - - - - =Fields!ImpuestoLocal.Value - - - - - - #4182bb - 2pt - 2pt - 2pt - 2pt - - - - - - - - DataSet1 - 5.75282cm - 14.66222cm - 0.6cm - 5.58343cm - 30 - - - - - - - - - 3.33888cm - - - 11.00525cm - - - - - 0.6cm - - - - - true - true - - - - - =Parameters!Observaciones.Value - - - - - - - Textbox128 - - - 2pt - 2pt - 2pt - 2pt - - - 2 - - - - - - - 0.6cm - - - - - true - true - - - - - Importe con letra: - - - - - - - Textbox126 - - - - - - - - - - - - #4182bb - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - ="SON: " & Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) - - - - - - - Textbox127 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - Forma de pago: - - - - - - - Textbox130 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #4182bb - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!FormaPago.Value - - - - - - - Textbox131 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - Uso CFDI: - - - - - - - Textbox15 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #4182bb - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!UsoCFDI.Value - - - - - - - Textbox17 - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 1.56188cm - - - - - true - true - - - - - Sello digital del CFDI: - - - - - - - Textbox132 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #4182bb - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!SelloCFDI.Value - - - - - - - Textbox133 - - - Top - 2pt - 2pt - 2pt - 2pt - - - - - - - - 1.2cm - - - - - true - true - - - - - Sello del SAT: - - - - - - - Textbox134 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #4182bb - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!SelloSAT.Value - - - - - - - Textbox135 - - - Top - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - Cadena original del complemento de certificación digital del SAT: - - - - - - - Textbox136 - - - - - - - - - - - - - - 1pt - - #4182bb - Middle - 2pt - 2pt - 2pt - 2pt - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - DsOC - 5.75282cm - 0.21226cm - 5.76188cm - 14.34413cm - 31 - - - - - - true - true - - - - - =Parameters!CadenaOriginal.Value - - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Nombre Comercial: - - - - - - - - - Beneficiario: - - - - - - - - - - - - - Banco: - - - - - - - - - - - - - Clabe: - - - - - - - - - Cuenta: - - - - - - - - - - - Textbox1 - 12.64886cm - 0.18154cm - 2.03294cm - 10.03331cm - 33 - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Servicios Especializados en TI - - - - - - - - - Paola Castillo Valenzuela - - - - - - - - - Bbva Bancomer - - - - - - - - - 012760 0295 6695 3887 - - - - - - - - - 29 5669 5388 - - - - - - - Textbox1 - 12.64885cm - 10.21485cm - 2.03294cm - 10.08428cm - 34 - - - 2pt - 2pt - 2pt - 2pt - - - - Embedded - SETIVERDE2 - FitProportional - 0.03532cm - 0cm - 1.67893cm - 5.10541cm - 35 - - - - - - 22.4849cm - + + + + + + Textbox3 + 0.92083in + 5.70042in + 0.5cm + 2.24597in + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Fecha y hora de emisión + + + + + + + + + + + + + + + + Textbox3 + 0.47805in + 5.70042in + 0.5cm + 2.24597in + 1 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =IIF(Parameters!Serie.Value.ToString="",Parameters!Folio.Value,Parameters!Serie.Value & "-" &Parameters!Folio.Value) + + + + + + + Textbox3 + 0.23846in + 5.70042in + 0.60856cm + 2.24597in + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!TipoDocumento.Value + + + + + + + Textbox3 + 0.07652cm + 5.70042in + 0.5cm + 2.24597in + 3 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + SERVICIOS ESPECIALIZADOS EN TI + + + + + + + + + R.F.C CAVP830823NZ4 + + + + + + + + + + + + + + + + Textbox4 + 0.03532cm + 2.02954in + 0.51102in + 3.5931in + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + External + =Parameters!QR.Value + FitProportional + 5.92196in + 0.08246in + 0.95455in + 1.49755in + 5 + + + + + + true + + + + + =Parameters!Fecha.Value + + + + + + + Textbox3 + 0.6749in + 5.70042in + 0.25114in + 2.24597in + 6 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!Tipo.Value & Parameters!Ref.Value + + + + + + + Textbox3 + 1.11755in + 5.70042in + 0.25635in + 2.24597in + 7 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + DOMICILIO FISCAL + + + + + + + + + PASEO FLORIDO No.Ext: 62, No.Int: A, Col: NUEVA GALICIA, CP: 83245, HERMOSILLO,SONORA, MEXICO + + + + + + + Textbox10 + 0.52493in + 1.52623in + 0.65513in + 2.06754in + 8 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + LUGAR DE EXPEDICIÓN + + + + + + + + + =Parameters!DomicilioSucursal.Value + + + + + + + Textbox10 + 0.52493in + 3.6859in + 0.65513in + 1.93674in + 9 + + + Top + + + + true + true + + + + + Nombre + + + + + + + + + + #4182bb + 1pt + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteNombre.Value + + + + + + + + + + #4182bb + 1pt + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Dirección + + + + + + + + + + #4182bb + 1pt + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteDireccion.Value + + + + + + + + + + #4182bb + 1pt + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Ciudad + + + + + + + #4182bb + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteLugar.Value + + + + + + + + + + + + + + #4182bb + 1pt + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Folio Fiscal: + + + + + + + Textbox54 + 5.89981in + 1.68632in + 0.18056in + 4.03672in + 16 + + + + + + + White + + + + + + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + No. Serie del Certificado del SAT: + + + + + + + Textbox54 + 6.09426in + 1.68632in + 0.18056in + 4.03672in + 17 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha y Hora de certificación: + + + + + + + Textbox54 + 6.29281in + 1.68632in + 0.19444in + 4.03672in + 18 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Certificado del Contribuyente: + + + + + + + Textbox54 + 6.49842in + 1.68632in + 0.19445in + 4.03672in + 19 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FolioFiscal.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!SerieCertificadoSAT.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FechaCertificacion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!CertificadoContribuyente.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Régímen: Sociedad Anónima de Capital Variable; Condiciones de pago: + + + + =IIF(Parameters!CondicionPago.Value.ToString="","No Identificado",Parameters!CondicionPago.Value) + + + + ; Método de Pago: + + + + =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) + + + + ; Num. Cta Pago: + + + + =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Éste documento es una representación impresa de un CFDi + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + true + true + + + + + P A G A R E con Folio + + + + =Parameters!Serie.Value + + + + - + + + + =Parameters!Folio.Value + + + + Por éste pagare prometo (emos) pagar incondicionalmente a la orden de PAOLA CASTILLO VALENZUELA, a su vencimiento el + + + + =Parameters!Vencimiento.Value + + + + , en Hermosillo, Sonora o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ + + + + =Parameters!Total.Value + + + + SON: ( + + + + =Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) + + + + ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a Soluciones en Telemedición JAR SA de CV o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a + + + + =CDATE(Parameters!Fecha.Value).ToString("dd/MM/yyyy") + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Nombre: + + + + =Parameters!ClienteNombre.Value + + + + + + + =Parameters!ClienteDireccion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Acepto de conformidad + + + + + + 2pt + 2pt + 2pt + 2pt + + + + 0.29357cm + 0.09963cm + 0cm + 0.57653cm + 3 + + + + + + 0.29357cm + 0.73559cm + 0cm + 0.57653cm + 4 + + + + + + 0.29357cm + 1.35545cm + 0cm + 0.57653cm + 5 + + + + + + 0.29357cm + 1.80439cm + 0cm + 0.57653cm + 6 + + + + + + 0.29357cm + 2.37686cm + 0cm + 0.57653cm + 7 + + + + + + 0.29357cm + 3.01789cm + 0cm + 0.57653cm + 8 + + + + + + 0.29357cm + 3.65558cm + 0cm + 0.57653cm + 9 + + + + + + 0.29357cm + 4.29154cm + 0cm + 0.57653cm + 10 + + + + + + 0.29357cm + 4.92728cm + 0cm + 0.57653cm + 11 + + + + + + 0.29357cm + 5.25981cm + 0cm + 0.57653cm + 12 + + + + + + 0.29357cm + 5.89576cm + 0cm + 0.57653cm + 13 + + + + + + 0.29357cm + 6.50505cm + 0cm + 0.57653cm + 14 + + + + + + 0.29357cm + 7.18531cm + 0cm + 0.57653cm + 15 + + + + + + 0.29357cm + 7.82127cm + 0cm + 0.57653cm + 16 + + + + + + 0.29357cm + 8.48346cm + 0cm + 0.57653cm + 17 + + + + + + 0.29357cm + 8.81599cm + 0cm + 0.57653cm + 18 + + + + + + 0.29357cm + 9.45195cm + 0cm + 0.57653cm + 19 + + + + + + 0.29357cm + 10.11415cm + 0cm + 0.57653cm + 20 + + + + + + 0.29357cm + 14.08927cm + 0cm + 0.57653cm + 21 + + + + + + 0.29357cm + 14.72523cm + 0cm + 0.57653cm + 22 + + + + + + 0.29357cm + 15.33451cm + 0cm + 0.57653cm + 23 + + + + + + 0.29357cm + 15.64058cm + 0cm + 0.57653cm + 24 + + + + + + 0.29357cm + 16.27654cm + 0cm + 0.57653cm + 25 + + + + + + 0.29357cm + 16.91228cm + 0cm + 0.57653cm + 26 + + + + + + 0.29357cm + 10.76463cm + 0cm + 0.57653cm + 27 + + + + + + 0.29357cm + 11.42705cm + 0cm + 0.57653cm + 28 + + + + + + 0.29357cm + 12.06279cm + 0cm + 0.57653cm + 29 + + + + + + 0.29357cm + 12.36886cm + 0cm + 0.57653cm + 30 + + + + + + 0.29357cm + 12.89898cm + 0cm + 0.57653cm + 31 + + + + + + 0.29357cm + 13.53472cm + 0cm + 0.57653cm + 32 + + + + + + 0.29357cm + 18.40663cm + 0cm + 0.57653cm + 33 + + + + + + 0.29357cm + 19.04259cm + 0cm + 0.57653cm + 34 + + + + + + 0.29357cm + 17.74353cm + 0cm + 0.57653cm + 35 + + + + + + 3.29402cm + 15.33451cm + 0cm + 4.58211cm + 36 + + + + + + true + 18.43647cm + 0.23734cm + 4.04843cm + 20.06179cm + 26 + + = (Parameters!AplicaPagare.Value="0" ORelse Parameters!AplicaPagare.Value="") + + + + + + + + + + 2.12527cm + + + 2.02474cm + + + 10.17786cm + + + 2.52862cm + + + 3.15415cm + + + + + 0.52063cm + + + + + true + + + + + Cantidad + + + + + + + Textbox34 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Unidad + + + + + + + Textbox53 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Descripción + + + + + + + Textbox79 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + P. Unitario + + + + + + + Textbox84 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Importe + + + + + + + + + + + + + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.4148cm + + + + + true + true + + + + + =Fields!Cantidad.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!UM.Value + + + + + + + UM1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PS.Value &Fields!Obs.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PU.Value + + + + + + + PU1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Cantidad.Value*Fields!PU.Value + + + + + + + Textbox88 + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.08406cm + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + Before + + + + DsOC + 4.59222cm + 0.21226cm + 1.01949cm + 20.01064cm + 27 + + + + + + true + + + + + RFC: + + + + =Parameters!ClienteRFC.Value + + + + + + + + + + + + + + #4182bb + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 0.81245in + + + 0.69098in + + + 0.69475in + + + + + 0.19645in + + + + + true + true + + + + + Impuesto + + + + + + + Textbox22 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Tasa + + + + + + + Textbox15 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Importe + + + + + + + Textbox29 + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.14436in + + + + + true + true + + + + + =Fields!Impuesto.Value + + + + + + + Cantidad1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!tasa.Value + + + + + + + UM + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Codigo + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet3 + 2.54983in + 5.77254in + 0.34081in + 2.19818in + 29 + + + + + + + + + 3.01975cm + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + + + + + + + + + + + + =Fields!ImpuestoLocal.Value + + + + 2.56368cm + + + true + true + + + + + =Fields!ImpuestoLocal.Value + + + + + + #4182bb + 2pt + 2pt + 2pt + 2pt + + + + + + + + DataSet1 + 5.75282cm + 14.66222cm + 0.6cm + 5.58343cm + 30 + + + + + + + + + 3.33888cm + + + 11.00525cm + + + + + 0.6cm + + + + + true + true + + + + + =Parameters!Observaciones.Value + + + + + + + Textbox128 + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + Importe con letra: + + + + + + + Textbox126 + + + + + + + + + + + + #4182bb + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + ="SON: " & Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) + + + + + + + Textbox127 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Forma de pago: + + + + + + + Textbox130 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #4182bb + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FormaPago.Value + + + + + + + Textbox131 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Uso CFDI: + + + + + + + Textbox15 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #4182bb + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!UsoCFDI.Value + + + + + + + Textbox17 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 1.56188cm + + + + + true + true + + + + + Sello digital del CFDI: + + + + + + + Textbox132 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #4182bb + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SelloCFDI.Value + + + + + + + Textbox133 + + + Top + 2pt + 2pt + 2pt + 2pt + + + + + + + + 1.2cm + + + + + true + true + + + + + Sello del SAT: + + + + + + + Textbox134 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + #4182bb + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SelloSAT.Value + + + + + + + Textbox135 + + + Top + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Cadena original del complemento de certificación digital del SAT: + + + + + + + Textbox136 + + + + + + + + + + + + + + 1pt + + #4182bb + Middle + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + DsOC + 5.75282cm + 0.21226cm + 5.76188cm + 14.34413cm + 31 + + + + + + true + true + + + + + =Parameters!CadenaOriginal.Value + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Nombre Comercial: + + + + + + + + + Beneficiario: + + + + + + + + + + + + + Banco: + + + + + + + + + + + + + Clabe: + + + + + + + + + Cuenta: + + + + + + + + + + + Textbox1 + 12.64886cm + 0.18154cm + 2.03294cm + 10.03331cm + 33 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Servicios Especializados en TI + + + + + + + + + Paola Castillo Valenzuela + + + + + + + + + Bbva Bancomer + + + + + + + + + 012760 0295 6695 3887 + + + + + + + + + 29 5669 5388 + + + + + + + Textbox1 + 12.64885cm + 10.21485cm + 2.03294cm + 10.08428cm + 34 + + + 2pt + 2pt + 2pt + 2pt + + + + Embedded + SETIVERDE2 + FitProportional + 0.03532cm + 0cm + 1.67893cm + 5.10541cm + 35 + + + + + + 22.4849cm +