This commit is contained in:
@@ -234,297 +234,6 @@ Partial Class PopUpVerFactura
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Public Function GeneraPDFNomina(CvePersonal As Integer, CvePeriodo As Integer, CveEmpresa As Integer, RutaEmpresa As String, Optional indemnizacion As Boolean = False) As Byte()
|
|
||||||
|
|
||||||
|
|
||||||
Dim ObjNomina As New ClsNominas
|
|
||||||
Dim ObjPersonal As New ClsRH
|
|
||||||
Dim TieneError = False
|
|
||||||
Dim Retorno As Byte() = Nothing
|
|
||||||
|
|
||||||
If Not ObjNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodo, -1, CveEmpresa) Then
|
|
||||||
Alert("Ocurrio un erro al obtener datos de la nomina", TipoMensaje.MsgError)
|
|
||||||
ObjPersonal.Dispose()
|
|
||||||
ObjNomina.Dispose()
|
|
||||||
Return Nothing
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim CveNomina = ObjNomina.CveNomina
|
|
||||||
Dim DTPercepciones As Data.DataTable
|
|
||||||
Dim DTDeducciones As Data.DataTable
|
|
||||||
Dim DTDeducciones2 As New Data.DataTable
|
|
||||||
|
|
||||||
Dim Ruta As String = UsuarioActual.Empresa.Ruta
|
|
||||||
Dim PathXML As String = $"{Ruta}XML\Nomina\{ObjNomina.Serie }{If(indemnizacion, "F", "")}-{ObjNomina.Folio}.xml"
|
|
||||||
Dim FechaEmision, FechaCertificacion As DateTime
|
|
||||||
Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String
|
|
||||||
FolioFiscal = ""
|
|
||||||
NoSerieCertificado = ""
|
|
||||||
SelloCFDi = ""
|
|
||||||
SelloSAT = ""
|
|
||||||
NoSerieCertificadoContribuyente = ""
|
|
||||||
|
|
||||||
Dim RutaCBB As String = String.Format("{0}CBB\Nomina\{1}.jpg", RutaEmpresa, ObjNomina.SerieFolio)
|
|
||||||
Dim ImagenCBB As New System.IO.FileInfo(RutaCBB)
|
|
||||||
Dim ImgCBB As String
|
|
||||||
|
|
||||||
Dim RutaFormato As String = String.Format("{0}Formatos\Nomina.rdlc", RutaEmpresa)
|
|
||||||
Dim RutaFormatoDefault As String = String.Format("Empresas\Grales\Formatos\Nomina.rdlc")
|
|
||||||
|
|
||||||
'SI ESTA TIMBRADA - CON XML
|
|
||||||
|
|
||||||
If System.IO.File.Exists(PathXML) Then
|
|
||||||
|
|
||||||
Dim XmlDoc As New System.Xml.XmlDocument
|
|
||||||
'XmlDoc.Load(Ruta & "XML\\Nomina\NOM A-3845.xml")
|
|
||||||
XmlDoc.Load(PathXML)
|
|
||||||
|
|
||||||
If ValorNodoXML(XmlDoc.DocumentElement, "version").Contiene("3.3", "4.0") Then
|
|
||||||
FechaEmision = XmlDoc.DocumentElement.Attributes("Fecha").InnerText.ToDate
|
|
||||||
NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("NoCertificado").InnerText
|
|
||||||
|
|
||||||
For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1
|
|
||||||
If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then
|
|
||||||
FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText
|
|
||||||
NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText
|
|
||||||
FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate
|
|
||||||
SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText
|
|
||||||
SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
Else
|
|
||||||
FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate
|
|
||||||
NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText
|
|
||||||
|
|
||||||
For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1
|
|
||||||
If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:timbreFiscalDigital" Then
|
|
||||||
FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText
|
|
||||||
NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText
|
|
||||||
FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("fechaTimbrado").InnerText.ToDate
|
|
||||||
SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText
|
|
||||||
SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
'SIN TIMBRAR - SIN XML
|
|
||||||
Else
|
|
||||||
FolioFiscal = "Sin Timbrar"
|
|
||||||
NoSerieCertificado = "Sin Timbrar"
|
|
||||||
SelloCFDi = "Sin Timbrar"
|
|
||||||
SelloSAT = "Sin Timbrar"
|
|
||||||
End If
|
|
||||||
|
|
||||||
'Si no tiene CBB, SE GENERA
|
|
||||||
If Not ImagenCBB.Exists Then
|
|
||||||
Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar()
|
|
||||||
If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then
|
|
||||||
CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString.ToDecimal, FolioFiscal, RutaCBB)
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/Nomina/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, ObjNomina.SerieFolio)
|
|
||||||
|
|
||||||
Dim cQr As Byte() = Nothing
|
|
||||||
Try
|
|
||||||
Dim CadenaOriginalCFD As String = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||"
|
|
||||||
|
|
||||||
Dim RptParametro As New List(Of ReportParameter)
|
|
||||||
|
|
||||||
|
|
||||||
'Datos Empresa
|
|
||||||
RptParametro.Add(New ReportParameter("RegistroPatronal", ObjNomina.RegistroPatronal))
|
|
||||||
Dim ajusteindemnizacion As Double = 0
|
|
||||||
'PERCECIONES - DEDUCCIONES
|
|
||||||
If ObjNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then
|
|
||||||
Dim filtrop As String = " AND CveSistema NOT IN(10,11,32)"
|
|
||||||
Dim friltrod As String = " AND CveSistema <>47"
|
|
||||||
If indemnizacion Then
|
|
||||||
filtrop = "AND CveSistema IN(10,11,32)"
|
|
||||||
friltrod = " AND CveSistema =47"
|
|
||||||
End If
|
|
||||||
DTPercepciones = ObjNomina.DtResultados.FiltraParametros($"((Tipo = 'P' OR (Tipo = 'D' AND Importe <0)) AND Importe <>0 AND EsPadre = 1 AND SoloVisible =0) {filtrop}")
|
|
||||||
DTDeducciones = ObjNomina.DtResultados.FiltraParametros($"(Tipo = 'D' AND Importe >0 AND EsPadre = 1 AND SoloVisible =0) {friltrod}")
|
|
||||||
DTDeducciones2 = ObjNomina.DtResultados.FiltraParametros($"((Tipo = 'D' AND Importe >0 AND EsPadre = 1 AND SoloVisible =0) OR CveSistema IN (20,21) OR CveConcepto =4714){friltrod}")
|
|
||||||
|
|
||||||
ajusteindemnizacion = ObjNomina.DtResultados.FiltraParametros($"((Tipo = 'P' OR (Tipo = 'D' AND Importe <0)) AND Importe <>0 AND EsPadre = 1 AND SoloVisible =0) AND CveSistema IN(10,11,32)").SUM("Importe") -
|
|
||||||
ObjNomina.DtResultados.FiltraParametros($"(Tipo = 'D' AND Importe >0 AND EsPadre = 1 AND SoloVisible =0) AND CveSistema =47").SUM("Importe")
|
|
||||||
For Each row As DataRow In DTPercepciones.Rows
|
|
||||||
If row("Tipo").ToString() = "D" Then
|
|
||||||
row("Codigo") = row("Codigo").ToString().Replace("D", "OP")
|
|
||||||
row("Importe") = row("Importe").ToString().ToDecimal() * -1
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
Else
|
|
||||||
DTPercepciones = Nothing
|
|
||||||
DTDeducciones = Nothing
|
|
||||||
End If
|
|
||||||
'DATOS DEL EMPLEADO
|
|
||||||
If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("NoEmpleado", ObjPersonal.Codigo))
|
|
||||||
RptParametro.Add(New ReportParameter("RFC", ObjPersonal.RFC))
|
|
||||||
RptParametro.Add(New ReportParameter("CURP", ObjPersonal.CURP))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("NombreCompleto", String.Format("{0} {1} {2}", ObjPersonal.Nombres, ObjPersonal.APaterno, ObjPersonal.AMaterno).Trim()))
|
|
||||||
RptParametro.Add(New ReportParameter("Regimen", ObjPersonal.RegimenContratacion))
|
|
||||||
RptParametro.Add(New ReportParameter("RiesgoPuesto", ObjPersonal.RiesgoPuesto))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("NSS", ObjPersonal.NumeroSS))
|
|
||||||
RptParametro.Add(New ReportParameter("Departamento", ObjPersonal.Departamento))
|
|
||||||
RptParametro.Add(New ReportParameter("Puesto", ObjPersonal.Puesto.ToString()))
|
|
||||||
RptParametro.Add(New ReportParameter("FechaIngreso", ObjPersonal.FechaIngreso.ToString("dd/MM/yyyy")))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("Contrato", ObjPersonal.TipoContrato.ToString))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("Jornada", ObjPersonal.Jornada))
|
|
||||||
RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo))
|
|
||||||
RptParametro.Add(New ReportParameter("SalarioBase", ObjPersonal.SalarioDiario.ToString))
|
|
||||||
RptParametro.Add(New ReportParameter("SalarioDiarioInt", ObjPersonal.SDI.ToString))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("Banco", ObjPersonal.Banco))
|
|
||||||
RptParametro.Add(New ReportParameter("CLABE", ObjPersonal.CLABE))
|
|
||||||
|
|
||||||
|
|
||||||
'DATOS NOMINA
|
|
||||||
If ObjNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, 1, CveEmpresa) Then
|
|
||||||
RptParametro.Add(New ReportParameter("ReciboNomina", ObjNomina.Folio.ToString))
|
|
||||||
RptParametro.Add(New ReportParameter("Serie", ObjNomina.Serie))
|
|
||||||
RptParametro.Add(New ReportParameter("Fecha", ObjNomina.Fecha.ToString))
|
|
||||||
RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("DiasPagados", ObjNomina.DiasPagados.ToString))
|
|
||||||
RptParametro.Add(New ReportParameter("MetodoPago", ObjNomina.MetodoPago)) '"""PUE"" (Pago en una sola exhibición)"
|
|
||||||
RptParametro.Add(New ReportParameter("FormaPago", """99"" (Por definir)"))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("Cantidad", "1"))
|
|
||||||
RptParametro.Add(New ReportParameter("Unidad", "ACT"))
|
|
||||||
RptParametro.Add(New ReportParameter("Descripcion", "PAGO DE NÓMINA"))
|
|
||||||
RptParametro.Add(New ReportParameter("Total", If(indemnizacion, ajusteindemnizacion, ObjNomina.Total - ajusteindemnizacion).ToString()))
|
|
||||||
|
|
||||||
Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar()
|
|
||||||
cQr = CBB.GenerarCBBBytes(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString().ToDecimal(), FolioFiscal)
|
|
||||||
RptParametro.Add(New ReportParameter("ImporteLetra", ObjNomina.Total.ToString.ToDouble.Texto2Letras))
|
|
||||||
RptParametro.Add(New ReportParameter("Clave", "84111505"))
|
|
||||||
Else
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not TieneError Then
|
|
||||||
If ObjNomina.GetPeriodos(-1, CveEmpresa, -1, -1, CvePeriodo) Then
|
|
||||||
RptParametro.Add(New ReportParameter("FechaInicio", ObjNomina.FechaInicio.ToString("dd/MM/yyyy")))
|
|
||||||
RptParametro.Add(New ReportParameter("FechaFin", ObjNomina.FechaFin.ToString("dd/MM/yyyy")))
|
|
||||||
Else
|
|
||||||
TieneError = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("PU", DTPercepciones.SUM("Importe").ToString()))
|
|
||||||
RptParametro.Add(New ReportParameter("Importe", DTPercepciones.SUM("Importe").ToString()))
|
|
||||||
RptParametro.Add(New ReportParameter("ImporteDeducciones", DTDeducciones.SUM("Importe").ToString()))
|
|
||||||
|
|
||||||
RptParametro.Add(New ReportParameter("SubTotal", DTPercepciones.SUM("Importe").ToString()))
|
|
||||||
RptParametro.Add(New ReportParameter("Descuentos", DTDeducciones.SUM("Importe", "SATCveConcepto <> '002'").ToString()))
|
|
||||||
RptParametro.Add(New ReportParameter("ISR", DTDeducciones.SUM("Importe", "SATCveConcepto = '002'").ToString()))
|
|
||||||
'Timbrado
|
|
||||||
RptParametro.Add(New ReportParameter("FolioFiscal", FolioFiscal))
|
|
||||||
RptParametro.Add(New ReportParameter("CertificadoSAT", NoSerieCertificado))
|
|
||||||
RptParametro.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString))
|
|
||||||
RptParametro.Add(New ReportParameter("SelloDigitalEmisor", SelloCFDi))
|
|
||||||
RptParametro.Add(New ReportParameter("SelloDigitalSAT", SelloSAT))
|
|
||||||
RptParametro.Add(New ReportParameter("CadenaOriginal", CadenaOriginalCFD))
|
|
||||||
RptParametro.Add(New ReportParameter("QR", ImgCBB.ToString))
|
|
||||||
|
|
||||||
|
|
||||||
Dim LSRds As New List(Of ReportDataSource)
|
|
||||||
|
|
||||||
|
|
||||||
Dim rds2 = New ReportDataSource()
|
|
||||||
|
|
||||||
Dim dtqr As New DataTable
|
|
||||||
|
|
||||||
Dim column As DataColumn = New DataColumn("ImagenByte")
|
|
||||||
column.DataType = System.Type.[GetType]("System.Byte[]")
|
|
||||||
column.AllowDBNull = True
|
|
||||||
column.Caption = "ImagenByte"
|
|
||||||
dtqr.Columns.Add(column)
|
|
||||||
Dim rowqr As DataRow = dtqr.NewRow()
|
|
||||||
rowqr("ImagenByte") = cQr
|
|
||||||
|
|
||||||
dtqr.Rows.Add(rowqr)
|
|
||||||
rds2.Name = "dsImagenes"
|
|
||||||
rds2.Value = dtqr
|
|
||||||
LSRds.Add(rds2)
|
|
||||||
Dim numnewfiles As Integer = 0
|
|
||||||
If DTPercepciones.Rows.Count > DTDeducciones2.Rows.Count Then
|
|
||||||
|
|
||||||
numnewfiles = DTPercepciones.Rows.Count - DTDeducciones2.Rows.Count
|
|
||||||
For index = 1 To numnewfiles
|
|
||||||
|
|
||||||
DTDeducciones2.Rows.Add(DTDeducciones2.NewRow)
|
|
||||||
Next
|
|
||||||
Else
|
|
||||||
|
|
||||||
If DTDeducciones2.Rows.Count > DTPercepciones.Rows.Count Then
|
|
||||||
numnewfiles = DTDeducciones2.Rows.Count - DTPercepciones.Rows.Count
|
|
||||||
For index = 1 To numnewfiles
|
|
||||||
|
|
||||||
DTPercepciones.Rows.Add(DTPercepciones.NewRow)
|
|
||||||
Next
|
|
||||||
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim RptDS As New ReportDataSource
|
|
||||||
RptDS.Name = "DsOC"
|
|
||||||
RptDS.Value = DTPercepciones
|
|
||||||
LSRds.Add(RptDS)
|
|
||||||
|
|
||||||
Dim RDS As New ReportDataSource
|
|
||||||
RDS.Name = "DataSet1"
|
|
||||||
RDS.Value = DTDeducciones2
|
|
||||||
LSRds.Add(RDS)
|
|
||||||
Dim Archivo As New System.IO.FileInfo(RutaFormato)
|
|
||||||
|
|
||||||
If Not TieneError Then
|
|
||||||
If Archivo.Exists Then
|
|
||||||
Retorno = StreamPDF(RutaFormato, LSRds, RptParametro, ObjNomina.SerieFolio, "PDF", MR:=Nothing)
|
|
||||||
Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\\{1}.pdf", RutaEmpresa, ObjNomina.SerieFolio))
|
|
||||||
If Not ArchivoPDF.Exists Then
|
|
||||||
Try
|
|
||||||
DirectoryExistsCreate(String.Format("{0}PDF", RutaEmpresa))
|
|
||||||
DirectoryExistsCreate(String.Format("{0}PDF\{1}", RutaEmpresa, "Nomina"))
|
|
||||||
File.WriteAllBytes(String.Format("{0}PDF\Nomina\{1}.pdf", RutaEmpresa, ObjNomina.SerieFolio), Retorno)
|
|
||||||
Catch ex As Exception
|
|
||||||
Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia)
|
|
||||||
GuardaLog(String.Format("Ocurrió un error al generar el PDF {0}", ex))
|
|
||||||
End Try
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
'ImprimirPDF(String.Format("{0}\Formatos\Nomina.rdlc", RutaEmpresa), LSRds, RptParametro, ObjNomina.SerieFolio)
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
Alert("Ocurrio un error al obtener los datos de la Nomina")
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
|
|
||||||
GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex))
|
|
||||||
End Try
|
|
||||||
|
|
||||||
|
|
||||||
ObjNomina.Dispose()
|
|
||||||
ObjPersonal.Dispose()
|
|
||||||
|
|
||||||
Return Retorno
|
|
||||||
End Function
|
|
||||||
|
|
||||||
|
|
||||||
Private Sub DescargaArchivoDirecto(RutaArchivo As String)
|
Private Sub DescargaArchivoDirecto(RutaArchivo As String)
|
||||||
If RutaArchivo <> "" Then
|
If RutaArchivo <> "" Then
|
||||||
|
|
||||||
|
|||||||
@@ -1136,7 +1136,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
|
|||||||
protected void LnkReenviarcorreo_Click(object sender, EventArgs e)
|
protected void LnkReenviarcorreo_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
string msggral = "";
|
//string msggral = "";
|
||||||
int CvePeriodo = 0;
|
int CvePeriodo = 0;
|
||||||
ClsSisMail Mail = new ClsSisMail();
|
ClsSisMail Mail = new ClsSisMail();
|
||||||
DataTable dtpersonal = new DataTable();
|
DataTable dtpersonal = new DataTable();
|
||||||
|
|||||||
@@ -560,6 +560,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user