This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2021-12-22 17:09:23 -07:00
parent 7e819271cc
commit 443360a9f3
15 changed files with 9040 additions and 214 deletions

View File

@@ -4,12 +4,16 @@ using System.Data;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Linq;
using Extensiones;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
public partial class Documentacion_TableroMaterialidad : ClsPaginas
{
@@ -25,6 +29,27 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
get { return ViewState["mes"] != null ? ViewState["mes"].ToString().ToEntero() : 0; }
set { ViewState["mes"] = value; }
}
public string directorio
{
get { return ViewState["directorio"] != null ? ViewState["directorio"].ToString() : string.Empty; }
set
{
if (ViewState["directorio"] != null && !string.IsNullOrEmpty(ViewState["directorio"].ToString()))
{
System.IO.Directory.Delete(ViewState["directorio"].ToString(), true);
}
ViewState["directorio"] = value;
}
}
public string xmlobject
{
get { return ViewState["xmlobject"] != null ? ViewState["xmlobject"].ToString() : string.Empty; }
set
{
ViewState["xmlobject"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
@@ -51,6 +76,7 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
}
}
upPaneldata.Update();
}
protected void RptDatos_ItemDataBound(object sender, RepeaterItemEventArgs e)
@@ -65,6 +91,35 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
protected void BtnAddClienteDocumento_Click(object sender, EventArgs e)
{
List<Archivo> litsarchivoxml = Anexo.getfiles().Archivos;
int CveDocumentacion = DdlDocumentacion.SelectedValue.ToEntero();
int CveDocumentacionElectronica = 0;
string obs = TxtObservaciones.Text;
string rutaempresa = string.Format("{0}\\materialidad\\", UsuarioActual.Empresa.Ruta);
if (!System.IO.Directory.Exists(rutaempresa))
{
System.IO.Directory.CreateDirectory(rutaempresa);
}
foreach (Archivo arch in litsarchivoxml)
{
DateTime fecha = string.Format("{0}-{1}-01", anio, mes).ToDateTime();
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
{
CveDocumentacionElectronica = edoc.DocumentacionElectronicaAdd(CveDocumentacion, -1, -1, -1, 1, obs, "", UsuarioActual.CveUsuario, fecha, fecha, Periodo: string.Format("{0}{1}", anio, mes).ToEntero());
if (CveDocumentacionElectronica > 0)
{
edoc.DocumentacionElectronicaUpdate(CveDocumentacionElectronica, CveDocumentacion, -1, -1, -1, 2, obs, string.Format("{0}.{1}", CveDocumentacionElectronica, arch.Extension.ToLower()), UsuarioActual.CveUsuario, fecha, fecha, arch.filenameO);
System.IO.File.Move(arch.FileUrl, string.Format("{2}{0}.{1}", CveDocumentacionElectronica, arch.Extension.ToLower(), rutaempresa));
Alert("los registros se guardaron correctamente");
cargadatos();
RegistraScript("$('#ModalDoctos').modal('hide');");
Anexo.Text = "[]";
}
}
}
}
@@ -78,10 +133,6 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
cargadatos();
}
protected void BtnAddClienteDocumentoxmlpd_Click(object sender, EventArgs e)
{
}
protected void LckOpModalDoctos_Click(object sender, EventArgs e)
{
@@ -95,21 +146,32 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
{
DateTime fecha = string.Format("{0}-{1}-01", anio, mes).ToDateTime();
LtlPeriodoXMLPDF.Text = fecha.ToString("MMMM yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX"));
RegistraScript("$('#ModalDoctosxmlpdf').modal();");
RegistraScript("$('#ModalDoctosxmlpdf').modal();showhideprocesarguardar =0; openguardar();");
Upxmlpdf.Update();
}
protected void LnkCargarZip_Click(object sender, EventArgs e)
{
string xmlobject = null;
List<Archivo> litsarchivoxml = Anexoxmlpdf.getfiles().Archivos;
if (litsarchivoxml.Count > 0)
{
Archivo archivoxml = litsarchivoxml[0];
if (archivoxml.Extension.ToLower() == "zip")
{
xmlobject = null;
string text;
string[] lines;
string[] splitword;
List<string> fechas = new List<string>();
string foliofiscal = string.Empty;
string CURP = string.Empty;
directorio = string.Empty;
char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
Regex rgxfecha = new Regex(@"^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$");
Regex rgxcurp = new Regex("^(([A-ZÑ&]{4})([0-9]{2})([0][13578]|[1][02])(([0][1-9]|[12][\\d])|[3][01])([A-Z0-9]{3}))|(([A-ZÑ&]{4})([0-9]{2})([0][13456789]|[1][012])(([0][1-9]|[12][\\d])|[3][0])([A-Z0-9]{3}))|(([A-ZÑ&]{4})([02468][048]|[13579][26])[0][2]([0][1-9]|[12][\\d])([A-Z0-9]{3}))|(([A-ZÑ&]{4})([0-9]{2})[0][2]([0][1-9]|[1][0-9]|[2][0-8])([A-Z0-9]{3}))$");
string directorio = archivoxml.FileUrl.Substring(0, archivoxml.FileUrl.Length - 4);
directorio = archivoxml.FileUrl.Substring(0, archivoxml.FileUrl.Length - 4);
System.IO.Directory.CreateDirectory(directorio);
ZipFile.ExtractToDirectory(archivoxml.FileUrl, directorio);
@@ -117,13 +179,14 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
XElement xfolder = new XElement("folder");
foreach (var urfile in System.IO.Directory.GetFiles(directorio, "*", SearchOption.AllDirectories))
{
XElement xfile = new XElement("archivo", urfile);
XElement xfile = new XElement("archivo");
xfile.SetAttributeValue("URL", urfile);
xfile.SetAttributeValue("EXT", Path.GetExtension(urfile).ToLower());
if (Path.GetExtension(urfile).ToLower() == ".xml")
{
var xmlobj = ADSistemaLibrary3.SatXml.XmlSatCFDI.readXML(urfile);
xfile.SetAttributeValue("UUID", xmlobj.complemento.UUID);
xfile.SetAttributeValue("Receptor", xmlobj.receptor.Nombre);
xfile.SetAttributeValue("RfcReceptor", xmlobj.receptor.Rfc);
xfile.SetAttributeValue("RfcEmisor", xmlobj.emisor.Rfc);
@@ -131,6 +194,9 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
xfile.SetAttributeValue("SubTotal", xmlobj.comprobante.SubTotal);
xfile.SetAttributeValue("Descuento", xmlobj.comprobante.Descuento);
xfile.SetAttributeValue("Total", xmlobj.comprobante.Total);
xfile.SetAttributeValue("Serie", xmlobj.comprobante.Serie);
xfile.SetAttributeValue("Folio", xmlobj.comprobante.Folio);
xfile.SetAttributeValue("Fecha", xmlobj.comprobante.Fecha);
xfile.SetAttributeValue("FechaPago", xmlobj.complemento.nomina12.FechaPago);
@@ -140,9 +206,113 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
xfile.SetAttributeValue("TotalPercepciones", xmlobj.complemento.nomina12.TotalPercepciones);
xfile.SetAttributeValue("TotalDeducciones", xmlobj.complemento.nomina12.TotalDeducciones);
xfile.SetAttributeValue("CURP", xmlobj.complemento.nomina12.Receptor.CURP);
xfile.SetAttributeValue("NSS", xmlobj.complemento.nomina12.Receptor.NSS);
xfile.SetAttributeValue("TN", xmlobj.complemento.nomina12.TipoNomina);
xfile.SetAttributeValue("NDP", xmlobj.complemento.nomina12.NumDiasPagados);
xfile.SetAttributeValue("TP", xmlobj.complemento.nomina12.Receptor.TipoPeriodo);
foreach (var con in xmlobj.complemento.nomina12.Percepciones)
{
XElement concepto = new XElement("con");
concepto.SetAttributeValue("TCon", "P");
concepto.SetAttributeValue("SV", "0");
concepto.SetAttributeValue("Tipo", con.TipoPercepcion);
concepto.SetAttributeValue("Clave", con.Clave);
concepto.SetAttributeValue("Concepto", con.Concepto);
concepto.SetAttributeValue("Importe", con.ImporteGravado + con.ImporteExento);
concepto.SetAttributeValue("ImporteG", con.ImporteGravado);
concepto.SetAttributeValue("ImporteE", con.ImporteExento);
xfile.Add(concepto);
}
foreach (var con in xmlobj.complemento.nomina12.OtrosPagos)
{
XElement concepto = new XElement("con");
concepto.SetAttributeValue("TCon", "D");
concepto.SetAttributeValue("SV", "0");
concepto.SetAttributeValue("Tipo", con.TipoOtroPago);
concepto.SetAttributeValue("Clave", con.Clave);
concepto.SetAttributeValue("Concepto", con.Concepto);
concepto.SetAttributeValue("Importe", -con.Importe);
concepto.SetAttributeValue("ImporteG", -con.Importe);
concepto.SetAttributeValue("ImporteE", 0);
xfile.Add(concepto);
}
foreach (var con in xmlobj.complemento.nomina12.Deducciones)
{
if (con.TipoDeduccion == "-001-") { }
else
{
XElement concepto = new XElement("con");
concepto.SetAttributeValue("TCon", "D");
if (con.TipoDeduccion == "-000-")
{
concepto.SetAttributeValue("SV", "1");
concepto.SetAttributeValue("Tipo", "000");
}
else
{
concepto.SetAttributeValue("SV", "0");
concepto.SetAttributeValue("Tipo", con.TipoDeduccion);
}
concepto.SetAttributeValue("Clave", con.Clave);
concepto.SetAttributeValue("Concepto", con.Concepto);
concepto.SetAttributeValue("Importe", con.Importe);
concepto.SetAttributeValue("ImporteG", con.Importe);
concepto.SetAttributeValue("ImporteE", 0);
xfile.Add(concepto);
}
}
}
else if (Path.GetExtension(urfile).ToLower() == ".pdf")
{
try
{
PdfReader reader = new PdfReader(urfile);
text = PdfTextExtractor.GetTextFromPage(reader, 1, new LocationTextExtractionStrategy());
foliofiscal = string.Empty;
CURP = string.Empty;
fechas.RemoveAll(z => true);
lines = text.Split('\n');
foreach (string linea in lines)
{
foreach (string word in Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(linea)).Split(delimiterChars))
{
if (word.Length == 36 && (splitword = word.Split('-')).Length == 5 &&
splitword[0].Length == 8 && splitword[1].Length == 4 && splitword[2].Length == 4 &&
splitword[3].Length == 4 && splitword[4].Length == 12)
{
foliofiscal = word;
}
if (rgxcurp.IsMatch(word))
{
CURP = word;
}
if (rgxfecha.IsMatch(word))
{
fechas.Add(word);
}
}
}
reader.Close();
}
catch (Exception) { }
if (fechas.Count > 2)
{
xfile.SetAttributeValue("FechaInicio", fechas[2].ToDateTime().ToString("yyyy-MM-dd"));
}
if (fechas.Count > 3)
{
xfile.SetAttributeValue("FechaFin", fechas[3].ToDateTime().ToString("yyyy-MM-dd"));
}
xfile.SetAttributeValue("CURP", CURP);
xfile.SetAttributeValue("UUID", foliofiscal);
}
@@ -150,24 +320,223 @@ public partial class Documentacion_TableroMaterialidad : ClsPaginas
}
xmlarchivos.Add(xfolder);
xmlobject = xmlarchivos.ToString();
//System.IO.StreamWriter archivoW = null;
//try { archivoW = new System.IO.StreamWriter(string.Format("{0}xml.txt", directorio), true, System.Text.Encoding.UTF8); } catch (Exception) { }
//if (archivoW != null)
//{
// try { archivoW.WriteLine(xmlobject); } catch (Exception) { }
// try
// {
// archivoW.Close();
// archivoW.Dispose();
// }
// catch (Exception) { }
//}
}
foreach (Archivo obj in litsarchivoxml)
{
System.IO.File.Delete(obj.FileUrl);
}
if (!string.IsNullOrEmpty(xmlobject))
{
procesararchivo(xmlobject, string.Format("{0}{1}", anio, mes).ToEntero());
}
Anexoxmlpdf.Text = "[]";
RegistraScript("showhideprocesarguardar =1; openguardar();");
Upxmlpdf.Update();
//RegistraScript("$('#ModalDoctosxmlpdf').modal();");
}
}
public void procesararchivo(string xmlobject,int periodo, bool guardarInformacion =false)
{
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
{
if (edoc.materialidadDoctos(xmlobject,UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, periodo, guardarInformacion))
{
if (edoc.DtResultados.Rows.Count > 0)
{
DataRow row = edoc.DtResultados.Rows[0];
LtlNoDoctos.Text = row["AllFiles"].ToString().ToEntero().ToString("N0");
LtlOtrosDoctos.Text = row["OTROSFiles"].ToString().ToEntero().ToString("N0");
LtlNoXml.Text = row["XMLFiles"].ToString().ToEntero().ToString("N0");
LtlNoPDF.Text = row["PDFFiles"].ToString().ToEntero().ToString("N0");
}
pnlinconsistencias.Visible = (edoc.DSResultados.Tables[2].FiltraParametros("CvePersonal IS NULL OR CvePeriodo IS NULL OR PeriodoOk =0").Rows.Count > 0);
if (edoc.DSResultados.Tables.Count > 2)
{
GVmaterialidadDoctos.DataSource = edoc.DSResultados.Tables[2];
GVmaterialidadDoctos.DataBind();
}
if (edoc.DSResultados.Tables.Count > 3)
{
GvPersonal.DataSource = edoc.DSResultados.Tables[3].FiltraParametros("CvePersonal IS NULL");
GvPersonal.DataBind();
}
if (edoc.DSResultados.Tables.Count > 4)
{
GvPeriodo.DataSource = edoc.DSResultados.Tables[4].FiltraParametros("CvePeriodo IS NULL");
GvPeriodo.DataBind();
}
}
}
}
protected void LnkProcesarDoctos_Click(object sender, EventArgs e)
{
}
protected void GVmaterialidadDoctos_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string toolTip = "";
int PeriodoOk = e.Row.DataKey("PeriodoOk").ToEntero();
int cvePersonal = e.Row.DataKey("CvePersonal").ToEntero();
int CvePeriodo = e.Row.DataKey("CvePeriodo").ToEntero();
int CveNomina = e.Row.DataKey("CveNomina").ToEntero();
if (CveNomina > 0)
{
e.Row.CssClass = "info";
toolTip = string.Format("{0}{1}Nomina registrada.", toolTip, (toolTip.Length > 0 ? " " : ""));
}
if (PeriodoOk <= 0)
{
e.Row.CssClass = "warning";
toolTip = string.Format("{0}{1}Esta nomina no pertenece a este periodo", toolTip, (toolTip.Length > 0 ? " " : ""));
}
if (cvePersonal <= 0)
{
e.Row.CssClass = "danger";
toolTip = string.Format("{0}{1}No se encontro el personal", toolTip, (toolTip.Length > 0 ? " " : ""));
}
if (CvePeriodo <= 0)
{
e.Row.CssClass = "danger";
toolTip = string.Format("{0}{1}No se encontro el periodo", toolTip, (toolTip.Length > 0 ? " " : ""));
}
e.Row.ToolTip = toolTip;
}
}
protected void btnshowdoc_Click(object sender, EventArgs e)
{
GVdocelect.DataSource = new DataTable();
GVMaterialidadEnvios.DataSource = new DataTable();
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
{
if (edoc.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, -1, -2, string.Format("{0}{1}", anio, mes).ToEntero()))
{
GVdocelect.DataSource = edoc.DtResultados.FiltraParametros(string.Format("CveDocumentacion ={0}", TxtcveDocumentacion.Text.ToEntero()));
}
if (edoc.Edoc_MaterialidadEnviosGet(-1, TxtcveCliente.Text.ToEntero(), -1, UsuarioActual.CveEmpresa))
{
GVMaterialidadEnvios.DataSource = edoc.DtResultados;
}
}
foreach (Archivo obj in litsarchivoxml)
{
System.IO.File.Delete(obj.FileUrl);
}
RegistraScript("$('#ModalDoctosxmlpdf').modal();");
GVMaterialidadEnvios.DataBind();
GVdocelect.DataBind();
RegistraScript("$('#ModalShowDoctos').modal()");
}
protected void LnkEliminardocto_Click(object sender, EventArgs e)
{
int CveDocumentacionElectronica = ((GridViewRow)((LinkButton)sender).NamingContainer).DataKey("CveDocumentacionElectronica").ToEntero();
string Adjunto = ((GridViewRow)((LinkButton)sender).NamingContainer).DataKey("Adjunto");
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
{
if (edoc.DocumentacionElectronicaRemove(CveDocumentacionElectronica, -1))
{
string ruta = string.Format("{0}\\materialidad\\{1}", UsuarioActual.Empresa.Ruta, Adjunto);
if (System.IO.File.Exists(ruta))
{
try
{
System.IO.File.Delete(ruta);
}
catch (Exception) { }
}
if (edoc.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, -1, -2, string.Format("{0}{1}", anio, mes).ToEntero()))
{
GVdocelect.DataSource = edoc.DtResultados.FiltraParametros(string.Format("CveDocumentacion ={0}", TxtcveDocumentacion.Text.ToEntero()));
GVdocelect.DataBind();
}
Alert("El documento se a eliminado");
}
}
}
protected void BtnDocumentacionElectronica_Click(object sender, EventArgs e)
{
String Adjunto = TxtCveDocumentacionElectronica.Text;
string ruta = string.Format("{0}\\materialidad\\{1}", UsuarioActual.Empresa.Ruta, Adjunto);
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
{
if (System.IO.File.Exists(ruta))
{
System.IO.FileInfo file = new System.IO.FileInfo(ruta);
string mimeType = "text/plain";
try
{
mimeType = MimeMapping.GetMimeMapping(ruta);
}
catch (Exception ex)
{
}
// Response.Write(path)
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(TxtDoctoName.Text)}");
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = mimeType;
Response.Flush();
Response.TransmitFile(file.FullName);
Response.End();
}
else
{
Alert("no se encontro el documento.");
}
}
}
protected void Btnenviardocto_Click(object sender, EventArgs e)
{
int periodo = string.Format("{0}{1}", anio, mes).ToEntero();
DataTable dtdoctos = null;
DataTable dtdocs = null;
string CorreoCumplimiento = string.Empty;
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
{
if (edoc.TableroMaterialidadGET(UsuarioActual.CveEmpresa, anio, mes) && edoc.DSResultados.Tables.Count > 1)
{
dtdoctos = edoc.DSResultados.Tables[0];
}
if (edoc.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, -1, -2, periodo))
{
dtdocs = edoc.DtResultados.FiltraParametros(string.Format("CveDocumentacionElectronica>0"));
}
DataRow row = null;
foreach (string item in TxtClientescorreo.Text.Split(','))
{
if (item.ToEntero() > 0 && dtdoctos != null && (row = dtdoctos.FiltroPrimero(string.Format("CveCliente ={0}", item))) != null && dtdocs != null && dtdocs.Rows.Count > 0 && !string.IsNullOrEmpty(CorreoCumplimiento = row["CorreoCumplimiento"].ToString()))
{
edoc.Edoc_MaterialidadEnviosAdd(item.ToEntero(), periodo, dtdocs.Rows.Count, "Envio", CorreoCumplimiento, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
}
}
}
Alert("El correo se ha enviado.");
}
}
public class archivoxmlpdf
{
@@ -196,8 +565,6 @@ public class archivoxmlpdf
}
namespace ADSistemaLibrary3.SatXml
{
public class XmlSatCFDI
@@ -515,17 +882,18 @@ namespace ADSistemaLibrary3.SatXml
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyComplemento)
{
int cDepth = xtr.Depth;
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
{
}
while (canread && xtr.Depth > cDepth)
bool enterdept = true;
bool noavance = true;
xmlCFDI.complemento.nomina12 = new CFDINomina();
while (canread && (xtr.Depth > cDepth || enterdept))
{
enterdept = false;
if (noavance)
{
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
}
noavance = true;
if (xtr.NodeType == XmlNodeType.Element && xtr.LocalName == "TimbreFiscalDigital" && xmlCFDI.comprobante.Version != null)
{
xmlCFDI.complemento.xmlns_tfd = xtr.GetAttribute("xmlns:tfd");
@@ -539,13 +907,10 @@ namespace ADSistemaLibrary3.SatXml
xmlCFDI.complemento.SelloSAT = xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("SelloSAT") : xtr.GetAttribute("selloSAT");
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
else if (xtr.NodeType == XmlNodeType.Element && xtr.LocalName.ToUpper() == "NOMINA" && xmlCFDI.comprobante.Version != null)
if (xtr.NodeType == XmlNodeType.Element && xtr.LocalName.ToUpper() == "NOMINA" && xmlCFDI.comprobante.Version != null)
{
xmlCFDI.complemento.nomina12 = new CFDINomina();
//Version="1.2" TipoNomina="E" FechaPago="2021-12-08"
//="2021-12-08" ="2021-12-08"
//="1" ="5026.31" ="254.34"
cont = xtr.MoveToFirstAttribute();
while (cont)
{
@@ -556,14 +921,150 @@ namespace ADSistemaLibrary3.SatXml
case "FECHAFINALPAGO": xmlCFDI.complemento.nomina12.FechaFin = xtr.Value; break;
case "NUMDIASPAGADOS": xmlCFDI.complemento.nomina12.NumDiasPagados = xtr.Value.ToEntero(); break;
case "TIPONOMINA": xmlCFDI.complemento.nomina12.TipoNomina = xtr.Value; break;
case "Version": xmlCFDI.complemento.nomina12.Version = xtr.Value; break;
case "VERSION": xmlCFDI.complemento.nomina12.Version = xtr.Value; break;
}
cont = xtr.MoveToNextAttribute();
}
xtr.MoveToFirstAttribute();
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
else if (xtr.NodeType == XmlNodeType.Element && xtr.LocalName == "Pagos" && xmlCFDI.comprobante.Version != null)
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper() == "NOMINA12:RECEPTOR")
{
cont = xtr.MoveToFirstAttribute();
while (cont)
{
switch (xtr.Name.ToUpper())
{
case "CURP": xmlCFDI.complemento.nomina12.Receptor.CURP = xtr.Value; break;
case "NUMSEGURIDADSOCIAL": xmlCFDI.complemento.nomina12.Receptor.NSS = xtr.Value; break;
case "FECHAINICIORELLABORAL": xmlCFDI.complemento.nomina12.Receptor.FechaInicioContrato = xtr.Value; break;
case "ANTIGÜEDAD": xmlCFDI.complemento.nomina12.Receptor.Antiguedad = xtr.Value; break;
case "TIPOCONTRATO": xmlCFDI.complemento.nomina12.Receptor.TipoContrato = xtr.Value; break;
case "NUMEMPLEADO": xmlCFDI.complemento.nomina12.Receptor.CodigoEmpleado = xtr.Value; break;
case "DEPARTAMENTO": xmlCFDI.complemento.nomina12.Receptor.Departamento = xtr.Value; break;
case "TIPOREGIMEN": xmlCFDI.complemento.nomina12.Receptor.CodigoRegimenContratacion = xtr.Value; break;
case "SINDICALIZADO": xmlCFDI.complemento.nomina12.Receptor.Sindicalizado = xtr.Value; break;
case "TIPOJORNADA": xmlCFDI.complemento.nomina12.Receptor.CodigoTipoJornada = xtr.Value; break;
case "PUESTO": xmlCFDI.complemento.nomina12.Receptor.Puesto = xtr.Value; break;
case "RIESGOPUESTO": xmlCFDI.complemento.nomina12.Receptor.CodigoRiesgoPuesto = xtr.Value; break;
case "SALARIOBASECOTAPOR": xmlCFDI.complemento.nomina12.Receptor.SBC = xtr.Value.ToDouble(); break;
case "SALARIODIARIOINTEGRADO": xmlCFDI.complemento.nomina12.Receptor.SDI = xtr.Value.ToDouble(); break;
case "CLAVEENTFED": xmlCFDI.complemento.nomina12.Receptor.CodigoEntidadFederativa = xtr.Value; break;
case "PERIODICIDADPAGO": xmlCFDI.complemento.nomina12.Receptor.TipoPeriodo = xtr.Value; break;
case "CUENTABANCARIA": xmlCFDI.complemento.nomina12.Receptor.NumeroCuenta = xtr.Value; break;
case "BANCO": xmlCFDI.complemento.nomina12.Receptor.CodigoBanco = xtr.Value; break;
}
cont = xtr.MoveToNextAttribute();
}
xtr.MoveToFirstAttribute();
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper() == "NOMINA12:PERCEPCION")
{
if (xmlCFDI.complemento.nomina12.Percepciones == null)
{
xmlCFDI.complemento.nomina12.Percepciones = new List<CFDINominaPercepciones>();
}
CFDINominaPercepciones concepto = new CFDINominaPercepciones();
cont = xtr.MoveToFirstAttribute();
while (cont)
{
switch (xtr.Name.ToUpper())
{
case "CLAVE": concepto.Clave = xtr.Value; break;
case "TIPOPERCEPCION": concepto.TipoPercepcion = xtr.Value; break;
case "IMPORTEGRAVADO": concepto.ImporteGravado = xtr.Value.ToDecimal(); break;
case "IMPORTEEXENTO": concepto.ImporteExento = xtr.Value.ToDecimal(); break;
case "CONCEPTO": concepto.Concepto = xtr.Value; break;
}
cont = xtr.MoveToNextAttribute();
}
xmlCFDI.complemento.nomina12.Percepciones.Add(concepto);
xtr.MoveToFirstAttribute();
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper() == "NOMINA12:DEDUCCION")
{
if (xmlCFDI.complemento.nomina12.Deducciones == null)
{
xmlCFDI.complemento.nomina12.Deducciones = new List<CFDINominaDeducciones>();
}
CFDINominaDeducciones concepto = new CFDINominaDeducciones();
cont = xtr.MoveToFirstAttribute();
while (cont)
{
switch (xtr.Name.ToUpper())
{
case "CLAVE": concepto.Clave = xtr.Value; break;
case "TIPODEDUCCION": concepto.TipoDeduccion = xtr.Value; break;
case "IMPORTE": concepto.Importe = xtr.Value.ToDecimal(); break;
case "CONCEPTO": concepto.Concepto = xtr.Value; break;
}
cont = xtr.MoveToNextAttribute();
}
xmlCFDI.complemento.nomina12.Deducciones.Add(concepto);
xtr.MoveToFirstAttribute();
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper() == "NOMINA12:OTROPAGO")
{
if (xmlCFDI.complemento.nomina12.OtrosPagos == null)
{
xmlCFDI.complemento.nomina12.OtrosPagos = new List<CFDINominaOtrosPagos>();
}
CFDINominaOtrosPagos concepto = new CFDINominaOtrosPagos();
cont = xtr.MoveToFirstAttribute();
while (cont)
{
switch (xtr.Name.ToUpper())
{
case "CLAVE": concepto.Clave = xtr.Value; break;
case "TIPOOTROPAGO": concepto.TipoOtroPago = xtr.Value; break;
case "IMPORTE": concepto.Importe = xtr.Value.ToDecimal(); break;
case "CONCEPTO": concepto.Concepto = xtr.Value; break;
}
cont = xtr.MoveToNextAttribute();
}
xmlCFDI.complemento.nomina12.OtrosPagos.Add(concepto);
xtr.MoveToFirstAttribute();
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper() == "NOMINA12:SUBSIDIOALEMPLEO")
{
if (xmlCFDI.complemento.nomina12.Deducciones == null)
{
xmlCFDI.complemento.nomina12.Deducciones = new List<CFDINominaDeducciones>();
}
CFDINominaDeducciones concepto = new CFDINominaDeducciones();
cont = xtr.MoveToFirstAttribute();
while (cont)
{
concepto.TipoDeduccion = "-000-";
concepto.Clave = "D025";
concepto.Concepto = "Subsidio acreditable";
switch (xtr.Name.ToUpper())
{
case "SubsidioCausado": concepto.Importe = -xtr.Value.ToDecimal(); break;
}
cont = xtr.MoveToNextAttribute();
}
CFDINominaDeducciones concepto2 = new CFDINominaDeducciones();
concepto2.TipoDeduccion = "-001-";
concepto2.Clave = concepto.Clave;
concepto2.Concepto = concepto.Concepto;
concepto2.Importe = -concepto.Importe;
xmlCFDI.complemento.nomina12.Deducciones.Add(concepto2);
xmlCFDI.complemento.nomina12.Deducciones.Add(concepto);
xtr.MoveToFirstAttribute();
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
if (xtr.NodeType == XmlNodeType.Element && xtr.LocalName.ToUpper() == "PAGOS" && xmlCFDI.comprobante.Version != null)
{
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
xmlCFDI.complemento.Pagos = new CFDIPago();
@@ -618,13 +1119,9 @@ namespace ADSistemaLibrary3.SatXml
conts = xtr.MoveToFirstAttribute();
xmlCFDI.complemento.Pagos.doctosRelacionados.Add(objpago);
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
noavance = false;
}
}
else
{
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
}
}
}
}
@@ -1179,8 +1676,4 @@ namespace ADSistemaLibrary3.SatXml
public string UUID { get; set; }
}
}
}