diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 47781c241..d588bbb5d 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -2755,9 +2755,9 @@ Public Class ClsVentas Return Retorno End Function - Public Function GetRepRemisionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSubProyecto As String, CveCliente As Integer, CveContrato As Integer, CveVendedor As String, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1) As Boolean + Public Function GetRepRemisionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSubProyecto As String, CveCliente As Integer, CveContrato As Integer, CveVendedor As String, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1, Optional ConsultaInventario As Boolean = False) As Boolean Dim Retorno As Boolean = False - DataAdapter("Vta_RepRemisionesGet") + DataAdapter("PA_Vta_RepRemisionesGet") With SqlAdapter.SelectCommand.Parameters .Add("@FechaI", SqlDbType.VarChar).Value = FechaI @@ -2769,6 +2769,7 @@ Public Class ClsVentas .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@ConsultaInventario", SqlDbType.Bit).Value = ConsultaInventario End With Try @@ -2780,9 +2781,9 @@ Public Class ClsVentas Return Retorno End Function - Public Function GetRepRemisionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, Optional CveUsuarioConsulta As Integer = -1) As Boolean + Public Function GetRepRemisionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, Optional CveUsuarioConsulta As Integer = -1, Optional ConsultaInventario As Boolean = False) As Boolean Dim Retorno As Boolean = False - DataAdapter("Vta_RepRemisionesDetalleGet") + DataAdapter("PA_Vta_RepRemisionesDetalleGet") With SqlAdapter.SelectCommand.Parameters .Add("@FechaI", SqlDbType.VarChar).Value = FechaI @@ -2794,6 +2795,7 @@ Public Class ClsVentas .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@ConsultaInventario", SqlDbType.Bit).Value = ConsultaInventario End With Try @@ -3056,6 +3058,24 @@ Public Class ClsVentas Return OnError End Function + Public Function GetFacturasRelacionadasPorFolioFiscal(FoliosFiscales As String, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + DataAdapter("PA_Vta_FacturasRelacionadasPorFolioFiscalGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FoliosFiscales", SqlDbType.VarChar).Value = FoliosFiscales + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener las facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + Public Function GetFacturasCanceladasPendientesWS(RFC As String, CveEmpresa As Integer, Optional showalert As Boolean = True) As Boolean Dim retorno As Boolean = False Try @@ -3095,6 +3115,8 @@ Public Class ClsVentas Return retorno End Function + + Public Function UpdateVentaFacturas(CveFactura As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean Dim OnError As Boolean = False diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 6544e4cd2..2bb1ae51e 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -29,20 +29,42 @@ Public Class Timbrado Public Property EstatusCancelacion As String End Class + Public Class RelacionadosPadre + Public Property Uuid As String + Public Property RfcEmisor As String + Public Property RfcReceptor As String + End Class + + Public Class RelacionadosHijo + Public Property Uuid As String + Public Property RfcEmisor As String + Public Property RfcReceptor As String + End Class + + Public Class MRespUUIDRelacionados + Public Property Codigo As Integer + Public Property Mensaje As String + Public Property Resultado As String + Public Property RelacionadosPadre As List(Of RelacionadosPadre) + Public Property RelacionadosHijo As List(Of RelacionadosHijo) + End Class + #End Region Public Shared Function VerificarVigenciaSAT(uuid As String, emisor As String, receptor As String, total As String, produccion As Boolean) As AcuseCancelacionSAT Dim Retorno As AcuseCancelacionSAT = Nothing - Dim resp As Cancelacion.AcuseSat = New Cancelacion.AcuseSat() - Using ws As Cancelacion.CancelacionSoapClient = New Cancelacion.CancelacionSoapClient + Dim resp As Cancelacion2022.AcuseSat = New Cancelacion2022.AcuseSat() + Using ws As Cancelacion2022.CancelacionSoapClient = New Cancelacion2022.CancelacionSoapClient Try If Not produccion Then - Dim PACUsuario As String = "rene.molina@adsistemas.mx" - Dim PACContrasenia As String = "rene2018" + Dim PACUsuario As String = "UserTest" + Dim PACContrasenia As String = "1234567890" resp = ws.ConsultaVigenciaTest(emisor, PACUsuario, PACContrasenia, uuid, receptor, total) Retorno = New AcuseCancelacionSAT() Else - resp = ws.ConsultaVigencia(emisor, "UserTest", "1234567890", uuid, receptor, total) + Dim PACUsuario As String = "rene.molina@adsistemas.mx" + Dim PACContrasenia As String = "rene2018" + resp = ws.ConsultaVigencia(emisor, PACUsuario, PACContrasenia, uuid, receptor, total) Retorno = New AcuseCancelacionSAT() End If Catch ex As Exception @@ -61,6 +83,52 @@ Public Class Timbrado End Using Return Retorno End Function + + Public Shared Function ConsultarUUIDRelacionados(Empresa As Empresa, FolioFiscal As String, Optional Produccion As Boolean = True) As MRespUUIDRelacionados + Dim Retorno = New MRespUUIDRelacionados() + Dim resp As Cancelacion2022.StructRelations = New Cancelacion2022.StructRelations() + + Using ws As Cancelacion2022.CancelacionSoapClient = New Cancelacion2022.CancelacionSoapClient + Try + Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" + Dim Key As String = Empresa.ContraseñaKey + + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String = "", certBase64 As String = "" + + llaveByte = System.IO.File.ReadAllBytes(ArchivoLLave) + llaveBase64 = Convert.ToBase64String(llaveByte) + + certByte = System.IO.File.ReadAllBytes(ArchivoCertificado) + certBase64 = Convert.ToBase64String(certByte) + + If Not Produccion Then + Dim PACUsuario As String = "UserTest" + Dim PACContrasenia As String = "1234567890" + resp = ws.ObtieneRelacionadosTest(Empresa.RFC, PACUsuario, PACContrasenia, certBase64, llaveBase64, Key, FolioFiscal) + Else + Dim PACUsuario As String = "rene.molina@adsistemas.mx" + Dim PACContrasenia As String = "rene2018" + resp = ws.ObtieneRelacionados(Empresa.RFC, PACUsuario, PACContrasenia, certBase64, llaveBase64, Key, FolioFiscal) + End If + + Catch ex As Exception + Dim Strr As String = String.Format("Error al verificar estatus de cancelacion:{0}", ex.Message) + Strr.GuardaLog() + Return Nothing + End Try + End Using + + Dim Json As String = Newtonsoft.Json.JsonConvert.SerializeObject(resp) + + If Not String.IsNullOrEmpty(Json) Then + Retorno = Newtonsoft.Json.JsonConvert.DeserializeObject(Of MRespUUIDRelacionados)(Json) + End If + + Return Retorno + End Function + Public Function CFDICancelar(Empresa As Empresa, FolioFiscal As String, Total As Decimal, RFCReceptor As String, RFCEmisor As String, Optional CvePACCancelacion As Integer = 2, Optional ValidaFactura As Boolean = True, Optional CveSATMotivoCancelacion As Integer = -1, Optional FolioSustitucion As String = "") As Boolean Dim Retorno As Boolean = False Dim MsgCancelacion As New StringBuilder diff --git a/App_WebReferences/Cancelacion2022/Cancelacion.disco b/App_WebReferences/Cancelacion2022/Cancelacion.disco new file mode 100644 index 000000000..4ddc38db6 --- /dev/null +++ b/App_WebReferences/Cancelacion2022/Cancelacion.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App_WebReferences/Cancelacion2022/Cancelacion.wsdl b/App_WebReferences/Cancelacion2022/Cancelacion.wsdl new file mode 100644 index 000000000..b11d5443c --- /dev/null +++ b/App_WebReferences/Cancelacion2022/Cancelacion.wsdl @@ -0,0 +1,496 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cancela un Cfdi en pruebas + + + + + Obtiene el estatus de un Cfdi en producción + + + + + Obtiene el estatus de un Cfdi en pruebas + + + + + Obtiene los Uuid pendientes de aceptar/rechazar de un Receptor (Producción) + + + + + Obtiene los Uuid pendientes de aceptar/rechazar de un Receptor (Pruebas) + + + + + Acepta/Rechaza una solicitud pendiente de cancelación (Producción) + + + + + Acepta/Rechaza una solicitud pendiente de cancelación (Pruebas) + + + + + Obtiene el/los Cfdi(s) relacionado(s) de un UUID de un RFC (Pruebas) + + + + + Obtiene el/los Cfdi(s) relacionado(s) de un UUID de un RFC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/Cancelacion2022/Reference.svcmap b/App_WebReferences/Cancelacion2022/Reference.svcmap new file mode 100644 index 000000000..c8a95a14c --- /dev/null +++ b/App_WebReferences/Cancelacion2022/Reference.svcmap @@ -0,0 +1,31 @@ + + + + false + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/Cancelacion2022/configuration.svcinfo b/App_WebReferences/Cancelacion2022/configuration.svcinfo new file mode 100644 index 000000000..513fc18cd --- /dev/null +++ b/App_WebReferences/Cancelacion2022/configuration.svcinfo @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/Cancelacion2022/configuration91.svcinfo b/App_WebReferences/Cancelacion2022/configuration91.svcinfo new file mode 100644 index 000000000..b03c6a068 --- /dev/null +++ b/App_WebReferences/Cancelacion2022/configuration91.svcinfo @@ -0,0 +1,310 @@ + + + + + + + CancelacionSoap4 + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + Transport + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (Collection) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + CancelacionSoap5 + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (Collection) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + https://cancel.gofac.com.mx/Cancelacion.asmx + + + + + + basicHttpBinding + + + CancelacionSoap4 + + + Cancelacion2022.CancelacionSoap + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + CancelacionSoap2 + + + + + + + + + + + \ No newline at end of file diff --git a/Ventas/RepRemisiones.aspx.vb b/Ventas/RepRemisiones.aspx.vb index 48a87762a..2d67f4de7 100644 --- a/Ventas/RepRemisiones.aspx.vb +++ b/Ventas/RepRemisiones.aspx.vb @@ -91,7 +91,7 @@ Partial Class RepRemisiones Dim Vendedores As String = IIf(DdlVendedor.GetSelectedValuesM = "", "-1", DdlVendedor.GetSelectedValuesM).ToString Dim ObjVentas As New ClsVentas - If ObjVentas.GetRepRemisionesSinFacturar(FechaI, FechaF, FechaV, Sucursales, CveCliente, CveContrato, Vendedores, UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + If ObjVentas.GetRepRemisionesSinFacturar(FechaI, FechaF, FechaV, Sucursales, CveCliente, CveContrato, Vendedores, UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, ConsultaInventario:=UsuarioActual.TienePermisoProceso(201)) Then DtVentas = ObjVentas.DtResultados.Copy() GvDatos.DataSource = DtVentas End If diff --git a/Ventas/RepRemisionesDetalle.aspx.vb b/Ventas/RepRemisionesDetalle.aspx.vb index 43fcb6801..9863874e9 100644 --- a/Ventas/RepRemisionesDetalle.aspx.vb +++ b/Ventas/RepRemisionesDetalle.aspx.vb @@ -158,7 +158,7 @@ Partial Class RepRemisionesDetalle CveContrato = If(DdlContrato.SelectedValue.ToEntero > 0, DdlContrato.SelectedValue.ToEntero, -1) CveSubProyecto = IIf(DdlSubProyectos.GetSelectedValuesM = "", "-1", DdlSubProyectos.GetSelectedValuesM).ToString - If ObjVentas.GetRepRemisionesSinFacturarDetalle(FechaI, FechaF, FechaV, CveCliente, CveContrato, CveVenta, UsuarioActual.CveEmpresa, CveSubProyecto, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + If ObjVentas.GetRepRemisionesSinFacturarDetalle(FechaI, FechaF, FechaV, CveCliente, CveContrato, CveVenta, UsuarioActual.CveEmpresa, CveSubProyecto, CveUsuarioConsulta:=UsuarioActual.CveUsuario, ConsultaInventario:=UsuarioActual.TienePermisoProceso(201)) Then If CveMoneda = 1 Or CveMoneda = 2 Then DtVentas = ObjVentas.DtResultados.FiltraParametros($"CveMoneda = {CveMoneda}") Else diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 6e49fe4e0..6fa5d7820 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -7076,7 +7076,49 @@ -
+ +
+
+
+
+ Facturas Padre +
+
+
+
+ + + + + + + +
+
+ +
+
+
+
+ Facturas Hijo +
+
+
+
+ + + + + + + +
+
+ +
+
+
+
@@ -7086,7 +7128,7 @@
-
+
@@ -7123,8 +7165,8 @@ diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index bee0d8d46..23699b2cd 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -20310,7 +20310,6 @@ Partial Class Ventas SWatch.Start() Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True) - SWatch.Stop() Dim SegundosRespuesta As Double = SWatch.ElapsedMilliseconds / 1000 @@ -22804,7 +22803,7 @@ Partial Class Ventas ObjVentas.Dispose() End Sub - Private Sub MostrarCondicionesCancelacion() + Private Sub MostrarCondicionesCancelacion(Optional Extra As String = "") Dim SbCondiciones As New StringBuilder() If VentaSaldoAlmacen < 0 AndAlso ChkDevAlm.Checked Then @@ -22817,6 +22816,10 @@ Partial Class Ventas SbCondiciones.Append("
     -La remisión está relacionada con otra factura.") End If + If Extra.Length > 0 Then + SbCondiciones.AppendFormat("
*{0}", Extra) + End If + LbCancelarDescripcion.Text = SbCondiciones.ToString() SbCondiciones.Clear() UpCancelarDocumento.Update() @@ -22832,8 +22835,10 @@ Partial Class Ventas If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs", "RNC") Then Dim sb As New StringBuilder() + Dim sbExtra As New StringBuilder() sb.Append("La factura se encuentra en el siguiente estatus del SAT:
") + Dim TotalT As Decimal = TxtTotal.Text.ToDecimal Dim RFCReceptor As String = "" @@ -22865,8 +22870,59 @@ Partial Class Ventas If Vigencia IsNot Nothing Then If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then - Alert("Esta factura no es cancelable.", TipoMensaje.MsgAdvertencia) - Exit Sub + + DivRelacionadasCancelacion.Visible = True + BtnCancelarDocumento.Visible = False + DivMotivoCancelacion.Visible = False + DivMotivoCancelacionTxt.Visible = False + DivCanRem.Visible = False + DivDevAlm.Visible = False + + Dim Relacionados = Timbrado.ConsultarUUIDRelacionados(UsuarioActual.Empresa, FolioFiscal, UsuarioActual.Empresa.FacturaProduccion) + If Relacionados IsNot Nothing Then + sbExtra.Append(Relacionados.Mensaje) + + Dim SbHijos = New StringBuilder() + Dim SbPadres = New StringBuilder() + + If Relacionados.RelacionadosHijo IsNot Nothing Then + For Each hijo In Relacionados.RelacionadosHijo + SbHijos.AppendFormat("{0};", hijo.Uuid) + Next + If SbHijos.Length > 0 Then + SbHijos.Remove(SbHijos.Length - 1, 1) + End If + End If + + If Relacionados.RelacionadosPadre IsNot Nothing Then + For Each padre In Relacionados.RelacionadosPadre + SbPadres.AppendFormat("{0};", padre.Uuid) + Next + If SbPadres.Length > 0 Then + SbPadres.Remove(SbPadres.Length - 1, 1) + End If + End If + + Using ObjVentas As New ClsVentas + + If SbHijos.Length > 0 Then + If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbHijos.ToString(), UsuarioActual.CveEmpresa) Then + GvFacturasHijosCancelar.DataSource = ObjVentas.DtResultados.Copy() + End If + End If + + If SbPadres.Length > 0 Then + If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbPadres.ToString(), UsuarioActual.CveEmpresa) Then + GvFacturasPadreCancelar.DataSource = ObjVentas.DtResultados.Copy() + End If + End If + + End Using + + GvFacturasHijosCancelar.DataBind() + GvFacturasPadreCancelar.DataBind() + End If + End If If String.IsNullOrEmpty(Vigencia.EsCancelable) Then If UsuarioActual.Empresa.FacturaProduccion AndAlso Not String.IsNullOrEmpty(FolioFiscal) Then @@ -22875,17 +22931,20 @@ Partial Class Ventas End If sb.Append("No encontrado
") + sb.Append("Está seguro de cancelar el documento?.") Else sb.AppendFormat("{0}
", Vigencia.EsCancelable) + If Vigencia.EsCancelable.ToUpper() <> "NO CANCELABLE" Then + sb.Append("Está seguro de cancelar el documento?.") + End If End If Else sb.Append("No encontrado
") + sb.Append("Está seguro de cancelar el documento?.") End If - sb.Append("Está seguro de cancelar el documento?.") - LblCancelarDocumento.Text = sb.ToString() - MostrarCondicionesCancelacion() + MostrarCondicionesCancelacion(sbExtra.ToString()) RegistraScript("$('#ModalCancelarDocumento').modal();") UpCancelarDocumento.Update()