--- selección multiple de devolución

This commit is contained in:
2025-01-20 09:07:41 -07:00
parent 3396f67ff7
commit c678d0e061
2 changed files with 403 additions and 140 deletions

View File

@@ -101,6 +101,19 @@ Partial Class Clientes
End Set
End Property
Property ModalidadSelecionDevAnticipos As Boolean
Get
If ViewState("ModalidadSelecionDevAnticipos") Is Nothing Then
Return False
Else
Return CBool(ViewState("ModalidadSelecionDevAnticipos").ToString())
End If
End Get
Set(value As Boolean)
ViewState("ModalidadSelecionDevAnticipos") = value
End Set
End Property
Private Property Existe As Boolean
Get
Return Convert.ToBoolean(ViewState("Existe"))
@@ -3005,11 +3018,8 @@ Partial Class Clientes
If e.Row.DataKey("ISTotal") = "1" Then
e.Row.FCLiteral("LtlFecha").Text = String.Format("Total {0} ", e.Row.DataKey("Tipo"))
e.Row.BackColor = Drawing.Color.LightGray
End If
'If e.Row.DataKey("Saldo").ToDouble < 0 Then e.Row.Cells(2).ForeColor = Drawing.Color.Red
'If e.Row.DataKey("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAnticipos"), Literal).Text = ""
End If
If e.Row.RowIndex > -1 Then
If e.Row.DBCampo("Folio") = "N/D" Then
e.Row.FCLiteral("LtlFactura").Text = e.Row.DataKey("Folio")
@@ -3023,118 +3033,31 @@ Partial Class Clientes
End If
If UsuarioActual.TienePermisoProceso(247) Then
If CType(sender, GridView).ID = "GVAnticipos" And e.Row.DBCampo("CveVenta").ToEntero() > 0 And e.Row.DBCampo("Tipo") = "NC" Then
Dim Parametros As String = Encripta($"CveVenta={e.Row.DBCampo("CveVenta").ToEntero()}&SerieFolio={e.Row.DBCampo("Folio")}&CveMoneda={e.Row.DBCampo("CveMoneda")}&CveCliente={CveCliente}&Saldo={e.Row.DBCampo("Saldo")}&Original={e.Row.DBCampo("Original")}&CvePrePoliza={e.Row.DBCampo("CvePrePoliza")}")
e.Row.FCHyperLink("HLDevolverDinero").Visible = True
e.Row.FCHyperLink("HLDevolverDinero").NavigateUrl = $"/Bancos/IE.aspx?Opcion=DevDinV&P={Parametros}"
If CType(sender, GridView).ID = "GVAnticipos" Then ' And e.Row.DBCampo("CveVenta").ToEntero() > 0 And e.Row.DBCampo("Tipo") = "NC" Then
If (e.Row.DBCampo("CveVenta").ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo").Contiene("Ant", "NC", "Dev")) OrElse (e.Row.DBCampo("CveIE").ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo") = "IxC") Then
If ModalidadSelecionDevAnticipos Then
e.Row.FCCheckBox("chkDevolver").Visible = True
e.Row.FCCheckBox("chkDevolver").InputAttributes.Add("data-saldo", e.Row.DataKey("Saldo"))
End If
If e.Row.DBCampo("CveVenta").ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo") = "NC" Then
Dim Parametros As String = Encripta($"CveVenta={e.Row.DBCampo("CveVenta").ToEntero()}&SerieFolio={e.Row.DBCampo("Folio")}&CveMoneda={e.Row.DBCampo("CveMoneda")}&CveCliente={CveCliente}&Saldo={e.Row.DBCampo("Saldo")}&Original={e.Row.DBCampo("Original")}&CvePrePoliza={e.Row.DBCampo("CvePrePoliza")}")
e.Row.FCHyperLink("HLDevolverDinero").Visible = True
e.Row.FCHyperLink("HLDevolverDinero").NavigateUrl = $"/Bancos/IE.aspx?Opcion=DevDinV&P={Parametros}"
End If
End If
End If
End If
If UsuarioActual.Empresa.Funcionalidad(185) = "1" AndAlso UsuarioActual.TienePermisoProceso(379) AndAlso CType(sender, GridView).ID = "GVAnticipos" Then
If e.Row.DBCampo("CveVenta").ToString().ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant") Then
If Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then
e.Row.FCLinkButton("LnkAutorizar").Visible = True
e.Row.FCLinkButton("LnkCancelar").Visible = False
Else
e.Row.FCLinkButton("LnkAutorizar").Visible = False
e.Row.FCLinkButton("LnkCancelar").Visible = True
End If
End If
If e.Row.DBCampo("CveIE").ToString().ToEntero() > 0 AndAlso e.Row.DBCampo("Tipo").ToString().Contiene("IxC") Then
If Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then
e.Row.FCLinkButton("LnkAutorizar").Visible = True
e.Row.FCLinkButton("LnkCancelar").Visible = False
Else
e.Row.FCLinkButton("LnkAutorizar").Visible = False
e.Row.FCLinkButton("LnkCancelar").Visible = True
End If
End If
End If
End If
End Sub
#End Region
#Region "R H"
Private Sub CargaPersonalAsignado()
Dim ObjPersonal As New ClsRH
If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, CveCliente, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
GVPersonal.DataSource = ObjPersonal.DtResultados
Else
GVPersonal.DataSource = Nothing
End If
ObjPersonal.Dispose()
GVPersonal.DataBind()
End Sub
Protected Sub GVPersonal_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVPersonal.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).Width = Unit.Pixel(70)
e.Row.Cells(1).Width = Unit.Pixel(300)
e.Row.Cells(2).Width = Unit.Pixel(80)
e.Row.Cells(3).Width = Unit.Pixel(80)
e.Row.Cells(4).Width = Unit.Pixel(120)
e.Row.Cells(5).Width = Unit.Pixel(120)
e.Row.Cells(6).Width = Unit.Pixel(60)
End If
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left
Dim Liga As String = "<a class=""Texto"" href=""/RH/Personal.aspx?CvePersonal=" & e.Row.DBCampo("CvePersonal") & """>"
e.Row.FCLiteral("LtlCodigo").Text = Liga & e.Row.FCLiteral("LtlCodigo").Text & "</a>"
e.Row.FCLiteral("LtlPersonal").Text = Liga & e.Row.FCLiteral("LtlPersonal").Text & "</a>"
End If
End Sub
Protected Sub BtnConsultarAsistencia_Click(sender As Object, e As System.EventArgs) Handles BtnConsultarAsistencia.Click
Dim objpersonal As New ClsRH
If objpersonal.GetAsistencias(-1, CveCliente, -1, -1, -1, 1, -1, txtFechaI.Text.Trim.ToDate(), txtFechaF.Text.Trim.ToDate(), UsuarioActual.CveEmpresa) Then
GVAsistencia.DataSource = objpersonal.DtResultados.FiltraParametros("Fecha IS NOT NULL")
Else
GVAsistencia.DataSource = Nothing
End If
objpersonal.Dispose()
GVAsistencia.DataBind()
UpDatos.Update()
End Sub
Protected Sub GVAsistencia_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAsistencia.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).Width = Unit.Pixel(75)
e.Row.Cells(1).Width = Unit.Pixel(145)
e.Row.Cells(2).Width = Unit.Pixel(70)
e.Row.Cells(3).Width = Unit.Pixel(100)
e.Row.Cells(4).Width = Unit.Pixel(100)
e.Row.Cells(5).Width = Unit.Pixel(145)
e.Row.Cells(6).Width = Unit.Pixel(220)
End If
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Left
If IsDate(e.Row.DBCampo("Fecha")) Then e.Row.FCLiteral("LtlFecha").Text = e.Row.DBCampo("Fecha").ToDate().ToShortDateString()
If e.Row.DBCampo("SeModifico") = "0" Then
e.Row.BackColor = Drawing.Color.LightBlue
ElseIf e.Row.DBCampo("SeModifico") = "1" Then
e.Row.ForeColor = Drawing.Color.Red
End If
End If
End Sub
#End Region
#Region "S U C U R S A L E S"
Private Sub LbAgregarSucursal_Click(sender As Object, e As EventArgs) Handles LbAgregarSucursal.Click
@@ -10829,6 +10752,226 @@ Partial Class Clientes
' End If
'End Sub
#Region "D E V O L U C I O N D E D I N E R O "
Protected Sub LnkDevolucionMasiva_Click(sender As Object, e As EventArgs)
TxtFechaDocumento.Text = Now.ToShortDateString
ModalidadSelecionDevAnticipos = True
divDevolverAnticipos.Visible = True
DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlCuenta.DataBind()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs' AND Estatus = 1 ")
DdlTipoTransaccion.DataBind()
TxtImporteDev.Attributes.Add(“readonly”, “readonly”)
TxtImporteDev.Text = ""
TxtDevRedondeo.Text = ""
DdlCuentaDeposito.DataSource = GlobalDTCuentasDepositosClientes(UsuarioActual.CveEmpresa, CveCliente:=CveCliente)
DdlCuentaDeposito.DataBind()
'Dim Dep As New ClsGenerales
'If Dep.GetCuentasDepositos(CveCliente:=CveCliente, CveEmpresa:=UsuarioActual.CveEmpresa) Then
' DdlCuentaDeposito.DataSource = Dep.DtResultados
'End If
'Dep.Dispose()
DdlCuentaDeposito.Items.Insert(Opcion, New ListItem("-", "-1"))
CargaAnticipos()
End Sub
Protected Sub LnkDevolucionCerrar_Click(sender As Object, e As EventArgs)
ModalidadSelecionDevAnticipos = False
divDevolverAnticipos.Visible = False
CargaAnticipos()
End Sub
Protected Sub LnkAplicaDevolucion_Click(sender As Object, e As EventArgs)
If TxtImporteDev.Text.ToDecimal <= 0 Then
Alert("No se tiene importe a devolver.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim CveIE, CvePrePoliza As Integer
Dim tCveMoneda As Integer = 1
Dim tTipoCambio As Decimal = 1
Dim PagueseA As String = TxtNombre.Text
Dim MsgError As String = ""
Dim tImporteDev As Decimal = TxtImporteDev.Text.ToDecimal
Dim tCveCorte As Integer = -1
Dim tFolio As String = "1"
Dim tObs As String = TxtDevObs.Text.Trim
tCveMoneda = GlobalDTBancosCuentasGral(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CveMoneda", $"CveCuenta={DdlCuenta.SelectedValue}").ToEntero
CvePrePoliza = ObjMov.AddPrePolizas("Clientes/IE/DEV ", 1, tImporteDev, tImporteDev, tCveMoneda, TxtFechaDocumento.Text.ToDate, PagueseA, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=2)
'valida prepoliza
If CvePrePoliza > 0 Then
tFolio = ObjIE.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero).ToString
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, tFolio, PagueseA, tImporteDev, tCveMoneda,
tTipoCambio, tObs, "", False, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=tCveCorte, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero)
If CveIE > 0 Then
Dim ImporteAplicar As Decimal = 0.0D
Dim ImporteAplicarMN As Decimal = 0.0D
Dim ImporteAplicarME As Decimal = 0.0D
Dim ReferenciaAplicar As String = ObjIE.Folio
Dim ConceptoAplicar As String = $"Devolución al cliente {PagueseA} {tImporteDev} "
ImporteAplicar = tImporteDev
ImporteAplicarME = ImporteAplicar
'CONSIDERA COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ImporteAplicar
Else
ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, tTipoCambio)).RoundSQL()
End If
'BANCOS
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAplicar, ImporteAplicarMN, 30, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=-1, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución"
End If
'BANCOS COMPLEMENTARIAs
If tCveMoneda > 1 Then
ImporteAplicarMN = ((ImporteAplicar * If(tCveMoneda = 1, 1, tTipoCambio)) - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAplicar, ImporteAplicarMN, 204, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=-1, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
'OTROS INGRESOS/EGRESOS
Dim ImpOtros As Decimal = TxtDevRedondeo.Text.ToDecimal
If ImpOtros <> 0 Then
Dim TipoMovtoIE As Boolean = False
Dim CveConcIE As Integer = 78
Dim tCveSub As Integer = GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero
If ImpOtros < 0 Then
TipoMovtoIE = True : ImpOtros = Math.Abs(ImpOtros) : CveConcIE = 78
Else
TipoMovtoIE = False : ImpOtros = Math.Abs(ImpOtros) : CveConcIE = 211
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoIE, ImpOtros, ImpOtros, CveConcIE, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveCliente:=CveCliente, ImporteME:=0, CveSubProyecto:=tCveSub) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
End If
End If
Dim tImporte As Decimal = 0
Dim tTipoMovto As Boolean = True
For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.FCCheckBox("chkDevolver").Checked Then
Dim PorcentajePagoDevDin As Decimal = (gvr.DataKey("Saldo").ToDecimal / gvr.DataKey("Total").ToDecimal).RoundSQL(6)
Dim tCveConcepto As Integer
ImporteAplicar = gvr.DataKey("Saldo").ToDecimal
If gvr.DataKey("Tipo") = "IxC" Then
tCveConcepto = 92 : tTipoMovto = False
ElseIf gvr.DataKey("Tipo").Contiene("Dev", "NC") Then
tCveConcepto = 12 : ImporteAplicar = -ImporteAplicar : tTipoMovto = True
ElseIf gvr.DataKey("Tipo").Contiene("Ant") Then
tCveConcepto = 11 : ImporteAplicar = ImporteAplicar : tTipoMovto = False
End If
ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, tTipoCambio)).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, tTipoMovto, ImporteAplicar, ImporteAplicarMN, tCveConcepto, ReferenciaAplicar, ConceptoAplicar, CveIE:=gvr.DataKey("CveIE").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit For
End If
'IMPUESTOS
If gvr.DataKey("IVA").ToDecimal > 0 Then
tImporte = -(gvr.DataKey("IVA").ToDecimal * PorcentajePagoDevDin).RoundSQL
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, tImporte, tImporte, 13, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME, PorcentajeImpuesto:=gvr.DataKey("PorcentajeIVA").ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit For
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, tImporte, tImporte, 61, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME, PorcentajeImpuesto:=gvr.DataKey("PorcentajeIVA").ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit For
End If
End If
If gvr.DataKey("IEPS").ToDecimal > 0 Then
tImporte = (gvr.DataKey("IEPS").ToDecimal * PorcentajePagoDevDin).RoundSQL
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, tImporte, tImporte, 39, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit For
End If
End If
If gvr.DataKey("RetIVA").ToDecimal > 0 Then
tImporte = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePagoDevDin).RoundSQL
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, tImporte, tImporte, 62, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit For
End If
End If
If gvr.DataKey("RetISR").ToDecimal > 0 Then
tImporte = (gvr.DataKey("RetISR").ToDecimal * PorcentajePagoDevDin).RoundSQL
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, tImporte, tImporte, 63, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit For
End If
End If
End If
Next
If MsgError = "" Then
If ObjMov.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
' MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"Bancos/IE | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
Else
MsgError = "No se pudo validar la prepoliza de cuadre."
End If
End If
If MsgError = "" Then
ObjIE.Commit()
Dim Msg As New StringBuilder
If Msg.ToString = "" Then
Msg.Append("El Documento se guardo correctamente")
End If
Dim Archivo As System.IO.FileInfo = Nothing
'VERIFICA SI EXISTE EL FORMATO
If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(2, 8, 9) Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta))
ElseIf DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(1) Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero))
If Not Archivo.Exists Then
Archivo = New System.IO.FileInfo(String.Format("{0}\Empresas\Grales\Formatos\CHQ.rdlc", ModExtensiones.DirectorioBaseEmpresas))
End If
'ElseIf DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(6) And UsuarioActual.CveEmpresa = 72 Then
' Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/ComprobanteEgreso.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero))
End If
If Archivo IsNot Nothing AndAlso Archivo.Exists Then
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">{1}</a> ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem))
End If
ModalidadSelecionDevAnticipos = False
divDevolverAnticipos.Visible = False
CargaAnticipos()
If UsuarioActual.Empresa.TipoContabilidad = 1 Then
Msg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}"">Ver Póliza</a>", CvePrePoliza)
End If
Alert(Msg.ToString)
Else
ObjIE.RollBack()
Alert(MsgError, TipoMensaje.MsgAdvertencia)
End If
End If
End If
ObjIE.Dispose()
ObjMov.Dispose()
End Sub
#End Region
End Class