Commit inicial Ventas Productivo
This commit is contained in:
324
Bancos/RepComplementoPago.aspx.vb
Normal file
324
Bancos/RepComplementoPago.aspx.vb
Normal file
@@ -0,0 +1,324 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
|
||||
Partial Class Bancos_RepComplementoPago
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Sub Bancos_RepComplementoPago_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
txtFechaI.Text = $"{New DateTime(Now.Year, Now.Month, 1).ToString("dd/MM/yyyy")}"
|
||||
txtFechaF.Text = DateTime.Now.ToString("dd/MM/yyyy")
|
||||
DdlCliente.setEsWebService(True)
|
||||
|
||||
Dim objGral As New ClsGralFolios
|
||||
If objGral.GetFolios("CP", UsuarioActual.CveEmpresa) Then
|
||||
If objGral.DtResultados.Rows.Count > 0 Then
|
||||
BtnEmitir.Visible = True
|
||||
Else
|
||||
Alert("No se cuenta con folios para emitir complemento de pago", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
End If
|
||||
|
||||
CargaDatos()
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BtnEmitir_Click(sender As Object, e As EventArgs) Handles BtnEmitir.Click
|
||||
GeneraTimbre()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim CveCliente As Integer = If(DdlCliente.SelectedValue.ToEntero > 0, DdlCliente.SelectedValue.ToEntero, -1)
|
||||
Dim Banco As New ClsBancos
|
||||
If Banco.GetComplementoPagosRep(CveCliente, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime, -1, -1, DdlOpcion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Estatus:=DdlEstatus.SelectedValue.ToEntero) Then
|
||||
|
||||
GvD.DataSource = Banco.DtResultados '.FiltraParametros("CveComplementoPago is null")
|
||||
End If
|
||||
|
||||
Banco.Dispose()
|
||||
If DdlOpcion.SelectedValue = "2" Then GvD.Columns(8).Visible = True Else GvD.Columns(8).Visible = False
|
||||
|
||||
GvD.DataBind()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub GeneraTimbre()
|
||||
|
||||
Dim Str As New StringBuilder
|
||||
|
||||
|
||||
For Each gvr As GridViewRow In GvD.Rows
|
||||
If gvr.FCCheckBox("Chk").Checked Then
|
||||
Dim Banco As New ClsBancos
|
||||
Banco.IniciaTransacSQL()
|
||||
|
||||
|
||||
If Banco.GeneraTimbrePago(gvr.DataKey("CveIE").ToEntero, -1, UsuarioActual) Then
|
||||
If Banco.Mensaje = "" Then
|
||||
Banco.Commit()
|
||||
PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False)
|
||||
Str.AppendFormat("Folio: <b>{0}</b> ", Banco.ComplementoSerieFolio)
|
||||
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">XML <i class=""fa fa-file""></i></i></a> ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
|
||||
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">PDF <i class=""fa fa-ad-pdf""></i></i></i></a> ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
|
||||
Str.AppendFormat("<a style='color:#337ab7' target='_blank' href='./IE.aspx?CveIE={0}'>{1}</a> {2}<br>", gvr.DataKey("CveIE"), gvr.DataKey("Folio"), gvr.DataKey("NombreCliente"))
|
||||
MandaCorreo(Banco.ComplementoSerieFolio, gvr.DataKey("CobranzaCorreo"))
|
||||
End If
|
||||
|
||||
Else
|
||||
Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", gvr.DataKey("Folio"), Banco.Mensaje)
|
||||
Banco.RollBack()
|
||||
End If
|
||||
|
||||
|
||||
Banco.Dispose()
|
||||
End If
|
||||
Next
|
||||
CargaDatos()
|
||||
Alert(Str.ToString)
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
CargaDatos()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
|
||||
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveVenta") = "" Then
|
||||
If DdlEstatus.SelectedValue.ToEntero <> 2 Then
|
||||
e.Row.BackColor = Drawing.Color.LightGray
|
||||
End If
|
||||
If e.Row.DBCampo("CveIE") <> "" Then
|
||||
|
||||
If e.Row.DBCampo("CveComplementoPago") = "" Then
|
||||
e.Row.FCCheckBox("Chk").Visible = True
|
||||
|
||||
'VALIDACION DE FORMA DE PAGO
|
||||
Dim Mensaje As String = ValidaCuentaDePagoFormaDePago(e.Row.DBCampo("CveTipoTransaccion").ToEntero(), e.Row.DBCampo("ClaveFormaPagoSAT").ToEntero(), e.Row.DBCampo("CuentaBeneficiario").ToString(), e.Row.DBCampo("CuentaOrdenante").ToString())
|
||||
If Mensaje = "" Then
|
||||
If e.Row.DBCampo("SinFolioFiscal").ToEntero > 0 Then
|
||||
Mensaje = "El Pago contiene facturas que no tienen folio fiscal"
|
||||
End If
|
||||
End If
|
||||
e.Row.FCLiteral("LtlMon").Text = e.Row.DBCampo("PagoAbreviaturaSAT")
|
||||
|
||||
If Not Mensaje.Length = 0 Then
|
||||
e.Row.ForeColor = Drawing.Color.Red
|
||||
e.Row.FCCheckBox("Chk").Enabled = False
|
||||
e.Row.FCCheckBox("Chk").ToolTip = Mensaje
|
||||
End If
|
||||
|
||||
Else
|
||||
e.Row.FCHyperLink("HplXML").Visible = True : e.Row.FCHyperLink("HplXML").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CompP&EXT=xml&CveComplementoPago={0}&SerieFolio={1}&CveIE={2}", e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("SerieFolioPago").ToString.Replace("&", "%26%"), e.Row.DBCampo("CveIE").ToString)))
|
||||
e.Row.FCHyperLink("HplPDF").Visible = True : e.Row.FCHyperLink("HplPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CompP&EXT=pdf&CveComplementoPago={0}&SerieFolio={1}&CveIE={2}", e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("SerieFolioPago").ToString.Replace("&", "%26%"), e.Row.DBCampo("CveIE").ToString)))
|
||||
e.Row.FCLinkButton("LnkSendMail").Visible = True
|
||||
|
||||
If DdlOpcion.SelectedValue.ToEntero = 2 Then
|
||||
e.Row.FCLinkButton("LnkCancelarFolioFiscal").Visible = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
e.Row.Cells(1).Text = String.Format("{0} - {1}", e.Row.DBCampo("Banco"), e.Row.DBCampo("NumCuenta"))
|
||||
e.Row.FCLiteral("LtlFecha").Text = e.Row.DBCampo("FechaDocumento").ToDate.ToShortDateString
|
||||
e.Row.FCHyperLink("HplIE").Visible = True
|
||||
e.Row.FCLabel("LblImp").Text = e.Row.DBCampo("VentasTotalPagado").FormatoNumero
|
||||
|
||||
e.Row.FCLabel("LblImp").ToolTip = String.Format("Importe Pagado:{0} ", e.Row.DBCampo("Importe").FormatoNumero) ' VentasTotalPagado
|
||||
If e.Row.DBCampo("Importe").ToDecimal.RoundAD <> e.Row.DBCampo("VentasTotalPagado").ToDecimal.RoundAD Then
|
||||
e.Row.FCLabel("LblImp").ForeColor = Drawing.Color.Red
|
||||
e.Row.FCLabel("LblImp").ToolTip = String.Format("Importe Pagado:{0} Importe Pagado PUE: {1}, Ot. Ingresos {2}", e.Row.DBCampo("Importe").FormatoNumero, e.Row.DBCampo("PagadoPUE").FormatoNumero, e.Row.DBCampo("PagadoOtIngresos").FormatoNumero) ' VentasTotalPagado
|
||||
'si hay una diferencia generado por el tipo de cambio o alguna situación especial, detendrá el timbrado
|
||||
If Math.Abs(e.Row.DBCampo("Importe").ToDecimal - e.Row.DBCampo("VentasTotalPagado").ToDecimal) > 11 Then
|
||||
' si tiene pagado PUE, habilitamos la condición porque esa puede ser la diferencia
|
||||
If e.Row.DBCampo("PagadoPUE").ToDecimal > 0 OrElse e.Row.DBCampo("PagadoOtIngresos").ToDecimal > 0 Then
|
||||
e.Row.FCCheckBox("Chk").Visible = True
|
||||
Else
|
||||
e.Row.FCCheckBox("Chk").Visible = False
|
||||
End If
|
||||
|
||||
e.Row.FCCheckBox("Chk").ToolTip = "Hay una inconsistencia entre lo pagado en las facturas y el importe expedido"
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
e.Row.FCHyperLink("HplCliente").Text = ""
|
||||
e.Row.FCHyperLink("HplIE").Visible = True
|
||||
e.Row.FCHyperLink("HplIE").Text = e.Row.DBCampo("MetodoPago")
|
||||
e.Row.FCHyperLink("HplIE").NavigateUrl = ""
|
||||
e.Row.FCHyperLink("HplIE").CssClass = ""
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If e.Row.RowType = DataControlRowType.Header Then
|
||||
If DdlOpcion.SelectedValue = "1" Then
|
||||
e.Row.FCCheckBox("ChkHeader").Visible = True
|
||||
Else
|
||||
e.Row.FCCheckBox("ChkHeader").Visible = False
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnSendMail_Click(sender As Object, e As System.EventArgs) Handles BtnSendMail.Click
|
||||
|
||||
If HdnSerieFolioPago.Value <> "-1" Then
|
||||
MandaCorreo(HdnSerieFolioPago.Value, TxtParaMail.Text.Trim)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True)
|
||||
Try
|
||||
Dim Msg As String = ""
|
||||
If NombreArchivo <> "-1" Then '
|
||||
|
||||
Dim ObjMail As New ClsSisMail()
|
||||
Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo)
|
||||
Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo)
|
||||
|
||||
Dim Cuerpo As String = "Se hace entrega del comprobante de pago"
|
||||
Dim Asunto As String = "Entrega de comprobante de pago"
|
||||
|
||||
If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then
|
||||
|
||||
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
|
||||
|
||||
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF})
|
||||
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML})
|
||||
|
||||
If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then
|
||||
|
||||
If ConAlerta Then
|
||||
TxtCC.Text = ""
|
||||
RegistraScript("$('#ModalDivMail').modal('hide');")
|
||||
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
|
||||
Else
|
||||
Msg = "No se pudo enviar el correo electrónico."
|
||||
End If
|
||||
|
||||
Else
|
||||
Msg = "No se pudo adjuntar el correo electrónico."
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If ConAlerta AndAlso Msg <> "" Then
|
||||
Alert(Msg, TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió error al mandar MAIL", ex)
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Function ValidaCuentaDePagoFormaDePago(CveTipoTransaccion As Integer, ClaveFormaPagoSAT As Integer, CuentaBeneficiario As String, CuentaPago As String) As String
|
||||
Dim Mensaje As String = ""
|
||||
|
||||
If Not (CveTipoTransaccion > 0) Then
|
||||
Mensaje = "Tipo de Transaccion o Cuenta no definidas"
|
||||
End If
|
||||
|
||||
Select Case ClaveFormaPagoSAT.ToString
|
||||
Case "1"
|
||||
' no tiene restricciones
|
||||
Case "2"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(11, 18) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
|
||||
Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
|
||||
End If
|
||||
Case "3"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(10, 16, 18) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 18)) Then
|
||||
Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
|
||||
End If
|
||||
Case "4"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(16) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
|
||||
Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
Case "5"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(10, 11, 15, 16, 18, 50) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
|
||||
Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
|
||||
End If
|
||||
Case "6"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(10) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
CuentaBeneficiario = ""
|
||||
Case "28"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(16) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
|
||||
Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
|
||||
End If
|
||||
Case "29"
|
||||
If CuentaPago <> "" AndAlso Not CuentaPago.Length.Contiene(15, 16) Then
|
||||
Mensaje = "La cuenta ordenante no cumple con el formato esperado."
|
||||
End If
|
||||
|
||||
If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then
|
||||
Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado."
|
||||
End If
|
||||
Case Else
|
||||
Mensaje = "Forma de Pago no valida, no tiene una forma de pago SAT"
|
||||
End Select
|
||||
Return Mensaje
|
||||
End Function
|
||||
|
||||
Protected Sub LnkCancelaFolioFiscal(sender As Object, e As EventArgs)
|
||||
|
||||
Dim Gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim CveIE As Integer = Gvr.DataKey("CveIE").ToEntero
|
||||
Dim SerieFolioPago As String = Gvr.DataKey("SerieFolioPago").ToString
|
||||
Dim CFDIRelacionado As String = Gvr.DataKey("FolioFiscalComplemento").ToString
|
||||
|
||||
If CFDIRelacionado <> "" Then
|
||||
Dim objBancos As New ClsBancos
|
||||
|
||||
If objBancos.GeneraTimbrePago(CveIE, -1, UsuarioActual, -1, CFDIRelacionado, True) Then
|
||||
Alert($"Complemento {SerieFolioPago} cancelado correctamente.")
|
||||
Else
|
||||
Alert($"Se presento un error al cancelar el complementob {SerieFolioPago}.", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
objBancos.Dispose()
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkSendMail_Click(sender As Object, e As EventArgs)
|
||||
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
||||
HdnSerieFolioPago.Value = gvRow.DataKey("SerieFolioPago").ToString
|
||||
TxtParaMail.Text = gvRow.DataKey("CobranzaCorreo").ToString
|
||||
UpSendMail.Update()
|
||||
RegistraScript("$('#ModalDivMail').modal('show');")
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user