This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-19 09:56:32 -07:00
parent 836f0fe7df
commit 83f52ddd40
3 changed files with 199 additions and 91 deletions

View File

@@ -3318,9 +3318,6 @@ Public Class ClsPaginas
'Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
'End Sub
Private Function Obt_ClavePagina(Pagina As String) As Integer Private Function Obt_ClavePagina(Pagina As String) As Integer
Dim Retorno As Integer Dim Retorno As Integer
@@ -4671,11 +4668,14 @@ Public Class ClsPaginas
Mensaje.Alert(Mensaje, pOpcion, JSBtnAceptar, TimeoutToast:=timeout) Mensaje.Alert(Mensaje, pOpcion, JSBtnAceptar, TimeoutToast:=timeout)
End If End If
End Sub End Sub
Protected Overrides Sub SavePageStateToPersistenceMedium(pviewState As Object) Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
If Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString.Length > 0 Then If Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString.Length > 0 Then
RegistraScript(ViewState("strToastMsglargonoreplace").ToString(), "esteseraunticklargoparaquenosesobrescribaconotro") RegistraScript(ViewState("strToastMsglargonoreplace").ToString(), "esteseraunticklargoparaquenosesobrescribaconotro")
ViewState("strToastMsglargonoreplace") = Nothing ViewState("strToastMsglargonoreplace") = Nothing
End If End If
End Sub
Protected Overrides Sub SavePageStateToPersistenceMedium(pviewState As Object)
'If Request.Form("__VIEWSTATE_KEY") IsNot Nothing Then Cache.Remove(Request.Form("__VIEWSTATE_KEY")) 'elimino la cachado anteriormente 'If Request.Form("__VIEWSTATE_KEY") IsNot Nothing Then Cache.Remove(Request.Form("__VIEWSTATE_KEY")) 'elimino la cachado anteriormente
Dim VSKey As String = String.Format("VIEWSTATE_{0}_{1}_{2}", Session.SessionID, Request.Path, Date.Now.Ticks) Dim VSKey As String = String.Format("VIEWSTATE_{0}_{1}_{2}", Session.SessionID, Request.Path, Date.Now.Ticks)
'Cache.Add(VSKey, pviewState, Nothing, Date.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, Nothing) 'Store the ViewState on Cache 'Cache.Add(VSKey, pviewState, Nothing, Date.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, Nothing) 'Store the ViewState on Cache

View File

@@ -17,12 +17,12 @@ Partial Class SessionesActivas
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then If Not IsPostBack Then
Dim listacve As New List(Of String) ' Dim listacve As New List(Of String)
listacve.Add("1815") ' listacve.Add("1815")
Notificaciones.AlertaVentana("notificacion", listacve, timeoutseconds:=0) ' Notificaciones.AlertaVentana("notificacion", listacve, timeoutseconds:=0)
RCveUsuario = "0" ' RCveUsuario = "0"
ClsSisNotificaciones.SendNotificacionERP(100, "Titulo", "Hola Mundo", 1) 'ClsSisNotificaciones.SendNotificacionERP(100, "Titulo", "Hola Mundo", 1)
CargaDatos("") CargaDatos("")
End If End If
End Sub End Sub

View File

@@ -24,6 +24,7 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
DdlSubProyectoDatos.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True "); DdlSubProyectoDatos.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ");
DdlSubProyectoDatos.DataBind(); DdlSubProyectoDatos.DataBind();
DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion: 1).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby: "Clasificacion"); DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion: 1).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby: "Clasificacion");
DdlClasificacion.DataBind(); DdlClasificacion.DataBind();
@@ -50,91 +51,177 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
{ {
ClsVentas ObjV = new ClsVentas(); ClsVentas ObjV = new ClsVentas();
ObjV.ConciliacionemitidasSATGet(UsuarioActual.CveEmpresa); ObjV.ConciliacionemitidasSATGet(UsuarioActual.CveEmpresa);
GVConciliacionemitidasSAT.DataSource = ObjV.DtResultados; GVConciliacionemitidasSAT.DataSource = ObjV.DtResultados.FiltraParametros("", "CveVenta");
ObjV.Dispose(); ObjV.Dispose();
GVConciliacionemitidasSAT.DataBind(); GVConciliacionemitidasSAT.DataBind();
UpDatosReporte.Update(); UpDatosReporte.Update();
}
private void registrarventa(GridViewRow gvrow)
{
{
string ruta = gvrow.DataKey("RutaXml");
strErrores = new StringBuilder();
XmlSatCFDI objxml = null;
Modelos.Factura objfact = null;
bool continuar = true;
objxml = XmlSatCFDI.readXML(ruta);
continuar = continuar && (objxml != null);
if (continuar)
{
objfact = GetFacturaFromXML(objxml);
}
continuar = continuar && (objfact != null);
if (continuar)
{
// Dim As New (ObjVentas.IniciaTransacSQL())
// Dim As = Nothing
// Dim MensajeAlert = New StringBuilder
ClsVentas ObjVentas = new ClsVentas();
ClsInventarios ObjInventario = new ClsInventarios(ObjVentas.IniciaTransacSQL());
ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL());
ClsContratos ObjContr = new ClsContratos(ObjVentas.IniciaTransacSQL());
ClsOS ObjOS = new ClsOS(ObjVentas.IniciaTransacSQL());
ClsBancos ObjBancos = new ClsBancos(ObjVentas.IniciaTransacSQL());
ClsClientes ObjClientes = new ClsClientes(ObjVentas.IniciaTransacSQL());
ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL());
ClsCGame ObjCGame = new ClsCGame(ObjVentas.IniciaTransacSQL());
ClsEdocumentacion ObjDocCliente = new ClsEdocumentacion(ObjVentas.IniciaTransacSQL());
ClsAcumuladores ObjAcum = new ClsAcumuladores(ObjVentas.IniciaTransacSQL());
ClsContPAQi ObjContPaq = null;
//StringBuilder MensajeAlert = new StringBuilder() ;
try
{
objfact.GuardarVenta(ref objfact, ref ObjVentas, ref ObjConta, ref ObjInventario, ref ObjContr, ref objfact.DtDetalle, objfact.CveNCaVincular, ref ObjContPaq, ref ObjBancos, ref ObjOS, ref ObjEventos, ref ObjCGame, ref ObjClientes, ObjAcum: ObjAcum);
}
catch (Exception)
{
objfact.CveVenta = -1;
}
if (ObjVentas.UpdateEstatusFactura(3, objxml.complemento.UUID, "", DateTime.ParseExact(objxml.comprobante.Fecha.Replace("T", " "), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture), ObjVentas.CveVenta, CvePAC: 4))
if (objfact.CveVenta > 0 && objfact.ErrorList.Count == 0)
{
ObjVentas.Commit();
}
else
{
foreach (string item in objfact.ErrorList)
{
strErrores.AppendLine("<br/>");
strErrores.AppendLine(item);
}
objfact.CveVenta = -1;
ObjVentas.RollBack();
}
ObjVentas.Dispose();
ObjConta.Dispose();
ObjInventario.Dispose();
ObjCGame.Dispose();
ObjContr.Dispose();
ObjDocCliente.Dispose();
ObjClientes.Dispose();
ObjAcum.Dispose();
}
if (objfact != null && objfact.CveVenta > 0)
{
CargaConciliacionemitidasSATGet();
Alert($"se ha agregado la factura correctamente.<br/> <a href=\"/Ventas/Ventas.aspx?CveVenta={objfact.CveVenta}\" > Ver Factura </a>", ModExtensiones.TipoMensaje.ToastInformacion, timeout: 25);
}
else { continuar = false; }
if (!continuar)
{
Alert($"no se pudo agregar la factura {strErrores.ToString()}", ModExtensiones.TipoMensaje.MsgAdvertencia);
}
}
} }
protected void LnkRegistrar_Click(object sender, EventArgs e) protected void LnkRegistrar_Click(object sender, EventArgs e)
{ {
GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer); GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer);
string ruta = gvrow.DataKey("RutaXml"); registrarventa(gvrow);
strErrores = new StringBuilder(); //string ruta = gvrow.DataKey("RutaXml");
XmlSatCFDI objxml = null; //strErrores = new StringBuilder();
Modelos.Factura objfact = null; //XmlSatCFDI objxml = null;
bool continuar = true; //Modelos.Factura objfact = null;
objxml = XmlSatCFDI.readXML(ruta); //bool continuar = true;
continuar = continuar && (objxml != null); //objxml = XmlSatCFDI.readXML(ruta);
if (continuar) //continuar = continuar && (objxml != null);
{ //if (continuar)
//{
objfact = GetFacturaFromXML(objxml); // objfact = GetFacturaFromXML(objxml);
} //}
continuar = continuar && (objfact != null); //continuar = continuar && (objfact != null);
if (continuar) //if (continuar)
{ //{
// Dim As New (ObjVentas.IniciaTransacSQL()) // // Dim As New (ObjVentas.IniciaTransacSQL())
// Dim As = Nothing // // Dim As = Nothing
// Dim MensajeAlert = New StringBuilder // // Dim MensajeAlert = New StringBuilder
ClsVentas ObjVentas = new ClsVentas(); // ClsVentas ObjVentas = new ClsVentas();
ClsInventarios ObjInventario = new ClsInventarios(ObjVentas.IniciaTransacSQL()); // ClsInventarios ObjInventario = new ClsInventarios(ObjVentas.IniciaTransacSQL());
ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL()); // ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL());
ClsContratos ObjContr = new ClsContratos(ObjVentas.IniciaTransacSQL()); // ClsContratos ObjContr = new ClsContratos(ObjVentas.IniciaTransacSQL());
ClsOS ObjOS = new ClsOS(ObjVentas.IniciaTransacSQL()); // ClsOS ObjOS = new ClsOS(ObjVentas.IniciaTransacSQL());
ClsBancos ObjBancos = new ClsBancos(ObjVentas.IniciaTransacSQL()); // ClsBancos ObjBancos = new ClsBancos(ObjVentas.IniciaTransacSQL());
ClsClientes ObjClientes = new ClsClientes(ObjVentas.IniciaTransacSQL()); // ClsClientes ObjClientes = new ClsClientes(ObjVentas.IniciaTransacSQL());
ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL()); // ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL());
ClsCGame ObjCGame = new ClsCGame(ObjVentas.IniciaTransacSQL()); // ClsCGame ObjCGame = new ClsCGame(ObjVentas.IniciaTransacSQL());
ClsEdocumentacion ObjDocCliente = new ClsEdocumentacion(ObjVentas.IniciaTransacSQL()); // ClsEdocumentacion ObjDocCliente = new ClsEdocumentacion(ObjVentas.IniciaTransacSQL());
ClsAcumuladores ObjAcum = new ClsAcumuladores(ObjVentas.IniciaTransacSQL()); // ClsAcumuladores ObjAcum = new ClsAcumuladores(ObjVentas.IniciaTransacSQL());
ClsContPAQi ObjContPaq = null; // ClsContPAQi ObjContPaq = null;
//StringBuilder MensajeAlert = new StringBuilder() ; // //StringBuilder MensajeAlert = new StringBuilder() ;
try // try
{ // {
objfact.GuardarVenta(ref objfact, ref ObjVentas, ref ObjConta, ref ObjInventario, ref ObjContr, ref objfact.DtDetalle, objfact.CveNCaVincular, ref ObjContPaq, ref ObjBancos, ref ObjOS, ref ObjEventos, ref ObjCGame, ref ObjClientes, ObjAcum: ObjAcum); // objfact.GuardarVenta(ref objfact, ref ObjVentas, ref ObjConta, ref ObjInventario, ref ObjContr, ref objfact.DtDetalle, objfact.CveNCaVincular, ref ObjContPaq, ref ObjBancos, ref ObjOS, ref ObjEventos, ref ObjCGame, ref ObjClientes, ObjAcum: ObjAcum);
} // }
catch (Exception ) // catch (Exception )
{ // {
objfact.CveVenta = -1; // objfact.CveVenta = -1;
} // }
if (ObjVentas.UpdateEstatusFactura(3, objxml.complemento.UUID, "", DateTime.ParseExact(objxml.comprobante.Fecha.Replace("T", " "), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture), ObjVentas.CveVenta, CvePAC: 4)) // if (ObjVentas.UpdateEstatusFactura(3, objxml.complemento.UUID, "", DateTime.ParseExact(objxml.comprobante.Fecha.Replace("T", " "), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture), ObjVentas.CveVenta, CvePAC: 4))
if (objfact.CveVenta > 0 && objfact.ErrorList.Count == 0) // if (objfact.CveVenta > 0 && objfact.ErrorList.Count == 0)
{ // {
ObjVentas.Commit(); // ObjVentas.Commit();
} // }
else // else
{ // {
foreach (string item in objfact.ErrorList) // foreach (string item in objfact.ErrorList)
{ // {
strErrores.AppendLine("<br/>"); // strErrores.AppendLine("<br/>");
strErrores.AppendLine(item); // strErrores.AppendLine(item);
} // }
objfact.CveVenta = -1; // objfact.CveVenta = -1;
ObjVentas.RollBack(); // ObjVentas.RollBack();
} // }
ObjVentas.Dispose(); // ObjVentas.Dispose();
ObjConta.Dispose(); // ObjConta.Dispose();
ObjInventario.Dispose(); // ObjInventario.Dispose();
ObjCGame.Dispose(); // ObjCGame.Dispose();
ObjContr.Dispose(); // ObjContr.Dispose();
ObjDocCliente.Dispose(); // ObjDocCliente.Dispose();
ObjClientes.Dispose(); // ObjClientes.Dispose();
ObjAcum.Dispose(); // ObjAcum.Dispose();
} //}
if (objfact != null && objfact.CveVenta > 0) //if (objfact != null && objfact.CveVenta > 0)
{ //{
CargaConciliacionemitidasSATGet(); // CargaConciliacionemitidasSATGet();
Alert($"se ha agregado la factura correctamente.<br/> <a href=\"/Ventas/Ventas.aspx?CveVenta={objfact.CveVenta}\" > Ver Factura </a>", ModExtensiones.TipoMensaje.MsgInformacion); // Alert($"se ha agregado la factura correctamente.<br/> <a href=\"/Ventas/Ventas.aspx?CveVenta={objfact.CveVenta}\" > Ver Factura </a>", ModExtensiones.TipoMensaje.ToastInformacion,timeout:25);
} //}
else { continuar = false; } //else { continuar = false; }
if (!continuar) //if (!continuar)
{ //{
Alert($"no se pudo agregar la factura {strErrores.ToString()}", ModExtensiones.TipoMensaje.MsgAdvertencia); // Alert($"no se pudo agregar la factura {strErrores.ToString()}", ModExtensiones.TipoMensaje.MsgAdvertencia);
} //}
} }
protected Modelos.Factura GetFacturaFromXML(XmlSatCFDI objxml) protected Modelos.Factura GetFacturaFromXML(XmlSatCFDI objxml)
@@ -389,10 +476,16 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
Row["CveTipoInvPS"] = DrPS["Inv_CveMetodoInventario"]; Row["CveTipoInvPS"] = DrPS["Inv_CveMetodoInventario"];
Row["CveTamaño"] = DrPS["CveTamaño"]; Row["CveTamaño"] = DrPS["CveTamaño"];
ADSistemaLibrary.SatXml.CFDIConceptoImpuesto impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Tipo == "Traslado"); ADSistemaLibrary.SatXml.CFDIConceptoImpuesto impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Tipo == "Traslado");
decimal sumaimpuesto=0;
decimal PorcentajeIVA = 0;
if (impuesto != null) if (impuesto != null)
{ {
Row["PorcentajeIVA"] = impuesto.TasaOCuota; decimal decimpuesto = 0;
Row["ImporteIVA"] = impuesto.Importe; decimal.TryParse(impuesto.TasaOCuota, out decimpuesto);
PorcentajeIVA = decimpuesto/100;
Row["PorcentajeIVA"] = decimpuesto / 100;
Row["ImporteIVA"] = decimpuesto / 100;// impuesto.Importe;//Math.Round(item.Importe * (decimpuesto/100), 2);
sumaimpuesto += impuesto.Importe;
} }
else else
{ {
@@ -403,9 +496,12 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "003" && x.Tipo == "Traslado"); impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "003" && x.Tipo == "Traslado");
if (impuesto != null) if (impuesto != null)
{ {
Row["PorcentajeIEPS"] = impuesto.TasaOCuota; decimal decimpuesto = 0;
decimal.TryParse(impuesto.TasaOCuota, out decimpuesto);
Row["PorcentajeIEPS"] = decimpuesto / 100;
Row["ImporteIEPS"] = impuesto.Importe; Row["ImporteIEPS"] = impuesto.Importe;
Row["IEPS"] = impuesto.Importe; Row["IEPS"] = impuesto.Importe;
sumaimpuesto += impuesto.Importe;
} }
else else
{ {
@@ -416,8 +512,11 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "001" && x.Tipo == "Retencion"); impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "001" && x.Tipo == "Retencion");
if (impuesto != null) if (impuesto != null)
{ {
decimal decimpuesto = 0;
decimal.TryParse(impuesto.TasaOCuota, out decimpuesto);
Row["PorcentajeRetISR"] = decimpuesto / 100;
Row["ImporteRetISR"] = impuesto.Importe; Row["ImporteRetISR"] = impuesto.Importe;
Row["PorcentajeRetISR"] = impuesto.TasaOCuota; sumaimpuesto -= impuesto.Importe;
} }
else else
{ {
@@ -427,8 +526,11 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Tipo == "Retencion"); impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Tipo == "Retencion");
if (impuesto != null) if (impuesto != null)
{ {
decimal decimpuesto = 0;
decimal.TryParse(impuesto.TasaOCuota, out decimpuesto);
Row["PorcentajeRetIVA"] = decimpuesto / 100;
Row["ImporteRetIVA"] = impuesto.Importe; Row["ImporteRetIVA"] = impuesto.Importe;
Row["PorcentajeRetIVA"] = impuesto.TasaOCuota; sumaimpuesto -= impuesto.Importe;
} }
else else
{ {
@@ -438,7 +540,8 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
Row["Descuento"] = item.Descuento; Row["Descuento"] = item.Descuento;
Row["TipoDescuento"] = "2"; Row["TipoDescuento"] = "2";
Row["Total"] = item.Importe; //Row["Total"] = item.Importe - sumaimpuesto;
Row["Total"] = item.Importe /(1+ PorcentajeIVA);
Row["TotalImporte"] = item.Importe; Row["TotalImporte"] = item.Importe;
Row["SATClaveProdServ"] = item.ClaveProdServ; Row["SATClaveProdServ"] = item.ClaveProdServ;
@@ -468,6 +571,11 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas
protected void LnkAceptarDefault_Click(object sender, EventArgs e) protected void LnkAceptarDefault_Click(object sender, EventArgs e)
{ {
RegistraScript("$('#DModalDefaults').modal('hide');"); RegistraScript("$('#DModalDefaults').modal('hide');");
//foreach (GridViewRow gvrow in GVConciliacionemitidasSAT.Rows)
//{
// registrarventa(gvrow);
//}
} }
} }
/* /*