diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index d5c7b5237..25fb3c073 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -2677,6 +2677,45 @@ Public Class ClsVentas 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 + + Dim objServicio As Cancelacion.CancelacionSoapClient = New Cancelacion.CancelacionSoapClient() + Dim resp As Cancelacion.StructCancel = objServicio.ObtienePendientes(RFC, "UserTest", "1234567890") + If resp.Estado = 0 Then + Dim XmlPendientes As String = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml)) + Dim theReader As IO.StringReader = New IO.StringReader(XmlPendientes) + Dim theDataSet As DataSet = New DataSet() + theDataSet.ReadXml(theReader) + + If theDataSet.Tables(0).Rows(0)("Uuid").ToString() <> "null" Then + Dim sb = New StringBuilder() + + For Each item As DataRow In theDataSet.Tables(0).Rows + sb.AppendFormat("{0};", item("Uuid").ToString()) + Next + + If GetFacturasCanceladasPendientes(sb.ToString(), CveEmpresa) Then + retorno = True + End If + + Else + If showalert Then + Alert("No se encontraron cancelaciones pendientes", ModExtensiones.TipoMensaje.MsgError) + End If + End If + Else + Alert("Error al obtener cancelaciones pendientes: " & resp.Descripcion, ModExtensiones.TipoMensaje.MsgError) + End If + + Catch ex As Exception + retorno = False + Me.OnError("Error al obtener cancelaciones pendientes: ", ex, "") + End Try + 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/Modelos.vb b/App_Code/Modelos.vb index fea43d93f..6df87817e 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -368,7 +368,7 @@ Namespace Modelos End If Timbre = New CFDITimbre End Sub - Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "") + Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "", Optional EsCancelacion As Boolean = False) Me.UsuarioActual = UsuarioActual Me.CveVenta = CveVenta Me.CveEmpresa = CveEmpresa @@ -393,7 +393,7 @@ Namespace Modelos Me.DtDetalle = ObjVentas.DtResultados.Copy() End If ObjVentas.Dispose() - IniciaValoresVentas() + IniciaValoresVentas(EsCancelacion) If String.IsNullOrEmpty(DirectorioServidor) Then DirectorioServidor = HttpContext.Current.Server.MapPath("/") End If @@ -446,7 +446,7 @@ Namespace Modelos Me.IEPS = 0 Me.CveAlmacenTraspasoOrigen = 0 End Sub - Private Sub IniciaValoresVentas() + Private Sub IniciaValoresVentas(Optional EsCancelacion As Boolean = False) If CveVenta > 0 AndAlso CveEmpresa > 0 Then Me.DtAnticipos = New DataTable() Me.DtAntNCVinculadas = New DataTable() @@ -492,6 +492,10 @@ Namespace Modelos Me.DtNCVinculadas = ObjVentas.DtResultados.Copy() End If + If TipoDocto.Contiene("Ant") AndAlso EsCancelacion Then + EsNCAmortizacion = True + End If + If ObjVentas.GetVentasAntNC(-1, CveVenta, AplicaAmortizacion:=EsNCAmortizacion) Then Me.DtAnticipos = ObjVentas.DtResultados.Copy() End If @@ -2333,7 +2337,7 @@ Namespace Modelos Exit Select End If - If ObjFactura.TipoDocto.Contiene("Ing", "Egs") AndAlso ValorMultiplicador = -1 Then + If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant") AndAlso ValorMultiplicador = -1 Then For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows If row2("CveConceptoContable").ToString().ToEntero = 11 Then importeMovimiento = row2("Importe").ToString().ToDecimal * ValorMultiplicador '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal) @@ -2344,7 +2348,10 @@ Namespace Modelos CveSubProyectoContabilizar = CveSubProyectoVenta If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=row2("CveVenta").ToString().ToEntero, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, + CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=row2("CveVenta").ToString().ToEntero, CveCliente:=ObjFactura.CveCliente, + CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, + CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then ErrorPrepoliza = True Exit For Else diff --git a/Inicio.aspx b/Inicio.aspx index 390a8591e..3fb0bbc90 100644 --- a/Inicio.aspx +++ b/Inicio.aspx @@ -605,62 +605,62 @@