que tenga folio fiscal

This commit is contained in:
2020-12-29 17:40:05 -07:00
parent 7726177eda
commit 65f3181806

View File

@@ -1,47 +1,47 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Extensiones;
using static Extensiones.ModExtensiones;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Extensiones;
using static Extensiones.ModExtensiones;
using Microsoft.Reporting.WebForms;
public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
private DataTable DtVentas
{
get { return (ViewState["DtVentas"] == null) ? null : (DataTable)ViewState["DtVentas"]; }
set { ViewState["DtVentas"] = value; }
}
private int CveVenta
{
get { return (ViewState["CveVenta"] == null) ? -1 : ViewState["CveVenta"].ToString().ToEntero(); }
set { ViewState["CveVenta"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CargaDatos();
}
}
private void CargaDatos()
{
HdnLigaRefacturar.Value = "";
if (Request["CveVenta"] != null)
{
this.CveVenta = Request["CveVenta"].ToString().ToEntero();
}
var ObjVentas = new ClsVentas();
if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -2, -1, "-1", "-1", "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario))
public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
private DataTable DtVentas
{
get { return (ViewState["DtVentas"] == null) ? null : (DataTable)ViewState["DtVentas"]; }
set { ViewState["DtVentas"] = value; }
}
private int CveVenta
{
get { return (ViewState["CveVenta"] == null) ? -1 : ViewState["CveVenta"].ToString().ToEntero(); }
set { ViewState["CveVenta"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CargaDatos();
}
}
private void CargaDatos()
{
HdnLigaRefacturar.Value = "";
if (Request["CveVenta"] != null)
{
this.CveVenta = Request["CveVenta"].ToString().ToEntero();
}
var ObjVentas = new ClsVentas();
if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -2, -1, "-1", "-1", "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario))
{
if (Request["CveVenta"] != null && Request["CveVenta"].ToString().ToEntero() > 0)
@@ -51,42 +51,42 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
else
{
DtVentas = ObjVentas.DtResultados.Copy();
}
}
ObjVentas.Dispose();
GvDatos.DataSource = DtVentas.FiltraParametros("CveEstatusFactura = 20 AND CveEstatusRefacturacion = 0");
var DtRefacturar = DtVentas.FiltraParametros("CveEstatusRefacturacion IN (1,3)");
if (DtRefacturar != null && DtRefacturar.Rows.Count > 0)
{
DivRefacturar.Visible = true;
GvRefacturaciones.DataSource = DtRefacturar;
GvRefacturaciones.DataBind();
}
GvDatos.DataBind();
UPDatos.Update();
}
protected void BtnValidar_Click(object sender, EventArgs e)
{
}
}
ObjVentas.Dispose();
GvDatos.DataSource = DtVentas.FiltraParametros("CveEstatusFactura = 20 AND CveEstatusRefacturacion = 0");
var DtRefacturar = DtVentas.FiltraParametros("CveEstatusRefacturacion IN (1,3)");
if (DtRefacturar != null && DtRefacturar.Rows.Count > 0)
{
DivRefacturar.Visible = true;
GvRefacturaciones.DataSource = DtRefacturar;
GvRefacturaciones.DataBind();
}
GvDatos.DataBind();
UPDatos.Update();
}
protected void BtnValidar_Click(object sender, EventArgs e)
{
this.HdnLigaRefacturar.Value = "";
this.CveVenta = -1;
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
string Total = GvRow.DataKey("Total");
string SubTotal = GvRow.DataKey("SubTotal");
string Uuid = GvRow.DataKey("FolioFiscal");
string RFCCliente = GvRow.DataKey("RFCCliente");
string Folio = GvRow.DataKey("Folio");
string TipoDocto = GvRow.DataKey("TipoDocto");
string Nombre = GvRow.DataKey("Nombre");
if (CveVenta > 0)
{
var resp = VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, Total);
this.CveVenta = -1;
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
string Total = GvRow.DataKey("Total");
string SubTotal = GvRow.DataKey("SubTotal");
string Uuid = GvRow.DataKey("FolioFiscal");
string RFCCliente = GvRow.DataKey("RFCCliente");
string Folio = GvRow.DataKey("Folio");
string TipoDocto = GvRow.DataKey("TipoDocto");
string Nombre = GvRow.DataKey("Nombre");
if (CveVenta > 0 && Uuid != "")
{
var resp = VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, Total);
if (resp.EnviarAcuse)
{
Alert(resp.Mensaje,TipoMensaje.MsgConfirmacion,"BtnEnviarMailCancelacion();");
@@ -94,30 +94,31 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
else
{
Alert(resp.Mensaje);
}
}
CargaDatos();
}
}
CargaDatos();
}
protected void BtnValidarRefacturacion_Click(object sender, EventArgs e)
{
protected void BtnValidarRefacturacion_Click(object sender, EventArgs e)
{
this.HdnLigaRefacturar.Value = "";
this.CveVenta = -1;
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
string Total = GvRow.DataKey("Total");
string SubTotal = GvRow.DataKey("SubTotal");
string Uuid = GvRow.DataKey("FolioFiscal");
string RFCCliente = GvRow.DataKey("RFCCliente");
string Folio = GvRow.DataKey("Folio");
string TipoDocto = GvRow.DataKey("TipoDocto");
string Nombre = GvRow.DataKey("Nombre");
if (CveVenta > 0)
{
this.CveVenta = -1;
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
this.CveVenta = GvRow.DataKey("CveVenta").ToEntero();
int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
string Total = GvRow.DataKey("Total");
string SubTotal = GvRow.DataKey("SubTotal");
string Uuid = GvRow.DataKey("FolioFiscal");
string RFCCliente = GvRow.DataKey("RFCCliente");
string Folio = GvRow.DataKey("Folio");
string TipoDocto = GvRow.DataKey("TipoDocto");
string Nombre = GvRow.DataKey("Nombre");
if (CveVenta > 0 && Uuid != "")
{
var respuesta = VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, Total, true);
CargaDatos();
if (respuesta.CveEstatus.Contiene(4,5))
@@ -129,7 +130,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
Alert(respuesta.Mensaje,TipoMensaje.MsgAdvertencia);
}
//if (respuesta.IrARefacturar)
//{
// Server.Transfer(respuesta.LigaRefacturacion);
@@ -138,46 +139,46 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
//{
// Alert(respuesta.Mensaje);
// CargaDatos();
//}
}
UPDatos.Update();
}
private MRespuestaSAT VerificarVigenciaSAT(int CveVenta, int CveCliente, string Folio, string TipoDocto, string uuid, string emisor, string receptor, string total, bool EsRefacturacion = false)
{
HdnLigaRefacturar.Value = "";
//}
}
UPDatos.Update();
}
private MRespuestaSAT VerificarVigenciaSAT(int CveVenta, int CveCliente, string Folio, string TipoDocto, string uuid, string emisor, string receptor, string total, bool EsRefacturacion = false)
{
HdnLigaRefacturar.Value = "";
var retorno = new MRespuestaSAT()
{
Mensaje = "",
EnviarAcuse = false,
LigaRefacturacion = "",
IrARefacturar = false
};
var sb = new StringBuilder();
string CancelacionAcuse = "";
DateTime CancelacionFecha = DateTime.Now;
int CveEstatus = 4;
try
{
var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, true);
if (resp != null)
};
var sb = new StringBuilder();
string CancelacionAcuse = "";
DateTime CancelacionFecha = DateTime.Now;
int CveEstatus = 4;
try
{
var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, true);
if (resp != null)
{
if (resp.Estado == null)
{
sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
retorno.Mensaje = sb.ToString();
return retorno;
}
sb.AppendFormat("Folio Fiscal: {0} <br/>", uuid);
sb.AppendFormat("Codigo Estado: {0} <br/>", resp.CodigoEstatus);
sb.AppendFormat("Estado: {0} <br/>", resp.Estado);
sb.AppendFormat("Es Cancelable: {0} <br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
if (resp.Estado == null)
{
sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
retorno.Mensaje = sb.ToString();
return retorno;
}
sb.AppendFormat("Folio Fiscal: {0} <br/>", uuid);
sb.AppendFormat("Codigo Estado: {0} <br/>", resp.CodigoEstatus);
sb.AppendFormat("Estado: {0} <br/>", resp.Estado);
sb.AppendFormat("Es Cancelable: {0} <br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
sb.AppendFormat("Estatus de Cancelación: {0} <br/><br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EstatusCancelacion);
if (!UsuarioActual.Empresa.FacturaProduccion && (string.IsNullOrEmpty(uuid) || uuid.Contains("test")))
@@ -253,31 +254,31 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
}
ObjVentas.Dispose();
}
}
}
else
{
sb.Append("No se pudo comprobar la vigencia de la factura.");
}
}
else
{
sb.Append("No se pudo comprobar la vigencia de la factura.");
retorno.Mensaje = sb.ToString();
return retorno;
}
}
catch (Exception ex)
{
return retorno;
}
}
catch (Exception ex)
{
sb.Append("Error al consumir el servicio: " + ex.Message);
retorno.Mensaje = sb.ToString();
return retorno;
}
retorno.CveEstatus = CveEstatus;
return retorno;
}
retorno.CveEstatus = CveEstatus;
retorno.Mensaje = sb.ToString();
return retorno;
}
private Modelos.Factura.MCancelacionVentaMensaje CancelarDocumento(int CveVenta, int CveEstatus, int CveCliente, string Folio, string FolioFiscal, string CancelacionAcuse, DateTime CancelacionFecha, string TipoComprobante, double Total, int CvePACCancelacion, bool EsRefacturacion = false)
{
Modelos.Factura.MCancelacionVentaMensaje retorno = null;
var factura = new Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:true);
return retorno;
}
private Modelos.Factura.MCancelacionVentaMensaje CancelarDocumento(int CveVenta, int CveEstatus, int CveCliente, string Folio, string FolioFiscal, string CancelacionAcuse, DateTime CancelacionFecha, string TipoComprobante, double Total, int CvePACCancelacion, bool EsRefacturacion = false)
{
Modelos.Factura.MCancelacionVentaMensaje retorno = null;
var factura = new Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:true);
if (EsRefacturacion)
{
retorno = factura.CancelarPorRefacturacion();
@@ -285,63 +286,63 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
else
{
retorno = factura.EjecutarCancelacionPendiente(CveEstatus, CancelacionFecha, CancelacionAcuse);
}
return retorno;
}
private string DecodeBase64(string strXMLCodificado)
{
try
{
byte[] decbuff = Convert.FromBase64String(strXMLCodificado);
return System.Text.Encoding.UTF8.GetString(decbuff);
}
catch
{
return "";
}
}
protected void LnkValidar_Click(object sender, EventArgs e)
}
return retorno;
}
private string DecodeBase64(string strXMLCodificado)
{
try
{
byte[] decbuff = Convert.FromBase64String(strXMLCodificado);
return System.Text.Encoding.UTF8.GetString(decbuff);
}
catch
{
return "";
}
}
protected void LnkValidar_Click(object sender, EventArgs e)
{
this.HdnLigaRefacturar.Value = "";
this.CveVenta = -1;
if (DtVentas != null)
{
var sb = new StringBuilder();
foreach (DataRow Row in DtVentas.Rows)
{
int CveVenta = Row["CveVenta"].ToEntero();
string Total = Row["Total"].ToString();
string SubTotal = Row["SubTotal"].ToString();
string Uuid = Row["FolioFiscal"].ToString();
string RFCCliente = Row["RFCCliente"].ToString();
string Folio = Row["Folio"].ToString();
string TipoDocto = Row["TipoDocto"].ToString();
string Nombre = Row["Nombre"].ToString();
int CveCliente = Row["CveCliente"].ToEntero();
if (CveVenta > 0)
{
sb.AppendFormat("{0}<br/>", VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, SubTotal));
}
}
Alert(sb.ToString());
}
CargaDatos();
}
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 0)
{
e.Row.Cells[10].Text = "";
}
}
}
this.CveVenta = -1;
if (DtVentas != null)
{
var sb = new StringBuilder();
foreach (DataRow Row in DtVentas.Rows)
{
int CveVenta = Row["CveVenta"].ToEntero();
string Total = Row["Total"].ToString();
string SubTotal = Row["SubTotal"].ToString();
string Uuid = Row["FolioFiscal"].ToString();
string RFCCliente = Row["RFCCliente"].ToString();
string Folio = Row["Folio"].ToString();
string TipoDocto = Row["TipoDocto"].ToString();
string Nombre = Row["Nombre"].ToString();
int CveCliente = Row["CveCliente"].ToEntero();
if (CveVenta > 0)
{
sb.AppendFormat("{0}<br/>", VerificarVigenciaSAT(CveVenta, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCCliente, SubTotal));
}
}
Alert(sb.ToString());
}
CargaDatos();
}
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DBCampo("PuedeRefacturar").ToString().ToEntero() == 0)
{
e.Row.Cells[10].Text = "";
}
}
}
public void BtnEnviarMailCancelacion_Click(object sender, EventArgs e)
{
if (this.CveVenta > 0)
@@ -353,7 +354,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
Alert("No se encontro la factura para enviar el acuse", TipoMensaje.MsgAdvertencia);
}
}
public void ImprimeCancelacion(int CveVenta)
{
var Archivo = new System.IO.FileInfo(ModExtensiones.DirectorioBaseEmpresas + @"Empresas\Grales\Formatos\AcuseCancelacion.rdlc");
@@ -457,7 +458,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
}
}
}
}
public class MRespuestaSAT
{
public int CveEstatus { get; set; }