From 354306e5a5584045d7394330e31e7e3453bf616e Mon Sep 17 00:00:00 2001 From: rrene Date: Sat, 15 Jul 2023 10:25:11 -0700 Subject: [PATCH] =?UTF-8?q?--=20comentado=20de=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bancos/IE.aspx.vb | 1153 +++++++++++++++++++++++---------------------- 1 file changed, 577 insertions(+), 576 deletions(-) diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 4067c7eb5..06f55f91d 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -1897,585 +1897,586 @@ Partial Class Bancos_IE #End Region -#Region "VIATICOS" + '#Region "VIATICOS" - Private Function TimbrarNomina12(CvePersonal As Integer) As String + ' Private Function TimbrarNomina12(CvePersonal As Integer) As String - Dim Retorno As String = "" - UsuarioActual.Empresa.CvePAC = 2 - Dim sw As New Diagnostics.Stopwatch - sw.Start() - Select Case UsuarioActual.Empresa.CvePAC - Case 1 - 'Retorno = TimbrarBIInformNomina12(CveNomina, CvePersonal, CvePeriodo) - Case 2, 4 - Dim cfdi As CFDITimbre = PreTimbrar(CvePersonal) - If cfdi Is Nothing Then - sw.Stop() - Return "No tiene asignado un folio de viaticos" - End If - If cfdi IsNot Nothing AndAlso cfdi.Mensaje = "" Then - Dim ObjTimbrado As New Timbrado - Dim ObjFactura As New Modelos.Factura - ObjFactura.TipoDocto = "Viaticos" - ObjFactura.Folio = cfdi.Comprobante.Folio.ToEntero - ObjFactura.Serie = cfdi.Comprobante.Serie - ObjFactura.Timbre = cfdi - If Not ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then - Retorno = ObjTimbrado.MensajeErrorCFDI - End If + ' Dim Retorno As String = "" + ' UsuarioActual.Empresa.CvePAC = 2 + ' Dim sw As New Diagnostics.Stopwatch + ' sw.Start() + ' Select Case UsuarioActual.Empresa.CvePAC + ' Case 1 + ' 'Retorno = TimbrarBIInformNomina12(CveNomina, CvePersonal, CvePeriodo) + ' Case 2, 4 + ' Dim cfdi As CFDITimbre = PreTimbrar(CvePersonal) + ' If cfdi Is Nothing Then + ' sw.Stop() + ' Return "No tiene asignado un folio de viaticos" + ' End If + ' If cfdi IsNot Nothing AndAlso cfdi.Mensaje = "" Then + ' Dim ObjTimbrado As New Timbrado + ' Dim ObjFactura As New Modelos.Factura + ' ObjFactura.TipoDocto = "Viaticos" + ' ObjFactura.Folio = cfdi.Comprobante.Folio.ToEntero + ' ObjFactura.Serie = cfdi.Comprobante.Serie + ' ObjFactura.Timbre = cfdi + ' If Not ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then + ' Retorno = ObjTimbrado.MensajeErrorCFDI + ' End If - 'Retorno = TimbrarFacturaRealVirtual(cfdi, UsuarioActual) - If Retorno <> "" Then - Retorno = $"{Retorno} - {cfdi.Receptor.Nombre}" - Else - 'Genero la addenda Ford - ' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo) - End If - Else - Retorno = $"No se pudo generar el pretimbre:
{cfdi.Mensaje}" - End If - End Select - sw.Stop() - GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC, "Nomina") - - Return Retorno - - End Function - - - - - Private Function PreTimbrar(CvePersonal As Integer) As CFDITimbre - Dim cfdi As New CFDITimbre - Dim ObjFolio As New ClsGralFolios - If ObjFolio.GetFolios("VIA", UsuarioActual.CveEmpresa) Then - If ObjFolio.DtResultados.Rows.Count > 0 Then - Folio = ObjFolio.DtResultados.Rows(0)("FActual").ToString - Else - ObjFolio.Dispose() - Return Nothing - End If - End If - ObjFolio.Dispose() - - Dim objPersonal As New ClsRH - objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) - - Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero - - cfdi.Nomina = New CFDINomina - cfdi.Nomina.Version = "1.2" - cfdi.Nomina.TipoNomina = "E" - cfdi.Nomina.FechaPago = TxtFechaDocumento.Text.ToDate - cfdi.Nomina.FechaInicio = TxtFechaDocumento.Text - cfdi.Nomina.FechaFin = TxtFechaDocumento.Text - cfdi.Nomina.NumDiasPagados = 1 - cfdi.Emisor.Nombre = UsuarioActual.Empresa.Empresa - cfdi.Emisor.RFC = UsuarioActual.Empresa.RFC - cfdi.Emisor.RegistroPatronal = objPersonal.DtResultados.Rows(0)("RegistroPatronal").ToString() - cfdi.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal - - 'aplica persona fisica debe de tener CURP - If cfdi.Emisor.RegimenFiscal.Contiene("605", "606", "608", "611", "612", "614", "616", "621", "622", "629", "630", "615") Then - cfdi.Emisor.CURP = UsuarioActual.Empresa.CURP - End If - - - cfdi.Receptor.UsoCFDI = "P01" - cfdi.Receptor.RFC = objPersonal.RFC - cfdi.Receptor.Nombre = objPersonal.NombreCompleto - - Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) - ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = "003", - .Clave = "003", - .Concepto = "Viáticos (entregados al trabajador).", - .Importe = TxtImporte.Text.ToString.ToDecimal - } - ) - If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos - - cfdi.Comprobante.Version = "3.3" - cfdi.Comprobante.Serie = "VIA" - cfdi.Comprobante.Folio = Folio - cfdi.Comprobante.Fecha = Now - cfdi.Comprobante.Subtotal = TxtImporte.Text.ToDecimal - cfdi.Comprobante.Descuentos = 0 - cfdi.Comprobante.Total = TxtImporte.Text.ToDecimal - cfdi.Comprobante.MotivoDescuento = "" - cfdi.Comprobante.Moneda = "MXN" - cfdi.Comprobante.TipoComprobante = "N" - cfdi.Comprobante.TipoDocto = "Egs" - cfdi.Comprobante.MetodoPago = "PUE" - cfdi.Comprobante.CondicionesdePago = "" - cfdi.Comprobante.FormadePago = "99" - cfdi.Comprobante.LugarExpedicion = UsuarioActual.Empresa.CP.ToString - cfdi.Comprobante.NumCuentaPago = "" - - - cfdi.Nomina.Receptor.CURP = objPersonal.CURP - cfdi.Nomina.Receptor.NSS = objPersonal.NumeroSS - cfdi.Nomina.Receptor.FechaInicioContrato = objPersonal.FechaInicioContrato.ToShortDateString - cfdi.Nomina.Receptor.Antiguedad = $"P{AntiguedadSemanas}W" - cfdi.Nomina.Receptor.TipoContrato = objPersonal.CodigoTipoContrato - cfdi.Nomina.Receptor.CodigoTipoJornada = objPersonal.ClaveTipoJornada - cfdi.Nomina.Receptor.CodigoRegimenContratacion = If(objPersonal.CveRegimenContratacion = "", "99", objPersonal.CveRegimenContratacion) - cfdi.Nomina.Receptor.CodigoEmpleado = objPersonal.Codigo - cfdi.Nomina.Receptor.Departamento = objPersonal.Departamento - cfdi.Nomina.Receptor.Puesto = objPersonal.Puesto - cfdi.Nomina.Receptor.CodigoRiesgoPuesto = If(objPersonal.CveSATRiesgoPuesto.ToString = "0", "99", objPersonal.CveSATRiesgoPuesto.ToString) - cfdi.Nomina.Receptor.TipoPeriodo = objPersonal.TipoPeriodoPago - cfdi.Nomina.Receptor.CodigoBanco = objPersonal.ClaveBanco - cfdi.Nomina.Receptor.NumeroCuenta = objPersonal.BancoNumCuenta - cfdi.Nomina.Receptor.SDI = objPersonal.SDI - cfdi.Nomina.Receptor.SBC = objPersonal.SDI - cfdi.Nomina.Receptor.Sindicalizado = "" - cfdi.Nomina.Receptor.CodigoEntidadFederativa = objPersonal.ClaveEstado - - - cfdi.Conceptos.Add(New CFDIConceptos With {.Cantidad = 1, .ClaveUnidad = "ACT", .ClaveProdServ = "84111505", .Descripcion = "Pago de nómina", .ValorUnitario = cfdi.Comprobante.Subtotal, .Importe = cfdi.Comprobante.Subtotal, .Descuento = cfdi.Nomina.TotalDeducciones.ToDecimal}) - - objPersonal.Dispose() - Return cfdi - End Function - - 'Private Function TimbrarBIInformNomina12(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer) As String - - ' If UsuarioActual.CveEmpresa = 8 Then - ' UsuarioActual.Empresa.FacturaProduccion = True - ' End If - ' 'UsuarioActual.Empresa.FacturaProduccion = False - - ' Dim MsgError As String = String.Empty - - ' Dim CFDi As New ClbNegBICFDv3_2.ClsNegEDI - ' CFDi.ObjCompNomina12 = New ClbNegBICFDv3_2.ClsNegComplementoNomina12() - ' 'CFDi.ObjCompNomina = New ClbNegBICFDv3_2.ClsNegCompNomina - - ' Dim objPersonal As New ClsRH - ' 'Dim objNomina As New ClsNominas - ' objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) - ' 'objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) - - - ' Dim Total As Decimal = 0 - ' Dim SubTotal As Decimal = 0 - ' Dim Descuentos As Decimal = 0 - ' Dim RetISR As Decimal = 0 - ' Dim TotalExcento As Decimal = 0 - ' Dim TotalGravado As Decimal = 0 - ' Dim TotalPercepciones As Decimal = 0 - ' Dim TotalDeducciones As Decimal = 0 - ' Dim TotalOtrosPagos As Decimal = 0 - - ' Dim Serie As String = "" - ' Dim Folio As String = "" - ' Dim NominaFolio As String = Serie & "-" & Folio - ' Dim RFC As String = objPersonal.RFC.Trim - ' Dim Nombre As String = objPersonal.NombreCompleto.Trim - ' Dim Direccion As String = String.Format("{0} {1} {2}", objPersonal.Calle.Trim, objPersonal.NumExt.Trim, objPersonal.NumInt.Trim).Trim - ' Dim Ciudad As String = objPersonal.Ciudad.Trim - ' Dim Estado As String = objPersonal.Estado.Trim - ' Dim CP As String = objPersonal.CP.Trim - - - - ' 'Dim TipoContrato As String = GlobalDTTiposContrato.FiltraParametros("CveTipoContrato = " + objPersonal.CveTipoContrato.ToString)(0)("TipoContrato").ToString - ' 'Dim TipoPeriodo As String = GlobalDTTipoPeriodo.FiltraParametros("CveTipoPeriodo = " + objPersonal.CveTipoPeriodo.ToString)(0)("TipoPeriodo").ToString - ' Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero - ' Dim FormatoReciboCFDi As String = objPersonal.FormatoReciboCFDi - - ' Dim FechaInicio, FechaFin, FechaPago As Date - ' Dim DiasPagados As Integer = 0 - ' Dim Msg As String = String.Empty - ' Dim DiasIncapacitados As Integer = 0 - ' Dim DrPeriodo As DataRow = Nothing - - ' Dim ObjFolio As New ClsGralFolios - ' If ObjFolio.GetFolios("VIA", UsuarioActual.CveEmpresa) Then - ' If ObjFolio.DtResultados.Rows.Count > 0 Then - ' Folio = ObjFolio.DtResultados.Rows(0)("FActual").ToString - ' End If - ' End If - - - ' 'If objNomina.GetPeriodos(-1, -1, -1, -1, CvePeriodo) Then - ' ' If objNomina.DtResultados.Rows().Count > 0 Then - ' ' DrPeriodo = objNomina.DtResultados.Rows(0) - ' ' End If - ' 'End If - ' 'Dim DrPeriodo As DataRow = GlobalDTNominasPeriodos(-1, CvePeriodo, -1).FiltroPrimero("") - ' If DrPeriodo IsNot Nothing Then - ' FechaInicio = DrPeriodo("FechaInicio").ToString.ToDate - ' FechaFin = DrPeriodo("FechaFin").ToString.ToDate - ' FechaPago = DrPeriodo("FechaPago").ToString.ToDate - ' If objPersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then - - ' Dim Asistencias As Integer = objPersonal.DtResultados.SUM("AplicaAsistencia").ToEntero - ' Dim Vacaciones As Integer = objPersonal.DtResultados.SUM("AplicaVacacion").ToEntero - ' DiasIncapacitados = objPersonal.DtResultados.SUM("AplicaIncapacidad").ToEntero - ' DiasPagados = Asistencias - Vacaciones - ' If DiasPagados < 0 Then DiasPagados = 0 - - ' End If - - ' End If - - ' Dim DtPercepciones As Data.DataTable = Nothing - ' Dim DtDeducciones As Data.DataTable = Nothing - ' Dim DtOtrosPagos As Data.DataTable = Nothing - ' 'If objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then - ' ' If objNomina.DtResultados.Rows.Count > 0 Then - ' ' DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ") - ' ' DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") - ' ' TotalPercepciones = DtPercepciones.SUM("Importe") - ' ' TotalDeducciones = DtDeducciones.SUM("Importe") - ' ' Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal) - ' ' End If - ' 'End If - - ' 'Tipo Nomina O de Ordinaria o E de extraordinaria - ' 'Dim FechaPago As Date = Now - ' Dim TotalSueldos As Decimal = 0 - ' Dim TotalIndemnizacion As Decimal = 0 - ' Dim TotalJubilacion As Decimal = 0 - ' Msg = CFDi.ObjCompNomina12.Cargar("O", FechaPago, FechaInicio, FechaFin, DiasPagados, TotalPercepciones, TotalDeducciones, 0) - - - - ' If Msg = String.Empty Then - ' If DtPercepciones IsNot Nothing Then - ' If DtPercepciones.Rows.Count > 0 Then - ' TotalSueldos = DtPercepciones.SUM("Importe", "SATCveConcepto = '001'") - ' TotalIndemnizacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('022','023','025')") ' https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf - ' TotalJubilacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('039','044')") 'https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf - ' Msg = CFDi.ObjCompNomina12.CargarPercepciones(TotalSueldos, TotalIndemnizacion, TotalJubilacion, DtPercepciones.SUM("ImporteGravado").ToDecimal, DtPercepciones.SUM("ImporteExento").ToDecimal) - ' End If - ' For Each Row As DataRow In DtPercepciones.Rows - ' If Row("Importe").ToString.ToDecimal > 0 Then - ' If Row("CveSATConcepto").ToString = "" Then - ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) + ' 'Retorno = TimbrarFacturaRealVirtual(cfdi, UsuarioActual) + ' If Retorno <> "" Then + ' Retorno = $"{Retorno} - {cfdi.Receptor.Nombre}" ' Else - ' Msg = CFDi.ObjCompNomina12.AgregarPercepcion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, Row("ImporteGravado").ToString.ToDecimal, Row("ImporteExento").ToString.ToDecimal) - ' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal - ' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal - ' SubTotal = SubTotal + Row("Importe").ToString.ToDecimal - ' End If - - ' If Msg <> String.Empty Then - ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Percepcion", New Exception) - ' Exit For - ' End If - ' End If - ' 'RMF, falta poner el numero de horas pagadas - ' If Row("CveSATConcepto").ToString.ToEntero = 19 Then 'cuando son horas extras - - ' 'Obtengo el desglose de horas extras - - ' If objNomina.GetHorasExtras(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - - ' Dim dr As DataRow = objNomina.DtResultados.FiltroPrimero("") - ' If dr IsNot Nothing Then - - ' If dr("HorasDobles").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasDobles").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Dobles, dr("HorasDobles").ToString.ToEntero, Row("Importe").ToString.ToDecimal) - ' If dr("HorasTriples").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasTriples").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Triples, dr("HorasTriples").ToString.ToEntero, Row("Importe").ToString.ToDecimal) - - - ' End If - - - ' End If - - ' End If - ' Next - ' If Msg = "" Then - ' CFDi.ObjCompNomina12.ObjPercepciones.TotalExento = TotalExcento - ' CFDi.ObjCompNomina12.ObjPercepciones.TotalGravado = TotalGravado - ' End If - - ' End If - - ' 'cargo las incapacidades - ' If DiasIncapacitados > 0 Then - - ' If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - - ' CFDi.ObjCompNomina12.CargarIncapacidades() - ' For Each dr As DataRow In objNomina.DtResultados.Rows - ' CFDi.ObjCompNomina12.AgregarIncapacidad(dr("Dias").ToString.ToDecimal, dr("ClaveTipoIncapacidad").ToString.ToEntero, dr("Descuento").ToString.ToDecimal) - ' Next - - ' End If - - ' End If - - - - ' TotalExcento = 0 - ' TotalGravado = 0 - - ' If Msg = String.Empty Then - ' If DtDeducciones IsNot Nothing Then - ' If DtDeducciones.Rows.Count > 0 Then - ' Total = CType((Total - DtDeducciones.SUM("Importe")), Decimal) - ' CFDi.ObjCompNomina12.CargarDeducciones(CType(DtDeducciones.SUM("ImporteGravado"), Decimal), CType(DtDeducciones.SUM("ImporteExento"), Decimal)) - ' End If - ' For Each Row As DataRow In DtDeducciones.Rows - - ' If Row("Importe").ToString.ToDecimal > 0 Then - ' If Row("CveSATConcepto").ToString = "" Then - ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) - ' Else - - ' Msg = CFDi.ObjCompNomina12.AgregarDeduccion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) - ' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal - ' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal - - ' If Row("CveSATConcepto").ToString.ToEntero = 3 Then - ' RetISR = RetISR + Row("Importe").ToString.ToDecimal - ' Else - ' Descuentos = Descuentos + Row("Importe").ToString.ToDecimal - ' End If - ' End If - - ' If Msg <> String.Empty Then - ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Deduccion", New Exception) - ' Exit For - ' End If - ' End If - ' Next - ' If Msg = "" Then - ' If CFDi.ObjCompNomina12.ObjDeducciones IsNot Nothing Then - ' CFDi.ObjCompNomina12.ObjDeducciones.TotalOtrasDeducciones = Descuentos - ' CFDi.ObjCompNomina12.ObjDeducciones.TotalImpuestosRetenidos = RetISR - ' End If - - ' End If - ' End If - - ' If Msg = String.Empty Then - ' If DtOtrosPagos IsNot Nothing Then - ' If DtOtrosPagos.Rows.Count > 0 Then - ' Total = CType((Total - DtOtrosPagos.SUM("Importe")), Decimal) - ' CFDi.ObjCompNomina12.CargarOtrosPagos() - ' End If - - ' For Each Row As DataRow In DtOtrosPagos.Rows - ' If Row("Importe").ToString.ToDecimal > 0 Then - ' If Row("CveSATConcepto").ToString = "" Then - ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) - ' Else - ' Msg = CFDi.ObjCompNomina12.AgregarOtroPago(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) - ' 'Msg = CFDi.ObjCompNomina12.CargarSubsidioAlEmpleo(0) - ' 'Msg = CFDi.ObjCompNomina12.CargarCompensacionSaldosAFavor(0, 0, 0) - ' End If - - ' If Msg <> String.Empty Then - ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Otros Pagos", New Exception) - ' Exit For - ' End If - ' End If - ' Next - - ' End If - - ' If Msg = String.Empty Then - ' Dim x As Integer = 0 - - ' Dim Moneda As String = "MXN" - ' Dim LugarExp As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} ", SucCalle, SucNoExt, SucNoInt, SucColonia, SucLocalidad, SucMunicipio, SucEstado, SucPais, SucCP) - ' Dim FechaFactura As DateTime = Now - ' 'Nodo Comprobante - - ' Dim TipoComprobante As ClbNegBICFDv3_2.TipoDeComprobante = ClbNegBICFDv3_2.TipoDeComprobante.egreso - ' Msg = CFDi.comprobantecfd(0, 0, Serie, Folio, FechaFactura, "PAGO EN UNA SOLA EXHIBICION", "CONTADO", SubTotal, Descuentos, "Deducciones nómina", "1", Moneda, Total, objPersonal.MetodoPagoSAT, ClbNegBICFDv3_2.TipoDeComprobante.egreso, LugarExp, "", "", "", New Date(1900, 1, 1), 0) - - ' If Msg = String.Empty Then - ' 'Nodo emisor - ' Msg = CFDi.ObjCompNomina12.CargarEmisor("", objPersonal.DtResultados.Rows(0)("RegistroPatronal").ToString(), UsuarioActual.Empresa.RFC) - ' 'If Msg = String.Empty Then Msg = CFDi.EmisorRegimen(UsuarioActual.Empresa.CodigoRegimenFiscal) - ' If Msg = String.Empty Then - ' 'Nodo Entidad SNCF - ' If 1 = 2 Then 'cuando es gobierno - ' Msg = CFDi.ObjCompNomina12.CargarEntidadSNCF("", 0) - ' End If - - ' If Msg = String.Empty Then - ' 'Nodo Receptor - ' Msg = CFDi.ObjCompNomina12.CargarReceptor(objPersonal.CURP, objPersonal.NumeroSS, objPersonal.FechaInicioContrato, AntiguedadSemanas, objPersonal.TipoContrato, "", objPersonal.ClaveTipoJornada, objPersonal.CveRegimenContratacion, objPersonal.Codigo.ToString, - ' objPersonal.Departamento, objPersonal.Puesto, objPersonal.CveRiesgoPuesto, objPersonal.TipoPeriodo, objPersonal.ClaveBanco, objPersonal.BancoNumCuenta, Total, objPersonal.SDI.ToString.ToDecimal, objPersonal.ClaveEstado) - ' If Msg = String.Empty Then - ' 'Nodo SubContratacion - ' If 1 = 2 Then Msg = CFDi.ObjCompNomina12.AgregarSubContratacion("", 0) - ' If Msg = String.Empty Then - - ' CFDi.LstCompNomina12.Add(CFDi.ObjCompNomina12) - - ' Dim HasErrorConceptos As Boolean = False - ' 'Dim Importe As Decimal = 0 - - - ' Msg = CFDi.ConceptosCfd(1, "ACT", "", "Pago de nómina", SubTotal, SubTotal) - - ' 'Timbrado - - ' 'Web Services de producción: http://biinform.com.mx/srvCFDi/service1.asmx - ' 'Web Services de pruebasd: http://biinform.com.mx/srvCFDiPrueba/service1.asmx - - - ' Dim WS As String = String.Empty - ' If UsuarioActual.Empresa.FacturaProduccion Then - ' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx" - ' Else - ' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx" - ' End If - - ' If Not System.IO.Directory.Exists(Ruta & "XML\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\") - ' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\") - - ' 'Generar Timbre - ' 'If UsuarioActual.Empresa.FacturaProduccion Then - ' If 1 = 2 Then - ' CFDi.Generar(String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoPfx), - ' UsuarioActual.Empresa.ContraseñaKey, - ' String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoCer), - ' String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), - ' String.Format("{0}Certificados\", Ruta), - ' UsuarioActual.Empresa.BIUsuario, - ' UsuarioActual.Empresa.BIContraseña, - ' WS, - ' True) - ' Else - ' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\Demo\") - ' 'RutaPruebas & "XML\Demo\" & NominaFolio & ".xml", - ' CFDi.Generar(String.Format("{0}Certificados\aaa010101aaa__csd_01.pfx", RutaPruebas), - ' "12345678a", - ' String.Format("{0}Certificados\aaa010101aaa__csd_01.cer", RutaPruebas), - ' String.Format("{0}XML\Nomina\Demo\{1}.xml", Ruta, NominaFolio), - ' String.Format("{0}Certificados\", RutaPruebas), - ' "prueba", - ' "123", - ' WS, - ' True) - ' End If - - - ' If CFDi.MsgError <> String.Empty Then - - ' 'OnError("Ocurrió un error al generar el timbre: " & CFDi.MsgError, New Exception) - - ' Dim params As New ActualizaTimbre - ' params.Estatus = False - ' params.CveNomina = CveNomina - ' params.CvePAC = 1 - - ' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado) - ' 'Hilo.Start(params) - ' BtnAutorizar.Enabled = False - ' MsgError = "Nombre: " & Nombre & ". Error: " & CFDi.MsgError - ' Else - ' 'Actualiza Estatus Timbrado - ' Dim params As New ActualizaTimbre - ' params.Estatus = True - ' params.CveNomina = CveNomina - ' params.CvePAC = 1 - - ' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado) - ' 'Hilo.Start(params) - - ' Dim CBB As New ClbNegBICFDv3_2.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 - ' ViewState("FolioFiscal") = FolioFiscal - - ' 'Actualiza Estatus Factura - ' CveNominaT = CveNomina - - ' Dim Rastro As String = String.Format("Nomina: CvePeriodo:{0}, CvePersonal:{1}, UUID: {2}, RFC:{3}", CvePeriodo, CvePersonal, FolioFiscal, objPersonal.RFC) - ' Rastro.GuardaLog() - - ' If FolioFiscal <> "" Then - - ' 'If UsuarioActual.Empresa.FacturaProduccion Then - ' ' Dim ObjNomina2 As New ClsNominas() - ' ' ObjNomina2.UpdateEstatusNomNominas(3, UsuarioActual.Empresa.CvePAC, FolioFiscal, "", ("01/01/2000").ToDate, CveNomina, SubTotal, Descuentos, RetISR, Total, DiasPagados) - ' ' ObjNomina2.Dispose() - ' 'End If - ' Rastro = "--Estatus" & Rastro - ' Rastro.GuardaLog() - ' 'Dim Hilo1 As New System.Threading.Thread(AddressOf ActualizaEstatus) - ' 'Hilo1.Start(3) - ' End If - - - ' Dim RutaCBB As String = String.Empty - ' If Not System.IO.Directory.Exists(Ruta & "CBB\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\") - ' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\") - - ' If UsuarioActual.Empresa.FacturaProduccion Then - ' RutaCBB = Ruta & "CBB\Nomina\" & NominaFolio & ".jpg" - ' Else - ' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\Demo\") - ' RutaCBB = Ruta & "CBB\Nomina\Demo\" & NominaFolio & ".jpg" - ' End If - ' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFC, Total, FolioFiscal, RutaCBB) - - - ' 'GeneraPDF(FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, TmpDT, SelloCFDi, SelloSAT, RutaCBB, VentaFolio, Ruta & "XML\" & VentaFolio & ".xml", False, CFDi.CadenaOriginal) - ' 'GeneraPDF(CveNomina, CvePersonal, CvePeriodo, FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT, RutaCBB, Ruta & "Nomina\XML\" & NominaFolio & ".xml", False, CFDi.Timbrado.CadenaOriginal, FormatoReciboCFDi) - ' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' 'Genero la addenda Ford + ' ' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo) ' End If ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' Retorno = $"No se pudo generar el pretimbre:
{cfdi.Mensaje}" ' End If + ' End Select + ' sw.Stop() + ' GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC, "Nomina") + + ' Return Retorno + + ' End Function + + + + + ' Private Function PreTimbrar(CvePersonal As Integer) As CFDITimbre + ' Dim cfdi As New CFDITimbre + ' Dim ObjFolio As New ClsGralFolios + ' If ObjFolio.GetFolios("VIA", UsuarioActual.CveEmpresa) Then + ' If ObjFolio.DtResultados.Rows.Count > 0 Then + ' Folio = ObjFolio.DtResultados.Rows(0)("FActual").ToString ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' ObjFolio.Dispose() + ' Return Nothing ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) - ' End If - ' objPersonal.Dispose() - ' objNomina.Dispose() + ' ObjFolio.Dispose() - ' Return MsgError - 'End Function + ' Dim objPersonal As New ClsRH + ' objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) + + ' Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero + + ' cfdi.Nomina = New CFDINomina + ' cfdi.Nomina.Version = "1.2" + ' cfdi.Nomina.TipoNomina = "E" + ' cfdi.Nomina.FechaPago = TxtFechaDocumento.Text.ToDate + ' cfdi.Nomina.FechaInicio = TxtFechaDocumento.Text + ' cfdi.Nomina.FechaFin = TxtFechaDocumento.Text + ' cfdi.Nomina.NumDiasPagados = 1 + ' cfdi.Emisor.Nombre = UsuarioActual.Empresa.Empresa + ' cfdi.Emisor.RFC = UsuarioActual.Empresa.RFC + ' cfdi.Emisor.RegistroPatronal = objPersonal.DtResultados.Rows(0)("RegistroPatronal").ToString() + ' cfdi.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal + + ' 'aplica persona fisica debe de tener CURP + ' If cfdi.Emisor.RegimenFiscal.Contiene("605", "606", "608", "611", "612", "614", "616", "621", "622", "629", "630", "615") Then + ' cfdi.Emisor.CURP = UsuarioActual.Empresa.CURP + ' End If -#End Region + ' cfdi.Receptor.UsoCFDI = "P01" + ' cfdi.Receptor.RFC = objPersonal.RFC + ' cfdi.Receptor.Nombre = objPersonal.NombreCompleto + + ' Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) + ' ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = "003", + ' .Clave = "003", + ' .Concepto = "Viáticos (entregados al trabajador).", + ' .Importe = TxtImporte.Text.ToString.ToDecimal + ' } + ' ) + ' If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos + + ' cfdi.Comprobante.Version = "3.3" + ' cfdi.Comprobante.Serie = "VIA" + ' cfdi.Comprobante.Folio = Folio + ' cfdi.Comprobante.Fecha = Now + ' cfdi.Comprobante.Subtotal = TxtImporte.Text.ToDecimal + ' cfdi.Comprobante.Descuentos = 0 + ' cfdi.Comprobante.Total = TxtImporte.Text.ToDecimal + ' cfdi.Comprobante.MotivoDescuento = "" + ' cfdi.Comprobante.Moneda = "MXN" + ' cfdi.Comprobante.TipoComprobante = "N" + ' cfdi.Comprobante.TipoDocto = "Egs" + ' cfdi.Comprobante.MetodoPago = "PUE" + ' cfdi.Comprobante.CondicionesdePago = "" + ' cfdi.Comprobante.FormadePago = "99" + ' cfdi.Comprobante.LugarExpedicion = UsuarioActual.Empresa.CP.ToString + ' cfdi.Comprobante.NumCuentaPago = "" + + + ' cfdi.Nomina.Receptor.CURP = objPersonal.CURP + ' cfdi.Nomina.Receptor.NSS = objPersonal.NumeroSS + ' cfdi.Nomina.Receptor.FechaInicioContrato = objPersonal.FechaInicioContrato.ToShortDateString + ' cfdi.Nomina.Receptor.Antiguedad = $"P{AntiguedadSemanas}W" + ' cfdi.Nomina.Receptor.TipoContrato = objPersonal.CodigoTipoContrato + ' cfdi.Nomina.Receptor.CodigoTipoJornada = objPersonal.ClaveTipoJornada + ' cfdi.Nomina.Receptor.CodigoRegimenContratacion = If(objPersonal.CveRegimenContratacion = "", "99", objPersonal.CveRegimenContratacion) + ' cfdi.Nomina.Receptor.CodigoEmpleado = objPersonal.Codigo + ' cfdi.Nomina.Receptor.Departamento = objPersonal.Departamento + ' cfdi.Nomina.Receptor.Puesto = objPersonal.Puesto + ' cfdi.Nomina.Receptor.CodigoRiesgoPuesto = If(objPersonal.CveSATRiesgoPuesto.ToString = "0", "99", objPersonal.CveSATRiesgoPuesto.ToString) + ' cfdi.Nomina.Receptor.TipoPeriodo = objPersonal.TipoPeriodoPago + ' cfdi.Nomina.Receptor.CodigoBanco = objPersonal.ClaveBanco + ' cfdi.Nomina.Receptor.NumeroCuenta = objPersonal.BancoNumCuenta + ' cfdi.Nomina.Receptor.SDI = objPersonal.SDI.ToDecimal + ' cfdi.Nomina.Receptor.SBC = objPersonal.SDI.ToDecimal + + ' cfdi.Nomina.Receptor.Sindicalizado = "" + ' cfdi.Nomina.Receptor.CodigoEntidadFederativa = objPersonal.ClaveEstado + + + ' cfdi.Conceptos.Add(New CFDIConceptos With {.Cantidad = 1, .ClaveUnidad = "ACT", .ClaveProdServ = "84111505", .Descripcion = "Pago de nómina", .ValorUnitario = cfdi.Comprobante.Subtotal, .Importe = cfdi.Comprobante.Subtotal, .Descuento = cfdi.Nomina.TotalDeducciones.ToDecimal}) + + ' objPersonal.Dispose() + ' Return cfdi + ' End Function + + ' 'Private Function TimbrarBIInformNomina12(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer) As String + + ' ' If UsuarioActual.CveEmpresa = 8 Then + ' ' UsuarioActual.Empresa.FacturaProduccion = True + ' ' End If + ' ' 'UsuarioActual.Empresa.FacturaProduccion = False + + ' ' Dim MsgError As String = String.Empty + + ' ' Dim CFDi As New ClbNegBICFDv3_2.ClsNegEDI + ' ' CFDi.ObjCompNomina12 = New ClbNegBICFDv3_2.ClsNegComplementoNomina12() + ' ' 'CFDi.ObjCompNomina = New ClbNegBICFDv3_2.ClsNegCompNomina + + ' ' Dim objPersonal As New ClsRH + ' ' 'Dim objNomina As New ClsNominas + ' ' objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) + ' ' 'objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) + + + ' ' Dim Total As Decimal = 0 + ' ' Dim SubTotal As Decimal = 0 + ' ' Dim Descuentos As Decimal = 0 + ' ' Dim RetISR As Decimal = 0 + ' ' Dim TotalExcento As Decimal = 0 + ' ' Dim TotalGravado As Decimal = 0 + ' ' Dim TotalPercepciones As Decimal = 0 + ' ' Dim TotalDeducciones As Decimal = 0 + ' ' Dim TotalOtrosPagos As Decimal = 0 + + ' ' Dim Serie As String = "" + ' ' Dim Folio As String = "" + ' ' Dim NominaFolio As String = Serie & "-" & Folio + ' ' Dim RFC As String = objPersonal.RFC.Trim + ' ' Dim Nombre As String = objPersonal.NombreCompleto.Trim + ' ' Dim Direccion As String = String.Format("{0} {1} {2}", objPersonal.Calle.Trim, objPersonal.NumExt.Trim, objPersonal.NumInt.Trim).Trim + ' ' Dim Ciudad As String = objPersonal.Ciudad.Trim + ' ' Dim Estado As String = objPersonal.Estado.Trim + ' ' Dim CP As String = objPersonal.CP.Trim + + + + ' ' 'Dim TipoContrato As String = GlobalDTTiposContrato.FiltraParametros("CveTipoContrato = " + objPersonal.CveTipoContrato.ToString)(0)("TipoContrato").ToString + ' ' 'Dim TipoPeriodo As String = GlobalDTTipoPeriodo.FiltraParametros("CveTipoPeriodo = " + objPersonal.CveTipoPeriodo.ToString)(0)("TipoPeriodo").ToString + ' ' Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero + ' ' Dim FormatoReciboCFDi As String = objPersonal.FormatoReciboCFDi + + ' ' Dim FechaInicio, FechaFin, FechaPago As Date + ' ' Dim DiasPagados As Integer = 0 + ' ' Dim Msg As String = String.Empty + ' ' Dim DiasIncapacitados As Integer = 0 + ' ' Dim DrPeriodo As DataRow = Nothing + + ' ' Dim ObjFolio As New ClsGralFolios + ' ' If ObjFolio.GetFolios("VIA", UsuarioActual.CveEmpresa) Then + ' ' If ObjFolio.DtResultados.Rows.Count > 0 Then + ' ' Folio = ObjFolio.DtResultados.Rows(0)("FActual").ToString + ' ' End If + ' ' End If + + + ' ' 'If objNomina.GetPeriodos(-1, -1, -1, -1, CvePeriodo) Then + ' ' ' If objNomina.DtResultados.Rows().Count > 0 Then + ' ' ' DrPeriodo = objNomina.DtResultados.Rows(0) + ' ' ' End If + ' ' 'End If + ' ' 'Dim DrPeriodo As DataRow = GlobalDTNominasPeriodos(-1, CvePeriodo, -1).FiltroPrimero("") + ' ' If DrPeriodo IsNot Nothing Then + ' ' FechaInicio = DrPeriodo("FechaInicio").ToString.ToDate + ' ' FechaFin = DrPeriodo("FechaFin").ToString.ToDate + ' ' FechaPago = DrPeriodo("FechaPago").ToString.ToDate + ' ' If objPersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then + + ' ' Dim Asistencias As Integer = objPersonal.DtResultados.SUM("AplicaAsistencia").ToEntero + ' ' Dim Vacaciones As Integer = objPersonal.DtResultados.SUM("AplicaVacacion").ToEntero + ' ' DiasIncapacitados = objPersonal.DtResultados.SUM("AplicaIncapacidad").ToEntero + ' ' DiasPagados = Asistencias - Vacaciones + ' ' If DiasPagados < 0 Then DiasPagados = 0 + + ' ' End If + + ' ' End If + + ' ' Dim DtPercepciones As Data.DataTable = Nothing + ' ' Dim DtDeducciones As Data.DataTable = Nothing + ' ' Dim DtOtrosPagos As Data.DataTable = Nothing + ' ' 'If objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then + ' ' ' If objNomina.DtResultados.Rows.Count > 0 Then + ' ' ' DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ") + ' ' ' DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") + ' ' ' TotalPercepciones = DtPercepciones.SUM("Importe") + ' ' ' TotalDeducciones = DtDeducciones.SUM("Importe") + ' ' ' Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal) + ' ' ' End If + ' ' 'End If + + ' ' 'Tipo Nomina O de Ordinaria o E de extraordinaria + ' ' 'Dim FechaPago As Date = Now + ' ' Dim TotalSueldos As Decimal = 0 + ' ' Dim TotalIndemnizacion As Decimal = 0 + ' ' Dim TotalJubilacion As Decimal = 0 + ' ' Msg = CFDi.ObjCompNomina12.Cargar("O", FechaPago, FechaInicio, FechaFin, DiasPagados, TotalPercepciones, TotalDeducciones, 0) + + + + ' ' If Msg = String.Empty Then + ' ' If DtPercepciones IsNot Nothing Then + ' ' If DtPercepciones.Rows.Count > 0 Then + ' ' TotalSueldos = DtPercepciones.SUM("Importe", "SATCveConcepto = '001'") + ' ' TotalIndemnizacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('022','023','025')") ' https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf + ' ' TotalJubilacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('039','044')") 'https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf + ' ' Msg = CFDi.ObjCompNomina12.CargarPercepciones(TotalSueldos, TotalIndemnizacion, TotalJubilacion, DtPercepciones.SUM("ImporteGravado").ToDecimal, DtPercepciones.SUM("ImporteExento").ToDecimal) + ' ' End If + ' ' For Each Row As DataRow In DtPercepciones.Rows + ' ' If Row("Importe").ToString.ToDecimal > 0 Then + ' ' If Row("CveSATConcepto").ToString = "" Then + ' ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) + ' ' Else + ' ' Msg = CFDi.ObjCompNomina12.AgregarPercepcion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, Row("ImporteGravado").ToString.ToDecimal, Row("ImporteExento").ToString.ToDecimal) + ' ' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal + ' ' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal + ' ' SubTotal = SubTotal + Row("Importe").ToString.ToDecimal + ' ' End If + + ' ' If Msg <> String.Empty Then + ' ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Percepcion", New Exception) + ' ' Exit For + ' ' End If + ' ' End If + ' ' 'RMF, falta poner el numero de horas pagadas + ' ' If Row("CveSATConcepto").ToString.ToEntero = 19 Then 'cuando son horas extras + + ' ' 'Obtengo el desglose de horas extras + + ' ' If objNomina.GetHorasExtras(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then + + ' ' Dim dr As DataRow = objNomina.DtResultados.FiltroPrimero("") + ' ' If dr IsNot Nothing Then + + ' ' If dr("HorasDobles").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasDobles").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Dobles, dr("HorasDobles").ToString.ToEntero, Row("Importe").ToString.ToDecimal) + ' ' If dr("HorasTriples").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasTriples").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Triples, dr("HorasTriples").ToString.ToEntero, Row("Importe").ToString.ToDecimal) + + + ' ' End If + + + ' ' End If + + ' ' End If + ' ' Next + ' ' If Msg = "" Then + ' ' CFDi.ObjCompNomina12.ObjPercepciones.TotalExento = TotalExcento + ' ' CFDi.ObjCompNomina12.ObjPercepciones.TotalGravado = TotalGravado + ' ' End If + + ' ' End If + + ' ' 'cargo las incapacidades + ' ' If DiasIncapacitados > 0 Then + + ' ' If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then + + ' ' CFDi.ObjCompNomina12.CargarIncapacidades() + ' ' For Each dr As DataRow In objNomina.DtResultados.Rows + ' ' CFDi.ObjCompNomina12.AgregarIncapacidad(dr("Dias").ToString.ToDecimal, dr("ClaveTipoIncapacidad").ToString.ToEntero, dr("Descuento").ToString.ToDecimal) + ' ' Next + + ' ' End If + + ' ' End If + + + + ' ' TotalExcento = 0 + ' ' TotalGravado = 0 + + ' ' If Msg = String.Empty Then + ' ' If DtDeducciones IsNot Nothing Then + ' ' If DtDeducciones.Rows.Count > 0 Then + ' ' Total = CType((Total - DtDeducciones.SUM("Importe")), Decimal) + ' ' CFDi.ObjCompNomina12.CargarDeducciones(CType(DtDeducciones.SUM("ImporteGravado"), Decimal), CType(DtDeducciones.SUM("ImporteExento"), Decimal)) + ' ' End If + ' ' For Each Row As DataRow In DtDeducciones.Rows + + ' ' If Row("Importe").ToString.ToDecimal > 0 Then + ' ' If Row("CveSATConcepto").ToString = "" Then + ' ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) + ' ' Else + + ' ' Msg = CFDi.ObjCompNomina12.AgregarDeduccion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) + ' ' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal + ' ' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal + + ' ' If Row("CveSATConcepto").ToString.ToEntero = 3 Then + ' ' RetISR = RetISR + Row("Importe").ToString.ToDecimal + ' ' Else + ' ' Descuentos = Descuentos + Row("Importe").ToString.ToDecimal + ' ' End If + ' ' End If + + ' ' If Msg <> String.Empty Then + ' ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Deduccion", New Exception) + ' ' Exit For + ' ' End If + ' ' End If + ' ' Next + ' ' If Msg = "" Then + ' ' If CFDi.ObjCompNomina12.ObjDeducciones IsNot Nothing Then + ' ' CFDi.ObjCompNomina12.ObjDeducciones.TotalOtrasDeducciones = Descuentos + ' ' CFDi.ObjCompNomina12.ObjDeducciones.TotalImpuestosRetenidos = RetISR + ' ' End If + + ' ' End If + ' ' End If + + ' ' If Msg = String.Empty Then + ' ' If DtOtrosPagos IsNot Nothing Then + ' ' If DtOtrosPagos.Rows.Count > 0 Then + ' ' Total = CType((Total - DtOtrosPagos.SUM("Importe")), Decimal) + ' ' CFDi.ObjCompNomina12.CargarOtrosPagos() + ' ' End If + + ' ' For Each Row As DataRow In DtOtrosPagos.Rows + ' ' If Row("Importe").ToString.ToDecimal > 0 Then + ' ' If Row("CveSATConcepto").ToString = "" Then + ' ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) + ' ' Else + ' ' Msg = CFDi.ObjCompNomina12.AgregarOtroPago(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) + ' ' 'Msg = CFDi.ObjCompNomina12.CargarSubsidioAlEmpleo(0) + ' ' 'Msg = CFDi.ObjCompNomina12.CargarCompensacionSaldosAFavor(0, 0, 0) + ' ' End If + + ' ' If Msg <> String.Empty Then + ' ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Otros Pagos", New Exception) + ' ' Exit For + ' ' End If + ' ' End If + ' ' Next + + ' ' End If + + ' ' If Msg = String.Empty Then + ' ' Dim x As Integer = 0 + + ' ' Dim Moneda As String = "MXN" + ' ' Dim LugarExp As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} ", SucCalle, SucNoExt, SucNoInt, SucColonia, SucLocalidad, SucMunicipio, SucEstado, SucPais, SucCP) + ' ' Dim FechaFactura As DateTime = Now + ' ' 'Nodo Comprobante + + ' ' Dim TipoComprobante As ClbNegBICFDv3_2.TipoDeComprobante = ClbNegBICFDv3_2.TipoDeComprobante.egreso + ' ' Msg = CFDi.comprobantecfd(0, 0, Serie, Folio, FechaFactura, "PAGO EN UNA SOLA EXHIBICION", "CONTADO", SubTotal, Descuentos, "Deducciones nómina", "1", Moneda, Total, objPersonal.MetodoPagoSAT, ClbNegBICFDv3_2.TipoDeComprobante.egreso, LugarExp, "", "", "", New Date(1900, 1, 1), 0) + + ' ' If Msg = String.Empty Then + ' ' 'Nodo emisor + ' ' Msg = CFDi.ObjCompNomina12.CargarEmisor("", objPersonal.DtResultados.Rows(0)("RegistroPatronal").ToString(), UsuarioActual.Empresa.RFC) + ' ' 'If Msg = String.Empty Then Msg = CFDi.EmisorRegimen(UsuarioActual.Empresa.CodigoRegimenFiscal) + ' ' If Msg = String.Empty Then + ' ' 'Nodo Entidad SNCF + ' ' If 1 = 2 Then 'cuando es gobierno + ' ' Msg = CFDi.ObjCompNomina12.CargarEntidadSNCF("", 0) + ' ' End If + + ' ' If Msg = String.Empty Then + ' ' 'Nodo Receptor + ' ' Msg = CFDi.ObjCompNomina12.CargarReceptor(objPersonal.CURP, objPersonal.NumeroSS, objPersonal.FechaInicioContrato, AntiguedadSemanas, objPersonal.TipoContrato, "", objPersonal.ClaveTipoJornada, objPersonal.CveRegimenContratacion, objPersonal.Codigo.ToString, + ' ' objPersonal.Departamento, objPersonal.Puesto, objPersonal.CveRiesgoPuesto, objPersonal.TipoPeriodo, objPersonal.ClaveBanco, objPersonal.BancoNumCuenta, Total, objPersonal.SDI.ToString.ToDecimal, objPersonal.ClaveEstado) + ' ' If Msg = String.Empty Then + ' ' 'Nodo SubContratacion + ' ' If 1 = 2 Then Msg = CFDi.ObjCompNomina12.AgregarSubContratacion("", 0) + ' ' If Msg = String.Empty Then + + ' ' CFDi.LstCompNomina12.Add(CFDi.ObjCompNomina12) + + ' ' Dim HasErrorConceptos As Boolean = False + ' ' 'Dim Importe As Decimal = 0 + + + ' ' Msg = CFDi.ConceptosCfd(1, "ACT", "", "Pago de nómina", SubTotal, SubTotal) + + ' ' 'Timbrado + + ' ' 'Web Services de producción: http://biinform.com.mx/srvCFDi/service1.asmx + ' ' 'Web Services de pruebasd: http://biinform.com.mx/srvCFDiPrueba/service1.asmx + + + ' ' Dim WS As String = String.Empty + ' ' If UsuarioActual.Empresa.FacturaProduccion Then + ' ' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx" + ' ' Else + ' ' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx" + ' ' End If + + ' ' If Not System.IO.Directory.Exists(Ruta & "XML\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\") + ' ' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\") + + ' ' 'Generar Timbre + ' ' 'If UsuarioActual.Empresa.FacturaProduccion Then + ' ' If 1 = 2 Then + ' ' CFDi.Generar(String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoPfx), + ' ' UsuarioActual.Empresa.ContraseñaKey, + ' ' String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoCer), + ' ' String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), + ' ' String.Format("{0}Certificados\", Ruta), + ' ' UsuarioActual.Empresa.BIUsuario, + ' ' UsuarioActual.Empresa.BIContraseña, + ' ' WS, + ' ' True) + ' ' Else + ' ' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\Demo\") + ' ' 'RutaPruebas & "XML\Demo\" & NominaFolio & ".xml", + ' ' CFDi.Generar(String.Format("{0}Certificados\aaa010101aaa__csd_01.pfx", RutaPruebas), + ' ' "12345678a", + ' ' String.Format("{0}Certificados\aaa010101aaa__csd_01.cer", RutaPruebas), + ' ' String.Format("{0}XML\Nomina\Demo\{1}.xml", Ruta, NominaFolio), + ' ' String.Format("{0}Certificados\", RutaPruebas), + ' ' "prueba", + ' ' "123", + ' ' WS, + ' ' True) + ' ' End If + + + ' ' If CFDi.MsgError <> String.Empty Then + + ' ' 'OnError("Ocurrió un error al generar el timbre: " & CFDi.MsgError, New Exception) + + ' ' Dim params As New ActualizaTimbre + ' ' params.Estatus = False + ' ' params.CveNomina = CveNomina + ' ' params.CvePAC = 1 + + ' ' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado) + ' ' 'Hilo.Start(params) + ' ' BtnAutorizar.Enabled = False + ' ' MsgError = "Nombre: " & Nombre & ". Error: " & CFDi.MsgError + ' ' Else + ' ' 'Actualiza Estatus Timbrado + ' ' Dim params As New ActualizaTimbre + ' ' params.Estatus = True + ' ' params.CveNomina = CveNomina + ' ' params.CvePAC = 1 + + ' ' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado) + ' ' 'Hilo.Start(params) + + ' ' Dim CBB As New ClbNegBICFDv3_2.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 + ' ' ViewState("FolioFiscal") = FolioFiscal + + ' ' 'Actualiza Estatus Factura + ' ' CveNominaT = CveNomina + + ' ' Dim Rastro As String = String.Format("Nomina: CvePeriodo:{0}, CvePersonal:{1}, UUID: {2}, RFC:{3}", CvePeriodo, CvePersonal, FolioFiscal, objPersonal.RFC) + ' ' Rastro.GuardaLog() + + ' ' If FolioFiscal <> "" Then + + ' ' 'If UsuarioActual.Empresa.FacturaProduccion Then + ' ' ' Dim ObjNomina2 As New ClsNominas() + ' ' ' ObjNomina2.UpdateEstatusNomNominas(3, UsuarioActual.Empresa.CvePAC, FolioFiscal, "", ("01/01/2000").ToDate, CveNomina, SubTotal, Descuentos, RetISR, Total, DiasPagados) + ' ' ' ObjNomina2.Dispose() + ' ' 'End If + ' ' Rastro = "--Estatus" & Rastro + ' ' Rastro.GuardaLog() + ' ' 'Dim Hilo1 As New System.Threading.Thread(AddressOf ActualizaEstatus) + ' ' 'Hilo1.Start(3) + ' ' End If + + + ' ' Dim RutaCBB As String = String.Empty + ' ' If Not System.IO.Directory.Exists(Ruta & "CBB\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\") + ' ' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\") + + ' ' If UsuarioActual.Empresa.FacturaProduccion Then + ' ' RutaCBB = Ruta & "CBB\Nomina\" & NominaFolio & ".jpg" + ' ' Else + ' ' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\Demo\") + ' ' RutaCBB = Ruta & "CBB\Nomina\Demo\" & NominaFolio & ".jpg" + ' ' End If + ' ' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFC, Total, FolioFiscal, RutaCBB) + + + ' ' 'GeneraPDF(FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, TmpDT, SelloCFDi, SelloSAT, RutaCBB, VentaFolio, Ruta & "XML\" & VentaFolio & ".xml", False, CFDi.CadenaOriginal) + ' ' 'GeneraPDF(CveNomina, CvePersonal, CvePeriodo, FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT, RutaCBB, Ruta & "Nomina\XML\" & NominaFolio & ".xml", False, CFDi.Timbrado.CadenaOriginal, FormatoReciboCFDi) + ' ' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' ' End If + ' ' Else + ' ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) + ' ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) + ' ' End If + ' ' objPersonal.Dispose() + ' ' objNomina.Dispose() + + ' ' Return MsgError + ' 'End Function + + + '#End Region #Region " GUARDAR - ACTUALIZAR " Private Function ValidaGuardar() As Boolean @@ -3770,16 +3771,16 @@ Partial Class Bancos_IE MsgError = GuardaSolicitudAnticipoOC(ObjOC) End If - If MsgError = "" Then - 'VIATICOS - If ChkAplicaViatico.Checked Then - Dim Retorno As String = TimbrarNomina12(CvePersonal) - If Retorno <> "" Then MsgError = $"{MsgError} {Retorno}" : Msg.Clear() : CveIE = -1 - If Retorno <> "" Then - Alert(Retorno, TipoMensaje.MsgError) - End If - End If - End If + 'If MsgError = "" Then + ' 'VIATICOS + ' If ChkAplicaViatico.Checked Then + ' Dim Retorno As String = TimbrarNomina12(CvePersonal) + ' If Retorno <> "" Then MsgError = $"{MsgError} {Retorno}" : Msg.Clear() : CveIE = -1 + ' If Retorno <> "" Then + ' Alert(Retorno, TipoMensaje.MsgError) + ' End If + ' End If + 'End If If MsgError = "" Then If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then