eFacturas Traslados

This commit is contained in:
rakcsle
2021-11-25 19:21:53 -07:00
parent ad936fd6ee
commit 6dffe35ee2
5 changed files with 513 additions and 16 deletions

View File

@@ -668,6 +668,20 @@ Partial Class Compras_eFacturas
End Property
Private Property CveFacturaComplementoTraslado As Integer
Get
If ViewState("CveFacturaComplementoTraslado") Is Nothing Then
Return -1
Else
Return ViewState("CveFacturaComplementoTraslado").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveFacturaComplementoTraslado") = value
End Set
End Property
Private Property ComprasEnComplemento As Integer
Get
@@ -682,6 +696,19 @@ Partial Class Compras_eFacturas
End Set
End Property
Private Property SeVinculoConComprasFaltantes As Boolean
Get
If ViewState("SeVinculoConComprasFaltantes") Is Nothing Then
Return False
Else
Return Boolean.Parse(ViewState("SeVinculoConComprasFaltantes").ToString)
End If
End Get
Set(value As Boolean)
ViewState("SeVinculoConComprasFaltantes") = value
End Set
End Property
#End Region
@@ -763,37 +790,55 @@ Partial Class Compras_eFacturas
txtFechaI.Text = MinFecha.ToString
txtFechaF.Text = Now.ToShortDateString
End If
Dim DtPagos As DataTable = Nothing
Dim DTTrasaldos As DataTable = Nothing
Dim ObjDatos As New ClsCompras
If ObjDatos.GetFacturas(-1, Folio, FechaI, FechaF, RFC, Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlTipoComprobante.SelectedValue.ToString, UsuarioActual.CveEmpresa) Then
If ObjDatos.DtResultados.Rows.Count > 0 Then
GvD.DataSource = ObjDatos.DtResultados.FiltraParametros("TipoComprobante <> 'P'") '.AsEnumerable().Take(100).CopyToDataTable()
GvD.DataSource = ObjDatos.DtResultados.FiltraParametros("TipoComprobante <> 'P' and TipoComprobante <> 'T' ") '.AsEnumerable().Take(100).CopyToDataTable()
DtPagos = ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'P'")
'Else
' GvD.DataSource = Nothing
End If
End If
If ObjDatos.GetFacturas(-1, Folio, FechaI, FechaF, RFC, Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlTipoComprobante.SelectedValue.ToString, UsuarioActual.CveEmpresa, Opcion:=2) Then
If ObjDatos.DtResultados.Rows.Count > 0 Then
LblRegistros.Text = String.Format("{0} Registros", ObjDatos.DtResultados.FiltraParametros("TipoComprobante <> 'P'").Rows.Count.ToString("N0"))
DTTrasaldos = ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'T'")
End If
End If
LblRegistros.Text = String.Format("{0} Registros", ObjDatos.DtResultados.FiltraParametros("TipoComprobante <> 'P' and TipoComprobante <> 'T' ").Rows.Count.ToString("N0"))
LblTotalPagos.Text = String.Format("{0} Pagos", ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'P'").Rows.Count.ToString("N0"))
LblTotalTraslados.Text = String.Format("{0} Traslados", ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'T'").Rows.Count.ToString("N0"))
If DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
GvPagos.DataSource = DtPagos
End If
If DTTrasaldos IsNot Nothing AndAlso DTTrasaldos.Rows.Count > 0 Then
GvTraslados.DataSource = DTTrasaldos
End If
ObjDatos.Dispose()
GvPagos.DataBind()
UpPagos.Update()
GvD.DataBind()
GvPagos.DataBind()
GvTraslados.DataBind()
UpPagos.Update()
UpDatos.Update()
UpTraslados.Update()
UPRegistros.Update()
End Sub
Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
@@ -2746,7 +2791,7 @@ Partial Class Compras_eFacturas
#Region "V I N C U L A R P A G O"
Protected Sub LnkAgregarPago_Click(sender As Object, e As EventArgs)
SeVinculoConComprasFaltantes = False
Dim sbSinIE As New StringBuilder
Dim TieneCompras As Boolean = False
@@ -3149,17 +3194,40 @@ Partial Class Compras_eFacturas
End If
BtnVincularPago.Attributes.Add("data-toggle", "")
BtnVincularPago.Attributes.Add("data-popout", "")
BtnVincularPago.Attributes.Add("data-original-title", "")
BtnVincularPago.Attributes.Add("data-btn-ok-label", "")
If UsuarioActual.TienePermisoProceso(332) And (BtnVincularPago.Visible = False Or BtnVincularPago.Enabled = False) Then
Dim FaltanCompras As Boolean = False
For Each GvRowVal As GridViewRow In GVPDocumentosRelacionadosPagos.Rows
If GvRowVal.DataKey("CveIE").ToEntero > 0 Then
BtnVincularPago.Enabled = True
BtnVincularPago.Visible = True
If GvRowVal.DataKey("CveCompra").ToEntero > 0 Then
FaltanCompras = True
Exit For
End If
Next
If FaltanCompras Then
For Each GvRowVal As GridViewRow In GVPDocumentosRelacionadosPagos.Rows
If GvRowVal.DataKey("CveIE").ToEntero > 0 Then
BtnVincularPago.Enabled = True
BtnVincularPago.Visible = True
BtnVincularPago.Attributes.Add("data-toggle", "confirmation")
BtnVincularPago.Attributes.Add("data-popout", "true")
BtnVincularPago.Attributes.Add("data-original-title", "Se realizará la vinculación sin tener compras previamente registradas")
BtnVincularPago.Attributes.Add("data-btn-ok-label", "Si")
SeVinculoConComprasFaltantes = True
Exit For
End If
Next
End If
End If
@@ -3171,6 +3239,8 @@ Partial Class Compras_eFacturas
Private Sub BtnVincularPago_Click(sender As Object, e As EventArgs) Handles BtnVincularPago.Click
'VERIFICA QUE HALLA UN PAGO
'Dim Contador = 0
'For Each Gv As GridViewRow In GvVincularPago.Rows
@@ -4185,4 +4255,184 @@ Partial Class Compras_eFacturas
End Sub
#Region "TRASLADOS"
Protected Sub GvTraslados_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvTraslados.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("TipoComprobante") = "T" Then
e.Row.FCLabel("LtTipoComprobante").Text = "Traslado"
e.Row.FCLabel("LtTipoComprobante").CssClass = "label label-sm label-primary"
e.Row.FCLabel("LtTipoComprobante").Attributes.Add("data-toggle", "tooltip")
e.Row.FCLabel("LtTipoComprobante").Attributes.Add("title", "Traslado")
End If
e.Row.Cells(2).Attributes.Add("data-order", e.Row.DBCampo("FechaFactura").ToDate.Ticks.ToString)
Dim RutaXML As String = String.Format("{0}{1}\{2}", Destino, e.Row.DBCampo("RFCDe"), e.Row.DBCampo("XML"))
If File.Exists(String.Format("{0}{1}\{2}", Destino, e.Row.DBCampo("RFCDe"), e.Row.DBCampo("XML"))) Then
e.Row.FCLiteral("LtlXML").Text = String.Format("<a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?RFC={0}&File={1}"">Ver</a>", HttpUtility.UrlEncode(e.Row.DBCampo("RFCDe")), HttpUtility.UrlEncode(e.Row.DBCampo("XML")))
If e.Row.DBCampo("TipoComprobante") = "T" And e.Row.DBCampo("FueValidado") = "1" Then
e.Row.FCLinkButton("LnkAgregarTraslado").Visible = True
End If
Else
e.Row.FCLiteral("LtlXML").Text = "N/D" ' String.Format("{0}{1}\{2}", Destino, e.Row.DBCampo("RFCDe"), e.Row.DBCampo("XML")) '
If e.Row.DBCampo("TipoComprobante") = "T" Then
e.Row.FCLinkButton("LnkAgregarTraslado").Visible = False
End If
End If
If File.Exists(String.Format("{0}{1}/{2}", Destino, e.Row.DBCampo("RFCDe"), e.Row.DBCampo("PDF"))) Then
e.Row.FCLiteral("LtlPDF").Text = String.Format("<a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?RFC={0}&File={1}"">Ver</a>", HttpUtility.UrlEncode(e.Row.DBCampo("RFCDe")), HttpUtility.UrlEncode(e.Row.DBCampo("PDF")))
Else
e.Row.FCLiteral("LtlPDF").Text = "N/D" ' String.Format("{0}{1}/{2}", Destino, e.Row.DBCampo("RFCDe"), e.Row.DBCampo("PDF"))
End If
If e.Row.DBCampo("FueValidado").Contiene("1", "2", "3") Then
e.Row.FCLinkButton("ImgValidarCFDi").Visible = False
e.Row.FCLiteral("LtlValidado").Visible = True
If e.Row.DBCampo("FueValidado") = "2" Then
e.Row.FCLiteral("LtlValidado").Text = "Cancelada"
e.Row.ForeColor = Drawing.Color.Red
e.Row.FCHyperLink("HplProveedor").ForeColor = Drawing.Color.Red
ElseIf e.Row.DBCampo("FueValidado") = "3" Then
e.Row.FCLiteral("LtlValidado").Text = "Omitida"
e.Row.ForeColor = Drawing.Color.Gray
e.Row.FCHyperLink("HplProveedor").ForeColor = Drawing.Color.Gray
End If
Else
If e.Row.DBCampo("TipoFactura") = "CFD" Then
e.Row.FCLinkButton("ImgValidarCFDi").CommandName = "ValidarCFD"
e.Row.FCLinkButton("ImgValidarCFDi").OnClientClick = "return confirm('La factura se validó en el sitio del SAT de comprobantes fiscales?');"
End If
e.Row.FCLinkButton("ImgValidarCFDi").Visible = True
e.Row.FCLiteral("LtlValidado").Visible = False
End If
If e.Row.DBCampo("CveCompra") <> "" Then
e.Row.FCLiteral("LtlFolio").Text = String.Format("<a class=""Texto"" style=""cursor:pointer;text-decoration: underline;"" href='/Compras/Compras.aspx?CveCompra={0}' target='_blank' rel='opener');"">{1}</a>", e.Row.DBCampo("CveCompra"), e.Row.DBCampo("SerieFolio")) '1\Compras\GAPC480413QL3\A-69.xml
End If
If e.Row.DBCampo("CveProveedor") = "" Then
e.Row.FCHyperLink("HplProv").Visible = True
e.Row.FCHyperLink("HplProv").NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveFactura={0}", e.Row.DBCampo("CveFactura"))
Else
e.Row.FCHyperLink("HplProveedor").NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", e.Row.DBCampo("CveProveedor"))
If e.Row.DBCampo("CveCompra") = "" AndAlso (e.Row.DBCampo("FueValidado") = "1") Then
e.Row.FCHyperLink("HplAgregarT").Visible = False
Else
e.Row.FCHyperLink("HplAgregarT").Visible = False
End If
End If
Dim CveComplementoTraslado As Integer = e.Row.DataKey("CveComplementoTraslado").ToString.ToEntero
If CveComplementoTraslado > 0 Then
e.Row.FCLinkButton("LnkAgregarTraslado").CssClass = "btn btn-sm green"
e.Row.FCLinkButton("LnkAgregarTraslado").Text = "<i class='fa fa-info' ></i>"
e.Row.FCLinkButton("LnkAgregarTraslado").Attributes.Add("Title", "Ver vinculación")
Else
e.Row.FCLinkButton("LnkAgregarTraslado").CssClass = "btn btn-sm blue"
e.Row.FCLinkButton("LnkAgregarTraslado").Text = "<i class='fa fa-check'></i>"
e.Row.FCLinkButton("LnkAgregarTraslado").Attributes.Add("Title", "Vincular Traslado")
End If
End If
End Sub
Protected Sub LnkAgregarTraslado_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
Dim CveComplementoTraslado As Integer = gvRow.DataKey("CveComplementoTraslado").ToEntero
CveFacturaComplementoTraslado = gvRow.DataKey("CveFactura").ToEntero
Dim SerieFolioTraslado As String = gvRow.DataKey("SerieFolio").ToString
LnkVincularTraslado.Visible = False
If CveComplementoTraslado > 0 Then
DvMomdalVincualarTrasladoBusqueda.Visible = False
DvModalVincularTrasladoVinculado.Visible = True
LtlModalVincularTrasaldoTitulo.Text = "Traslado Vinculado"
LnkModalModalVincularTrasaldoFolio.Text = gvRow.DataKey("SerieFolioVinculado")
LnkModalModalVincularTrasaldoFolio.NavigateUrl = $"~/Compras/Compras.aspx?CveCompra={gvRow.DataKey("CveCompraTraslado")}"
Else
DvMomdalVincualarTrasladoBusqueda.Visible = True
DvModalVincularTrasladoVinculado.Visible = False
LtlModalVincularTrasaldoTitulo.Text = "Vincular Traslado"
End If
UpModalVincularTraslado.Update()
RegistraScript("$('#DvModalVincularTrasaldo').modal('show');")
End Sub
Protected Sub BtnCargaCompraComplementoTraslado_Click(sender As Object, e As EventArgs)
If HdnCveCompraComplementoTraslado.Value.ToString.ToEntero > 0 Then
LnkVincularTraslado.Visible = True
LnkModalModalVincularTrasaldoFolio.Text = HdnFolioCompraComplementoTraslado.Value.ToString
LnkModalModalVincularTrasaldoFolio.NavigateUrl = $"~/Compras/Compras.aspx?CveCompra={HdnCveCompraComplementoTraslado.Value.ToString}"
DvModalVincularTrasladoVinculado.Visible = True
Else
LnkVincularTraslado.Visible = False
LnkModalModalVincularTrasaldoFolio.Text = ""
LnkModalModalVincularTrasaldoFolio.NavigateUrl = ""
DvModalVincularTrasladoVinculado.Visible = False
LnkVincularTraslado.Visible = False
End If
UpModalVincularTraslado.Update()
End Sub
Protected Sub LnkVincularTraslado_Click(sender As Object, e As EventArgs)
Dim ProcesoOk As Boolean = False
If HdnCveCompraComplementoTraslado.Value.ToString.ToEntero > 0 Then
Dim objCompras As New ClsCompras
If objCompras.AddComplementoTraslado(CveFacturaComplementoTraslado, HdnCveCompraComplementoTraslado.Value.ToString.ToEntero, UsuarioActual.CveUsuario) Then
ProcesoOk = True
End If
objCompras.Dispose()
End If
If ProcesoOk Then
RegistraScript("$('#DvModalVincularTrasaldo').modal('hide');")
CargaDatos()
Alert("Traslado Vinculado correctamente.")
End If
End Sub
#End Region
End Class