1684 lines
88 KiB
C#
1684 lines
88 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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
|
|
{
|
|
#region "Propiedades"
|
|
|
|
public int anio
|
|
{
|
|
get { return ViewState["anio"] != null ? ViewState["anio"].ToString().ToEntero() : 0; }
|
|
set { ViewState["anio"] = value; }
|
|
}
|
|
public int mes
|
|
{
|
|
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)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
cargadatos();
|
|
}
|
|
}
|
|
DataTable dt;
|
|
public void cargadatos()
|
|
{
|
|
using (ClsEdocumentacion edoc = new ClsEdocumentacion())
|
|
{
|
|
if (edoc.TableroMaterialidadGET(UsuarioActual.CveEmpresa, (anio = Txtanio.Text.ToEntero()), (mes = ddlMes.SelectedValue.ToEntero())) && edoc.DSResultados.Tables.Count > 1)
|
|
{
|
|
RptDatos.DataSource = edoc.DSResultados.Tables[0];
|
|
dt = edoc.DSResultados.Tables[1];
|
|
RPTTableroHeader.DataSource = edoc.DSResultados.Tables[1];
|
|
RPTTableroHeader.DataBind();
|
|
RptDatos.DataBind();
|
|
DdlDocumentacion.DataSource = dt;
|
|
DdlDocumentacion.DataBind();
|
|
|
|
}
|
|
|
|
}
|
|
upPaneldata.Update();
|
|
}
|
|
|
|
protected void RptDatos_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
|
{
|
|
DataRowView item = (DataRowView)(e.Item.DataItem);
|
|
Repeater rpt = ((Repeater)e.Item.FindControl("rptdocumentacion"));
|
|
rpt.DataSource = dt;
|
|
rpt.DataBind();
|
|
}
|
|
|
|
|
|
|
|
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 = "[]";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
protected void BtnEnviarDoctos_Click(object sender, EventArgs e)
|
|
{
|
|
Alert("El correo se ha enviado.");
|
|
}
|
|
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
cargadatos();
|
|
}
|
|
|
|
|
|
protected void LckOpModalDoctos_Click(object sender, EventArgs e)
|
|
{
|
|
DateTime fecha = string.Format("{0}-{1}-01", anio, mes).ToDateTime();
|
|
LtlPeriodo.Text = fecha.ToString("MMMM yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX"));//string.Format("");
|
|
UpModalDoctos.Update();
|
|
RegistraScript("$('#ModalDoctos').modal();");
|
|
}
|
|
|
|
protected void LckOpModalDoctosPDFXML_Click(object sender, EventArgs e)
|
|
{
|
|
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();showhideprocesarguardar =0; openguardar();");
|
|
Upxmlpdf.Update();
|
|
}
|
|
|
|
protected void LnkCargarZip_Click(object sender, EventArgs e)
|
|
{
|
|
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}))$");
|
|
|
|
|
|
directorio = archivoxml.FileUrl.Substring(0, archivoxml.FileUrl.Length - 4);
|
|
System.IO.Directory.CreateDirectory(directorio);
|
|
ZipFile.ExtractToDirectory(archivoxml.FileUrl, directorio);
|
|
|
|
System.Xml.Linq.XDocument xmlarchivos = new System.Xml.Linq.XDocument();
|
|
XElement xfolder = new XElement("folder");
|
|
foreach (var urfile in System.IO.Directory.GetFiles(directorio, "*", SearchOption.AllDirectories))
|
|
{
|
|
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);
|
|
xfile.SetAttributeValue("Emisor", xmlobj.emisor.Nombre);
|
|
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);
|
|
xfile.SetAttributeValue("FechaInicio", xmlobj.complemento.nomina12.FechaInicio);
|
|
xfile.SetAttributeValue("FechaFin", xmlobj.complemento.nomina12.FechaFin);
|
|
xfile.SetAttributeValue("NumDiasPagados", xmlobj.complemento.nomina12.NumDiasPagados);
|
|
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);
|
|
}
|
|
|
|
|
|
xfolder.Add(xfile);
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
Upxmlpdf.Update();
|
|
}
|
|
}
|
|
|
|
protected void LnkProcesarDoctos_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
procesararchivo(xmlobject, string.Format("{0}{1}", anio, mes).ToEntero(), true);
|
|
procesararchivo(xmlobject, string.Format("{0}{1}", anio, mes).ToEntero(), false);
|
|
}
|
|
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;
|
|
}
|
|
|
|
}
|
|
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
|
|
{
|
|
string rutaarchivo { get; set; }
|
|
string extension { get; set; }
|
|
|
|
|
|
string RfcReceptor { get; set; }
|
|
string RfcEmisor { get; set; }
|
|
string Emisor { get; set; }
|
|
string Receptor { get; set; }
|
|
decimal SubTotal { get; set; }
|
|
decimal Descuento { get; set; }
|
|
decimal Total { get; set; }
|
|
|
|
|
|
string FechaPago { get; set; }
|
|
string periodo { get { return string.Format("", FechaInicialPago, FechaFinalPago); } }
|
|
|
|
string FechaInicialPago { get; set; }
|
|
string FechaFinalPago { get; set; }
|
|
string Curp { get; set; }
|
|
int NumDiasPagados { get; set; }
|
|
decimal TotalPercepciones { get; set; }
|
|
decimal TotalDeducciones { get; set; }
|
|
|
|
}
|
|
|
|
namespace ADSistemaLibrary3.SatXml
|
|
{
|
|
public class XmlSatCFDI
|
|
{
|
|
public XmlSatCFDI()
|
|
{
|
|
comprobante = new CFDIComprobante();
|
|
emisor = new CFDIEmisor();
|
|
receptor = new CFDIReceptor();
|
|
complemento = new CFDIComplemento();
|
|
cFDIRelacionados = new List<CFDIRelacionado>();
|
|
conceptos = new List<CFDIConcepto>();
|
|
Impuestos = new List<CFDIImpuesto>();
|
|
}
|
|
public CFDIComprobante comprobante;
|
|
public CFDIEmisor emisor;
|
|
public CFDIReceptor receptor;
|
|
public CFDIComplemento complemento;
|
|
public List<CFDIRelacionado> cFDIRelacionados;
|
|
public List<CFDIConcepto> conceptos;
|
|
public List<CFDIImpuesto> Impuestos;
|
|
public List<CFDIConcepto_I> GetConceptosforpdf()
|
|
{
|
|
List<CFDIConcepto_I> lcon = new List<CFDIConcepto_I>();
|
|
if (conceptos != null)
|
|
{
|
|
int _orden = 0;
|
|
foreach (CFDIConcepto item in conceptos)
|
|
{
|
|
_orden += 1;
|
|
CFDIConcepto_I con = new CFDIConcepto_I
|
|
{
|
|
tipo = 1,
|
|
orden = _orden,
|
|
ClaveProdServ = item.ClaveProdServ,
|
|
NoIdentificacion = item.NoIdentificacion,
|
|
Cantidad = item.Cantidad,
|
|
ClaveUnidad = item.ClaveUnidad,
|
|
Unidad = item.Unidad,
|
|
ValorUnitario = item.ValorUnitario,
|
|
Importe = item.Importe,
|
|
Descuento = item.Descuento,
|
|
NumeroPedimento = item.NumeroPedimento,
|
|
CuentaPredial = item.CuentaPredial,
|
|
Descripcion = item.Descripcion
|
|
};
|
|
int index = 0;
|
|
foreach (CFDIConceptoImpuesto Imp in item.Impuestos)
|
|
{
|
|
index++;
|
|
if (index > 1)
|
|
{
|
|
lcon.Add(con);
|
|
con = new CFDIConcepto_I
|
|
{
|
|
tipo = 2,
|
|
orden = _orden,
|
|
};
|
|
|
|
}
|
|
|
|
con.Impuesto = Imp.ImpuestoTexto;
|
|
con.Impuesto_Tipo = Imp.Tipo;
|
|
con.Impuesto_Base = Imp.Base;
|
|
con.Impuesto_TipoFactor = Imp.TipoFactor;
|
|
con.Impuesto_TasaOCuota = Imp.TasaOCuota;
|
|
con.Impuesto_Importe = Imp.Importe;
|
|
}
|
|
lcon.Add(con);
|
|
}
|
|
}
|
|
|
|
return lcon;
|
|
}
|
|
|
|
public static XmlSatCFDI readXML(string fileUrl)
|
|
{
|
|
XmlSatCFDI xmlCFDI = new XmlSatCFDI();
|
|
bool canread = true;
|
|
//keys
|
|
string keyComprobante = "Comprobante";
|
|
string keyCfdiRelacionados = "CfdiRelacionados";
|
|
string keyEmisor = "Emisor";
|
|
string keyReceptor = "Receptor";
|
|
string keyConceptos = "Conceptos";
|
|
string keyImpuestos = "Impuestos";
|
|
string keyComplemento = "Complemento";
|
|
//endkeys
|
|
string[] PrimerNivel = new string[] { keyCfdiRelacionados, keyEmisor, keyReceptor, keyConceptos, keyImpuestos, keyComplemento };
|
|
//(canread = xtr.Read()) para evitar ciclos infinitos, todos los .Read() los guardo en la variable Canread y en los while reviso primero esta variable
|
|
if (File.Exists(fileUrl))
|
|
{
|
|
XmlReaderSettings settings = new XmlReaderSettings();
|
|
settings.ConformanceLevel = ConformanceLevel.Fragment;
|
|
settings.IgnoreWhitespace = true;
|
|
settings.IgnoreComments = true;
|
|
using (XmlReader xtr = XmlReader.Create(fileUrl, settings))
|
|
{
|
|
|
|
while ((canread = xtr.Read()) && !(xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyComprobante))
|
|
{
|
|
//if (xtr.NodeType != XmlNodeType.Element) { while (xtr.Read() && xtr.NodeType != XmlNodeType.Element) { } }
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyComprobante)
|
|
{
|
|
int Nivel = xtr.Depth;
|
|
bool cont = xtr.MoveToFirstAttribute();
|
|
while (cont)
|
|
{
|
|
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "XMLNS:CFDI": xmlCFDI.comprobante.xmlns_cfdi = xtr.Value; break;
|
|
case "XMLNS:XSI": xmlCFDI.comprobante.xmlns_xsi = xtr.Value; break;
|
|
case "XSI:SCHEMALOCATION": xmlCFDI.comprobante.xsi_schemaLocation = xtr.Value; break;
|
|
case "VERSION": xmlCFDI.comprobante.Version = xtr.Value; break;
|
|
case "SERIE": xmlCFDI.comprobante.Serie = xtr.Value; break;
|
|
case "FOLIO": xmlCFDI.comprobante.Folio = xtr.Value; break;
|
|
case "FECHA": xmlCFDI.comprobante.Fecha = xtr.Value; break;
|
|
case "MONEDA": xmlCFDI.comprobante.Moneda = xtr.Value; break;
|
|
case "SUBTOTAL": decimal SubTotal = 0; decimal.TryParse(xtr.Value, out SubTotal); xmlCFDI.comprobante.SubTotal = SubTotal; break;
|
|
case "TOTAL": decimal Total = 0; decimal.TryParse(xtr.Value, out Total); xmlCFDI.comprobante.Total = Total; break;
|
|
case "DESCUENTO": decimal Descuento = 0; decimal.TryParse(xtr.Value, out Descuento); xmlCFDI.comprobante.Descuento = Descuento; break;
|
|
case "TIPOCAMBIO": decimal TipoCambio = 0; decimal.TryParse(xtr.Value, out TipoCambio); xmlCFDI.comprobante.TipoCambio = TipoCambio; break;
|
|
case "TIPODECOMPROBANTE": xmlCFDI.comprobante.TipoDeComprobante = xtr.Value; break;
|
|
case "FORMAPAGO": xmlCFDI.comprobante.FormaPago = xtr.Value; break;
|
|
case "FORMADEPAGO": xmlCFDI.comprobante.FormaPago = xtr.Value; break;
|
|
case "METODOPAGO": xmlCFDI.comprobante.MetodoPago = xtr.Value; break;
|
|
case "METODODEPAGO": xmlCFDI.comprobante.MetodoPago = xtr.Value; break;
|
|
case "CONDICIONESDEPAGO": xmlCFDI.comprobante.CondicionesDePago = xtr.Value; break;
|
|
case "LUGAREXPEDICION": xmlCFDI.comprobante.LugarExpedicion = xtr.Value; break;
|
|
case "CONFIRMACION": xmlCFDI.comprobante.Confirmacion = xtr.Value; break;
|
|
case "NOCERTIFICADO": xmlCFDI.comprobante.NoCertificado = xtr.Value; break;
|
|
case "SELLO": xmlCFDI.comprobante.Sello = xtr.Value; break;
|
|
case "CERTIFICADO": xmlCFDI.comprobante.Certificado = xtr.Value; break;
|
|
}
|
|
cont = xtr.MoveToNextAttribute();
|
|
}
|
|
cont = xtr.MoveToFirstAttribute();
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > Nivel)
|
|
{
|
|
if (PrimerNivel.Contains(xtr.Name.Replace("cfdi:", "")))
|
|
{
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyCfdiRelacionados)
|
|
{
|
|
int cDepth = xtr.Depth;
|
|
|
|
string TipoRelacion = null;
|
|
cont = xtr.MoveToFirstAttribute();
|
|
while (cont)
|
|
{
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "TIPORELACION": TipoRelacion = xtr.Value; break;
|
|
}
|
|
cont = xtr.MoveToNextAttribute();
|
|
}
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > cDepth)
|
|
{
|
|
if (xtr.Name.Replace("cfdi:", "") == "CfdiRelacionado")
|
|
{
|
|
CFDIRelacionado cfdir = new CFDIRelacionado();
|
|
cfdir.TipoRelacion = TipoRelacion;
|
|
cfdir.UUID = xtr.GetAttribute("UUID");
|
|
xmlCFDI.cFDIRelacionados.Add(cfdir);
|
|
}
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
}
|
|
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyEmisor)
|
|
{
|
|
|
|
|
|
int curentNivel = xtr.Depth;
|
|
cont = xtr.MoveToFirstAttribute();
|
|
while (cont)
|
|
{
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "REGIMENFISCAL": xmlCFDI.emisor.RegimenFiscal = xtr.Value; break;
|
|
case "NOMBRE": xmlCFDI.emisor.Nombre = xtr.Value; break;
|
|
case "RFC": xmlCFDI.emisor.Rfc = xtr.Value; break;
|
|
}
|
|
cont = xtr.MoveToNextAttribute();
|
|
}
|
|
while ((canread = xtr.Read()) && !(xtr.NodeType == XmlNodeType.Element && curentNivel >= xtr.Depth)) { }//continua hasta que no tenga nodos y (el nodo sea tipo elemnto y ete en el mismo nivel)
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyReceptor)
|
|
{
|
|
int curentNivel = xtr.Depth;
|
|
cont = xtr.MoveToFirstAttribute();
|
|
while (cont)
|
|
{
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "RFC": xmlCFDI.receptor.Rfc = xtr.Value; break;
|
|
case "NOMBRE": xmlCFDI.receptor.Nombre = xtr.Value; break;
|
|
case "RESIDENCIAFISCAL": xmlCFDI.receptor.ResidenciaFiscal = xtr.Value; break;
|
|
case "NUMREGIDTRIB": xmlCFDI.receptor.NumRegIdTrib = xtr.Value; break;
|
|
case "USOCFDI": xmlCFDI.receptor.UsoCFDI = xtr.Value; break;
|
|
}
|
|
cont = xtr.MoveToNextAttribute();
|
|
}
|
|
|
|
while ((canread = xtr.Read()) && !(xtr.NodeType == XmlNodeType.Element && curentNivel >= xtr.Depth)) { }//continua hasta que no tenga nodos y (el nodo sea tipo elemnto y ete en el mismo nivel)
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyConceptos)
|
|
{
|
|
int cDepth = xtr.Depth;
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > cDepth)
|
|
{
|
|
if (xtr.Name.Replace("cfdi:", "") == "Concepto")
|
|
{
|
|
int cDepthb = xtr.Depth;
|
|
CFDIConcepto concepto = new CFDIConcepto();
|
|
|
|
cont = xtr.MoveToFirstAttribute();
|
|
while (cont)
|
|
{
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "CLAVEPRODSERV": concepto.ClaveProdServ = xtr.Value; break;
|
|
case "NOIDENTIFICACION": concepto.NoIdentificacion = xtr.Value; break;
|
|
case "CANTIDAD": concepto.Cantidad = xtr.Value; break;
|
|
case "CLAVEUNIDAD": concepto.ClaveUnidad = xtr.Value; break;
|
|
case "UNIDAD": concepto.Unidad = xtr.Value; break;
|
|
case "VALORUNITARIO": decimal ValorUnitario = 0; decimal.TryParse(xtr.Value, out ValorUnitario); concepto.ValorUnitario = ValorUnitario; ; break;
|
|
case "IMPORTE": decimal Importe = 0; decimal.TryParse(xtr.Value, out Importe); concepto.Importe = Importe; ; break;
|
|
case "DESCUENTO": decimal DDescuento = 0; decimal.TryParse(xtr.Value, out DDescuento); concepto.Descuento = DDescuento; ; break;
|
|
case "DESCRIPCION": concepto.Descripcion = xtr.Value; break;
|
|
}
|
|
cont = xtr.MoveToNextAttribute();
|
|
}
|
|
xtr.MoveToFirstAttribute();
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > cDepthb)
|
|
{
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == "Impuestos")
|
|
{
|
|
int cDepthc = xtr.Depth;
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > cDepthc)
|
|
{
|
|
if (xtr.Name.Replace("cfdi:", "") == "Traslado" || xtr.Name.Replace("cfdi:", "") == "Retencion")
|
|
{
|
|
CFDIConceptoImpuesto impuesto = new CFDIConceptoImpuesto();
|
|
impuesto.Impuesto = xtr.GetAttribute("Impuesto");
|
|
impuesto.Tipo = xtr.LocalName;
|
|
decimal Base = 0;
|
|
decimal.TryParse(xtr.GetAttribute("Base"), out Base);
|
|
impuesto.Base = Base;
|
|
impuesto.TipoFactor = xtr.GetAttribute("TipoFactor");
|
|
decimal tasaOCuota = 0;
|
|
decimal.TryParse(xtr.GetAttribute("TasaOCuota"), out tasaOCuota);
|
|
impuesto.TasaOCuota = impuesto.TipoFactor == "Tasa" ? (tasaOCuota * 100).ToString("N4") : xtr.GetAttribute("TasaOCuota");
|
|
decimal ImImporte = 0;
|
|
decimal.TryParse(xtr.GetAttribute("Importe"), out ImImporte);
|
|
impuesto.Importe = ImImporte;
|
|
|
|
concepto.Impuestos.Add(impuesto);
|
|
}
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bool rednew = true;
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == "InformacionAduanera")
|
|
{
|
|
concepto.NumeroPedimento = xtr.GetAttribute("NumeroPedimento");
|
|
rednew = false; while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == "CuentaPredial")
|
|
{
|
|
concepto.CuentaPredial = xtr.GetAttribute("CuentaPredial");
|
|
rednew = false; while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
}
|
|
if (rednew) { while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { } }
|
|
|
|
}
|
|
}
|
|
|
|
xmlCFDI.conceptos.Add(concepto);
|
|
}
|
|
}
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyImpuestos)
|
|
{
|
|
int cDepth = xtr.Depth;
|
|
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > cDepth)
|
|
{
|
|
CFDIImpuesto impuest = new CFDIImpuesto();
|
|
if (xtr.Name.Replace("cfdi:", "") == "Traslado" || xtr.Name.Replace("cfdi:", "") == "Retencion" && xmlCFDI.comprobante.Version != null)
|
|
{
|
|
impuest.Tipo = xtr.LocalName == "Traslado" ? "Traslados" : (xtr.LocalName == "Retencion" ? "Retenciones" : "");
|
|
impuest.Impuesto = xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("Impuesto") : xtr.GetAttribute("impuesto");
|
|
impuest.TipoFactor = xtr.GetAttribute("TipoFactor");
|
|
impuest.TasaOCuota = xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("TasaOCuota") : xtr.GetAttribute("tasa");
|
|
decimal ImImporte = 0;
|
|
decimal.TryParse((xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("Importe") : xtr.GetAttribute("importe")), out ImImporte);
|
|
impuest.Importe = ImImporte;
|
|
xmlCFDI.Impuestos.Add(impuest);
|
|
}
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
|
|
}
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.Name.Replace("cfdi:", "") == keyComplemento)
|
|
{
|
|
int cDepth = xtr.Depth;
|
|
|
|
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");
|
|
xmlCFDI.complemento.xsi_schemaLocation = xtr.GetAttribute("xsi:schemaLocation");
|
|
xmlCFDI.complemento.Version = xtr.GetAttribute("Version");
|
|
xmlCFDI.complemento.UUID = xtr.GetAttribute("UUID");
|
|
xmlCFDI.complemento.FechaTimbrado = xtr.GetAttribute("FechaTimbrado");
|
|
xmlCFDI.complemento.RfcProvCertif = xtr.GetAttribute("RfcProvCertif");
|
|
xmlCFDI.complemento.SelloCFD = xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("SelloCFD") : xtr.GetAttribute("selloCFD");
|
|
xmlCFDI.complemento.NoCertificadoSAT = xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("NoCertificadoSAT") : xtr.GetAttribute("noCertificadoSAT");
|
|
xmlCFDI.complemento.SelloSAT = xmlCFDI.comprobante.Version == "3.3" ? xtr.GetAttribute("SelloSAT") : xtr.GetAttribute("selloSAT");
|
|
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
noavance = false;
|
|
}
|
|
if (xtr.NodeType == XmlNodeType.Element && xtr.LocalName.ToUpper() == "NOMINA" && xmlCFDI.comprobante.Version != null)
|
|
{
|
|
cont = xtr.MoveToFirstAttribute();
|
|
while (cont)
|
|
{
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "FECHAPAGO": xmlCFDI.complemento.nomina12.FechaPago = xtr.Value.ToDateTime(); break;
|
|
case "FECHAINICIALPAGO": xmlCFDI.complemento.nomina12.FechaInicio = xtr.Value; break;
|
|
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;
|
|
}
|
|
cont = xtr.MoveToNextAttribute();
|
|
}
|
|
xtr.MoveToFirstAttribute();
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
noavance = false;
|
|
}
|
|
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();
|
|
int depthpagos = xtr.Depth;
|
|
bool conts = xtr.MoveToFirstAttribute();
|
|
while (conts)
|
|
{
|
|
|
|
decimal Base = 0;
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "FECHAPAGO": xmlCFDI.complemento.Pagos.FechaPago = xtr.Value; break;
|
|
case "FORMADEPAGOP": xmlCFDI.complemento.Pagos.FormaDePagoP = xtr.Value; break;
|
|
case "FORMADEPAGOPTEXT": xmlCFDI.complemento.Pagos.FormaDePagoPText = xtr.Value; break;
|
|
case "MONEDAP": xmlCFDI.complemento.Pagos.MonedaP = xtr.Value; break;
|
|
case "MONTO": decimal.TryParse(xtr.Value, out Base); xmlCFDI.complemento.Pagos.Monto = Base; break;
|
|
case "TIPOCAMBIOP": decimal.TryParse(xtr.Value, out Base); xmlCFDI.complemento.Pagos.TipoCambioP = Base; break;
|
|
case "NUMOPERACION": xmlCFDI.complemento.Pagos.NumOperacion = xtr.Value; break;
|
|
case "NOMBANCOORDEXT": xmlCFDI.complemento.Pagos.NomBancoOrdExt = xtr.Value; break;
|
|
case "RFCEMISORCTAORD": xmlCFDI.complemento.Pagos.RfcEmisorCtaOrd = xtr.Value; break;
|
|
case "CTAORDENANTE": xmlCFDI.complemento.Pagos.CtaOrdenante = xtr.Value; break;
|
|
case "RFCEMISORCTABEN": xmlCFDI.complemento.Pagos.RfcEmisorCtaBen = xtr.Value; break;
|
|
case "CTABENEFICIARIO": xmlCFDI.complemento.Pagos.CtaBeneficiario = xtr.Value; break;
|
|
}
|
|
conts = xtr.MoveToNextAttribute();
|
|
}
|
|
conts = xtr.MoveToFirstAttribute();
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
while (canread && xtr.Depth > depthpagos)
|
|
{
|
|
CFDIPagoDoctoRelacionado objpago = new CFDIPagoDoctoRelacionado();
|
|
conts = xtr.MoveToFirstAttribute();
|
|
while (conts)
|
|
{
|
|
|
|
decimal Basep = 0;
|
|
switch (xtr.Name.ToUpper())
|
|
{
|
|
case "IDDOCUMENTO": objpago.IdDocumento = xtr.Value; break;
|
|
case "SERIE": objpago.Serie = xtr.Value; break;
|
|
case "FOLIO": objpago.Folio = xtr.Value; break;
|
|
case "MONEDADR": objpago.MonedaDR = xtr.Value; break;
|
|
case "METODODEPAGODR": objpago.MetodoDePagoDR = xtr.Value; break;
|
|
case "NUMPARCIALIDAD": objpago.NumParcialidad = xtr.Value; break;
|
|
case "IMPSALDOANT": decimal.TryParse(xtr.Value, out Basep); objpago.ImpSaldoAnt = Basep; break;
|
|
case "IMPPAGADO": decimal.TryParse(xtr.Value, out Basep); objpago.ImpPagado = Basep; break;
|
|
case "IMPSALDOINSOLUTO": decimal.TryParse(xtr.Value, out Basep); objpago.ImpSaldoInsoluto = Basep; break;
|
|
|
|
}
|
|
conts = xtr.MoveToNextAttribute();
|
|
}
|
|
conts = xtr.MoveToFirstAttribute();
|
|
xmlCFDI.complemento.Pagos.doctosRelacionados.Add(objpago);
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
noavance = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//si no entro en ninguna de los anteriores no se debe ciclar
|
|
while ((canread = xtr.Read()) && xtr.NodeType != XmlNodeType.Element) { }
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
if (xmlCFDI.comprobante.Version == "3.3" || xmlCFDI.comprobante.Version == "3.2")
|
|
{
|
|
return xmlCFDI;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public class utilValores
|
|
{
|
|
public utilValores(string nombre, string valor)
|
|
{
|
|
Nombre = nombre;
|
|
Valor = valor;
|
|
}
|
|
public string Nombre { get; set; }
|
|
public string Valor { get; set; }
|
|
}
|
|
public class utilImage
|
|
{
|
|
public utilImage(byte[] imagenByte)
|
|
{
|
|
ImagenByte = imagenByte;
|
|
}
|
|
public byte[] ImagenByte { get; set; }
|
|
}
|
|
}
|
|
|
|
public class CFDIComplemento
|
|
{
|
|
|
|
public string xmlns_tfd { get; set; }
|
|
public string xsi_schemaLocation { get; set; }
|
|
public string Version { get; set; }
|
|
public string UUID { get; set; }
|
|
public string FechaTimbrado { get; set; }
|
|
public string RfcProvCertif { get; set; }
|
|
public string SelloCFD { get; set; }
|
|
public string NoCertificadoSAT { get; set; }
|
|
public string SelloSAT { get; set; }
|
|
public CFDIPago Pagos { get; set; }
|
|
public CFDINomina nomina12 { get; set; }
|
|
public string CadenaOriginal
|
|
{
|
|
get
|
|
{
|
|
return string.Format("||{0}|{1}|{2}|{3}|{4}|{5}||", Version, UUID, FechaTimbrado, RfcProvCertif, SelloCFD, NoCertificadoSAT);
|
|
}
|
|
}
|
|
|
|
}
|
|
public class CFDIComprobante
|
|
{
|
|
public string xmlns_cfdi { get; set; }
|
|
public string xmlns_xsi { get; set; }
|
|
public string xsi_schemaLocation { get; set; }
|
|
public string Version { get; set; }
|
|
public string Serie { get; set; }
|
|
public string Folio { get; set; }
|
|
public string Fecha { get; set; }
|
|
public string Moneda { get; set; }
|
|
public decimal SubTotal { get; set; }
|
|
public decimal Total { get; set; }
|
|
public decimal Descuento { get; set; }
|
|
public decimal TipoCambio { get; set; }
|
|
public string TipoDeComprobante { get; set; }
|
|
|
|
public string TipoDeComprobanteSIG
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
if (Version == "3.3")
|
|
{
|
|
switch (TipoDeComprobante)
|
|
{
|
|
case "I":
|
|
retorno = "Ing";
|
|
break;
|
|
case "E":
|
|
retorno = "Egs";
|
|
break;
|
|
case "P":
|
|
retorno = "PA";
|
|
break;
|
|
//case "T":
|
|
// retorno = "Traslado";
|
|
// break;
|
|
//case "N":
|
|
// retorno = "Nómina";
|
|
// break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else if (Version == "3.2")
|
|
{
|
|
switch (TipoDeComprobante)
|
|
{
|
|
case "ingreso":
|
|
retorno = "Ing";
|
|
break;
|
|
case "egreso":
|
|
retorno = "Egs";
|
|
break;
|
|
case "P":
|
|
retorno = "PA";
|
|
break;
|
|
//case "T":
|
|
// retorno = "Traslado";
|
|
// break;
|
|
//case "N":
|
|
// retorno = "Nómina";
|
|
// break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else { retorno = TipoDeComprobante; }
|
|
return retorno;
|
|
}
|
|
}
|
|
public string TipoDeComprobanteTexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
|
|
if (Version == "3.3")
|
|
{
|
|
switch (TipoDeComprobante)
|
|
{
|
|
case "I":
|
|
retorno = "Ingreso";
|
|
break;
|
|
case "E":
|
|
retorno = "Egreso";
|
|
break;
|
|
case "P":
|
|
retorno = "Pago";
|
|
break;
|
|
case "T":
|
|
retorno = "Traslado";
|
|
break;
|
|
case "N":
|
|
retorno = "Nómina";
|
|
break;
|
|
|
|
default:
|
|
retorno = TipoDeComprobante;
|
|
break;
|
|
}
|
|
}
|
|
else if (Version == "3.2")
|
|
{
|
|
switch (TipoDeComprobante)
|
|
{
|
|
case "ingreso":
|
|
retorno = "Ing";
|
|
break;
|
|
case "egreso":
|
|
retorno = "Egs";
|
|
break;
|
|
case "P":
|
|
retorno = "PA";
|
|
break;
|
|
//case "T":
|
|
// retorno = "Traslado";
|
|
// break;
|
|
//case "N":
|
|
// retorno = "Nómina";
|
|
// break;
|
|
|
|
default:
|
|
retorno = TipoDeComprobante;
|
|
break;
|
|
}
|
|
}
|
|
else { retorno = TipoDeComprobante; }
|
|
return retorno;
|
|
}
|
|
}
|
|
public string FormaPago { get; set; }
|
|
|
|
public string FormaPagoTexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
|
|
switch (FormaPago)
|
|
{
|
|
case "01": retorno = "Efectivo"; break;
|
|
case "02": retorno = "Cheque nominativo"; break;
|
|
case "03": retorno = "Transferencia electrónica de fondos"; break;
|
|
case "04": retorno = "Tarjeta de crédito"; break;
|
|
case "05": retorno = "Monedero electrónico"; break;
|
|
case "06": retorno = "Dinero electrónico"; break;
|
|
case "08": retorno = "Vales de despensa"; break;
|
|
case "12": retorno = "Dación en pago"; break;
|
|
case "13": retorno = "Pago por subrogación"; break;
|
|
case "14": retorno = "Pago por consignación"; break;
|
|
case "15": retorno = "Condonación"; break;
|
|
case "17": retorno = "Compensación"; break;
|
|
case "23": retorno = "Novación"; break;
|
|
case "24": retorno = "Confusión"; break;
|
|
case "25": retorno = "Remisión de deuda"; break;
|
|
case "26": retorno = "Prescripción o caducidad"; break;
|
|
case "27": retorno = "A satisfacción del acreedor"; break;
|
|
case "28": retorno = "Tarjeta de débito"; break;
|
|
case "29": retorno = "Tarjeta de servicios"; break;
|
|
case "30": retorno = "Aplicación de anticipos"; break;
|
|
case "31": retorno = "Intermediario pagos"; break;
|
|
case "99": retorno = "Por definir"; break;
|
|
default: retorno = FormaPago; break;
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
public string MetodoPago { get; set; }
|
|
public string MetodoPagoTexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
|
|
switch (MetodoPago)
|
|
{
|
|
case "PUE": retorno = "Pago en una sola exhibición"; break;
|
|
case "PPD": retorno = "Pago en parcialidades o diferido"; break;
|
|
default: retorno = MetodoPago; break;
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
public string CondicionesDePago { get; set; }
|
|
public string LugarExpedicion { get; set; }
|
|
public string Confirmacion { get; set; }
|
|
public string NoCertificado { get; set; }
|
|
public string Sello { get; set; }
|
|
public string Certificado { get; set; }
|
|
|
|
}
|
|
|
|
public class CFDIConcepto
|
|
{
|
|
public CFDIConcepto()
|
|
{
|
|
Impuestos = new List<CFDIConceptoImpuesto>();
|
|
}
|
|
public string ClaveProdServ { get; set; }
|
|
public string NoIdentificacion { get; set; }
|
|
public string Cantidad { get; set; }
|
|
public string ClaveUnidad { get; set; }
|
|
public string Unidad { get; set; }
|
|
public decimal ValorUnitario { get; set; }
|
|
public decimal Importe { get; set; }
|
|
public decimal Descuento { get; set; }
|
|
public string NumeroPedimento { get; set; }
|
|
public string CuentaPredial { get; set; }
|
|
public string Descripcion { get; set; }
|
|
public List<CFDIConceptoImpuesto> Impuestos { get; set; }
|
|
}
|
|
|
|
public class CFDIConcepto_I
|
|
{
|
|
public int tipo { get; set; }
|
|
public int orden { get; set; }
|
|
public string ClaveProdServ { get; set; }
|
|
public string NoIdentificacion { get; set; }
|
|
public string Cantidad { get; set; }
|
|
public string ClaveUnidad { get; set; }
|
|
public string Unidad { get; set; }
|
|
public decimal ValorUnitario { get; set; }
|
|
public decimal Importe { get; set; }
|
|
public decimal Descuento { get; set; }
|
|
public string NumeroPedimento { get; set; }
|
|
public string CuentaPredial { get; set; }
|
|
public string Descripcion { get; set; }
|
|
|
|
|
|
public string Impuesto { get; set; }
|
|
|
|
public string Impuesto_Tipo { get; set; }
|
|
public decimal Impuesto_Base { get; set; }
|
|
public string Impuesto_TipoFactor { get; set; }
|
|
public string Impuesto_TasaOCuota { get; set; }
|
|
public decimal Impuesto_Importe { get; set; }
|
|
}
|
|
|
|
public class CFDIConceptoImpuesto
|
|
{
|
|
public string Impuesto { get; set; }
|
|
public string ImpuestoTexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
|
|
switch (Impuesto)
|
|
{
|
|
case "001": retorno = "ISR"; break;
|
|
case "002": retorno = "IVA"; break;
|
|
case "003": retorno = "IEPS"; break;
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
public string Tipo { get; set; }
|
|
public decimal Base { get; set; }
|
|
public string TipoFactor { get; set; }
|
|
public string TasaOCuota { get; set; }
|
|
public decimal Importe { get; set; }
|
|
|
|
}
|
|
|
|
public class CFDIEmisor
|
|
{
|
|
public string RegimenFiscal { get; set; }
|
|
|
|
public string RegimenFiscalTexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
|
|
switch (RegimenFiscal)
|
|
{
|
|
case "601": retorno = "General de Ley Personas Morales"; break;
|
|
case "603": retorno = "Personas Morales con Fines no Lucrativos"; break;
|
|
case "605": retorno = "Sueldos y Salarios e Ingresos Asimilados a Salarios"; break;
|
|
case "606": retorno = "Arrendamiento"; break;
|
|
case "608": retorno = "Demás ingresos"; break;
|
|
case "609": retorno = "Consolidación"; break;
|
|
case "610": retorno = "Residentes en el Extranjero sin Establecimiento Permanente en México"; break;
|
|
case "611": retorno = "Ingresos por Dividendos (socios y accionistas)"; break;
|
|
case "612": retorno = "Personas Físicas con Actividades Empresariales y Profesionales"; break;
|
|
case "614": retorno = "Ingresos por intereses"; break;
|
|
case "616": retorno = "Sin obligaciones fiscales"; break;
|
|
case "620": retorno = "Sociedades Cooperativas de Producción que optan por diferir sus ingresos"; break;
|
|
case "621": retorno = "Incorporación Fiscal"; break;
|
|
case "622": retorno = "Actividades Agrícolas, Ganaderas, Silvícolas y Pesqueras"; break;
|
|
case "623": retorno = "Opcional para Grupos de Sociedades"; break;
|
|
case "624": retorno = "Coordinados"; break;
|
|
case "628": retorno = "Hidrocarburos"; break;
|
|
case "607": retorno = "Régimen de Enajenación o Adquisición de Bienes"; break;
|
|
case "629": retorno = "De los Regímenes Fiscales Preferentes y de las Empresas Multinacionales"; break;
|
|
case "630": retorno = "Enajenación de acciones en bolsa de valores"; break;
|
|
case "615": retorno = "Régimen de los ingresos por obtención de premios"; break;
|
|
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
public string Nombre { get; set; }
|
|
public string Rfc { get; set; }
|
|
|
|
}
|
|
|
|
public class CFDIImpuesto
|
|
{
|
|
public string Tipo { get; set; }
|
|
public string Impuesto { get; set; }
|
|
public string ImpuestoTexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "";
|
|
|
|
switch (Impuesto)
|
|
{
|
|
case "001": retorno = "ISR"; break;
|
|
case "002": retorno = "IVA"; break;
|
|
case "003": retorno = "IEPS"; break;
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
public string TipoFactor { get; set; }
|
|
public string TasaOCuota { get; set; }
|
|
public decimal Importe { get; set; }
|
|
}
|
|
|
|
public class CFDIPago
|
|
{
|
|
public CFDIPago()
|
|
{
|
|
doctosRelacionados = new List<CFDIPagoDoctoRelacionado>();
|
|
}
|
|
public string FechaPago { get; set; }
|
|
public string FormaDePagoP { get; set; }
|
|
public string FormaDePagoPText { get; set; }
|
|
public string MonedaP { get; set; }
|
|
public decimal Monto { get; set; }
|
|
public decimal TipoCambioP { get; set; }
|
|
public string NumOperacion { get; set; }
|
|
public string NomBancoOrdExt { get; set; }
|
|
public string RfcEmisorCtaOrd { get; set; }
|
|
public string CtaOrdenante { get; set; }
|
|
public string RfcEmisorCtaBen { get; set; }
|
|
public string CtaBeneficiario { get; set; }
|
|
public List<CFDIPagoDoctoRelacionado> doctosRelacionados { get; set; }
|
|
}
|
|
|
|
public class CFDIPagoDoctoRelacionado
|
|
{
|
|
public string IdDocumento { get; set; }
|
|
public string Serie { get; set; }
|
|
public string Folio { get; set; }
|
|
public string MonedaDR { get; set; }
|
|
public string MetodoDePagoDR { get; set; }
|
|
public string NumParcialidad { get; set; }
|
|
public decimal ImpSaldoAnt { get; set; }
|
|
public decimal ImpPagado { get; set; }
|
|
public decimal ImpSaldoInsoluto { get; set; }
|
|
}
|
|
|
|
public class CFDIReceptor
|
|
{
|
|
public string Rfc { get; set; }
|
|
public string Nombre { get; set; }
|
|
public string ResidenciaFiscal { get; set; }
|
|
public string NumRegIdTrib { get; set; }
|
|
public string UsoCFDI { get; set; }
|
|
public string UsoCFDITexto
|
|
{
|
|
get
|
|
{
|
|
string retorno = "N/A";
|
|
|
|
switch (UsoCFDI)
|
|
{
|
|
case "G01":
|
|
retorno = "Adquisición de mercancías";
|
|
break;
|
|
case "G02":
|
|
retorno = "Devoluciones, descuentos o bonificaciones";
|
|
break;
|
|
case "G03":
|
|
retorno = "Gastos en general";
|
|
break;
|
|
case "I01":
|
|
retorno = "Construcciones";
|
|
break;
|
|
case "I02":
|
|
retorno = "Mobiliario y equipo de oficina por inversiones";
|
|
break;
|
|
case "I03":
|
|
retorno = "Equipo de transporte";
|
|
break;
|
|
case "I04":
|
|
retorno = "Equipo de cómputo y accesorios";
|
|
break;
|
|
case "I05":
|
|
retorno = "Dados, troqueles, moldes, matrices y herramental";
|
|
break;
|
|
case "I06":
|
|
retorno = "Comunicaciones telefónicas";
|
|
break;
|
|
case "I07":
|
|
retorno = "Comunicaciones satelitales";
|
|
break;
|
|
case "I08":
|
|
retorno = "Otra maquinaria y equipo";
|
|
break;
|
|
case "D01":
|
|
retorno = "Honorarios médicos, dentales y gastos hospitalarios.";
|
|
break;
|
|
case "D02":
|
|
retorno = "Gastos médicos por incapacidad o discapacidad";
|
|
break;
|
|
case "D03":
|
|
retorno = "Gastos funerales.";
|
|
break;
|
|
case "D04":
|
|
retorno = "Donativos.";
|
|
break;
|
|
case "D05":
|
|
retorno = "Intereses reales efectivamente pagados por créditos hipotecarios (casa habitación).";
|
|
break;
|
|
case "D06":
|
|
retorno = "Aportaciones voluntarias al SAR.";
|
|
break;
|
|
case "D07":
|
|
retorno = "Primas por seguros de gastos médicos.";
|
|
break;
|
|
case "D08":
|
|
retorno = "Gastos de transportación escolar obligatoria.";
|
|
break;
|
|
case "D09":
|
|
retorno = "Depósitos en cuentas para el ahorro, primas que tengan como base planes de pensiones.";
|
|
break;
|
|
case "D10":
|
|
retorno = "Pagos por servicios educativos (colegiaturas)";
|
|
break;
|
|
case "P01":
|
|
retorno = "Por definir";
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public class CFDIRelacionado
|
|
{
|
|
public string TipoRelacion { get; set; }
|
|
public string TipoRelacionTexto
|
|
{
|
|
|
|
get
|
|
{
|
|
string retorno;
|
|
|
|
switch (TipoRelacion)
|
|
{
|
|
case "01": retorno = "Nota de crédito de los documentos relacionados"; break;
|
|
case "02": retorno = "Nota de débito de los documentos relacionados"; break;
|
|
case "03": retorno = "Devolución de mercancía sobre facturas o traslados previos"; break;
|
|
case "04": retorno = "Sustitución de los CFDI previos"; break;
|
|
case "05": retorno = "Traslados de mercancias facturados previamente"; break;
|
|
case "06": retorno = "Factura generada por los traslados previos"; break;
|
|
case "07": retorno = "CFDI por aplicación de anticipo"; break;
|
|
default:
|
|
retorno = "Por definir";
|
|
break;
|
|
}
|
|
return retorno;
|
|
}
|
|
}
|
|
public string UUID { get; set; }
|
|
|
|
}
|
|
} |