diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 960072f71..7863393bd 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -4831,7 +4831,8 @@
- + diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 7fdf99fc4..ee2823cb8 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -1,5 +1,6 @@ Option Explicit On Option Strict On +Imports System.Activities Imports System.Data Imports System.Diagnostics Imports System.Globalization @@ -1151,6 +1152,21 @@ Partial Class Compras_Compras End Property + Private Property UUIDSList As List(Of String) + Get + + If ViewState("UUIDSList") Is Nothing Then + Return New List(Of String) + Else + Return DirectCast(ViewState("UUIDSList"), List(Of String)) + End If + + End Get + Set(value As List(Of String)) + ViewState("UUIDSList") = value + End Set + End Property + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then 'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip") @@ -1273,21 +1289,7 @@ Partial Class Compras_Compras TxtOC.Attributes.Add("onkeypress", "fncBuscaOC(event);") - 'If UsuarioActual.Empresa.GralSoloProyecto Then - ' LitHProyecto.Text = "Sucursal" - ' DdlSubProyecto.Items.Clear() - - - ' DdlAsignaSubProyecto.Items.Clear() - - - ' divproyecto.Visible = False - ' divasignaproyecto.Visible = False - ' DdlProyecto.Visible = False - ' DdlProyecto.Items(0).Text = "" - - 'End If If UsuarioActual.CveEmpresa = 66 And UsuarioActual.TienePermisoProceso(96) Then ChkProgramarPago.Visible = True @@ -1374,20 +1376,7 @@ Partial Class Compras_Compras CambiaEjercicioAC() End If - ' ''Fecha limite para ingreso de facturas - ''Dim DtEmpresa As DataTable = GlobalDTEmpresas(UsuarioActual.CveEmpresa) - ''If DtEmpresa.Rows.Count > 0 Then - '' Dim FechaLimite = DateSerial(DtEmpresa.Rows(0)("EjercicioActual").ToString.ToEntero, DtEmpresa.Rows(0)("PeriodoActual").ToString.ToEntero, DtEmpresa.Rows(0)("DiasPermitidos").ToString.ToEntero) - '' If Month(TxtFecha.Text.ToDate) < (Month(FechaLimite) - 1) Or (Month(TxtFecha.Text.ToDate) = (Month(FechaLimite) - 1) And Day(Date.Now) > Day(FechaLimite)) Then - '' Alert("La factura actual ya no aplica para ingresarse al sístema.", TipoMensaje.MsgAdvertencia) - '' BtnGuardar.Enabled = False - '' Else - '' Alert("En tiempo") - '' End If - ''Else - '' Alert("No se pudieron cargar los datos de la empresa", TipoMensaje.MsgAdvertencia) - ''End If - 'Carga Compra + If UsuarioActual.Empresa.Funcionalidad(123) <> "" And Not UsuarioActual.TienePermisoProceso(156) Then If Not ValidaCierrePeriodo() Then @@ -1600,6 +1589,11 @@ Partial Class Compras_Compras End If + + If DdlTipoComprobante.SelectedValue = "NC" Then + NCSeleccionFacturasRelacionadas(UUIDSList) + End If + End If 'SE OCUPAN AFUERA DEL POSTBACK ?? @@ -9685,6 +9679,28 @@ Partial Class Compras_Compras namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + If _TipoComprobante.ToUpper = "E" And (Version = "3.3" Or Version = "4.0") Then + Dim UUIDS As String = "" + + Dim UUIDSLista As New List(Of String) + Dim nodeCFDIRelacionados As XmlNode + nodeCFDIRelacionados = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + + If nodeCFDIRelacionados IsNot Nothing Then + + For Each CFDIRelacionados As XmlNode In nodeCFDIRelacionados + UUIDSLista.Add("" & CFDIRelacionados.Attributes("UUID").Value.ToString & "") + Next + + End If + + UUIDSList = UUIDSLista + + End If + + + Dim node As XmlNode node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces) @@ -16300,7 +16316,7 @@ Partial Class Compras_Compras Dim NumNoDed As Integer = TmpDT.COUNT("CvePS", "NoDeducible = True ") If NumNoDed > 0 Then GvPS.Columns(11).Visible = True 'visualiza columnas de nodeducibles - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") And CveFactura <= 0 Then InicializaAplicaNCFact() End If @@ -20066,11 +20082,121 @@ Partial Class Compras_Compras End Function + Private Sub NCSeleccionFacturasRelacionadas(UUIDSListRelacioandos As List(Of String)) + + + If UUIDSListRelacioandos.Count > 0 Then + Dim SaldoNota As Decimal = TxtTotal.Text.ToDecimal + Dim SaldoNotaPorAplicar As Decimal = SaldoNota + Dim CountAplicacion As Integer = 0 + + Dim sbNoencontrados As New StringBuilder + + + For Each UUID As String In UUIDSListRelacioandos + + UUID = UUID.ToUpper + Dim UUIDEncontrado As Boolean = False + + For Each GvRow As GridViewRow In GvFacturaNC.Rows + Dim UUIDGv As String = GvRow.DataKey("UUID").Trim.ToUpper + + + If UUID.Trim.ToUpper = GvRow.DataKey("UUID").Trim.ToUpper Then + UUIDEncontrado = True + Exit For + End If + + Next + + If Not UUIDEncontrado Then + sbNoencontrados.Append($"{UUID},") + End If + + Next + + Dim TeminarAmortizacion As Boolean = False + + For Each UUID As String In UUIDSListRelacioandos + + For Each GvRow As GridViewRow In GvFacturaNC.Rows + + If UUID.Trim.ToUpper = GvRow.DataKey("UUID").Trim.ToUpper Then + + Dim SaldoFactura As Decimal = GvRow.DataKey("Saldo").ToDecimal + + If SaldoFactura <= SaldoNotaPorAplicar Then + SaldoNotaPorAplicar = SaldoNotaPorAplicar - SaldoFactura + GvRow.FCTextBox("TxtImporte").Text = SaldoFactura.ToString("###,###,###.00") + GvRow.FCCheckBox("ChkFacturaNC").Checked = True + Else + + If SaldoFactura >= SaldoNotaPorAplicar Then + + GvRow.FCTextBox("TxtImporte").Text = SaldoNotaPorAplicar.ToString("###,###,###.00") + GvRow.FCCheckBox("ChkFacturaNC").Checked = True + SaldoNotaPorAplicar = 0 + TeminarAmortizacion = True + + Else + GvRow.FCTextBox("TxtImporte").Text = SaldoFactura.ToString("###,###,###.00") + GvRow.FCCheckBox("ChkFacturaNC").Checked = True + SaldoNotaPorAplicar = SaldoNotaPorAplicar - SaldoFactura + + TeminarAmortizacion = True + End If + End If + CountAplicacion = CountAplicacion + 1 + Exit For + End If + + + If SaldoNotaPorAplicar <= 0 Then + TeminarAmortizacion = True + Exit For + End If + + Next + + + If TeminarAmortizacion Then + Exit For + End If + + Next + + + Dim TipoMesaje As TipoMensaje = TipoMensaje.ToastInformacion + + TipoMesaje = If(sbNoencontrados.ToString.Length > 0 Or (SaldoNotaPorAplicar <> 0), TipoMensaje.ToastAdventencia, TipoMesaje) + + + Dim MsgSalida As String = "" + If sbNoencontrados.ToString.Length > 0 Then + MsgSalida = $"UUIDS no encotradas o sin saldo: {sbNoencontrados.ToString()}
" + End If + + MsgSalida = $"{MsgSalida}Se seleccionó {(SaldoNota - SaldoNotaPorAplicar).ToString("###,###,###.00")} de {SaldoNota.ToString("###,###,###.00")} a {CountAplicacion} factura{If(CountAplicacion > 0, "s", "")}." + + Alert(MsgSalida, TipoMesaje) + + If CountAplicacion > 0 Then + BtnFacturaNC_Click(Nothing, Nothing) + End If + + End If + + + + End Sub + + End Class + Public Class MMensajeDevolucion Public Property CveMovimiento As Integer Public Property TieneError As Boolean diff --git a/Contabilidad2/RepAnexoCatalogoCC.aspx b/Contabilidad2/RepAnexoCatalogoCC.aspx index d9df7060d..2aab78ff9 100644 --- a/Contabilidad2/RepAnexoCatalogoCC.aspx +++ b/Contabilidad2/RepAnexoCatalogoCC.aspx @@ -17,7 +17,7 @@ - Anexo de Catálogo - Centro Costo + Anexo de Catálogo - Centro Costo @@ -52,7 +52,7 @@