Commit inicial Ventas Productivo
This commit is contained in:
261
Bancos/RegistroPagoIntermediario.aspx.vb
Normal file
261
Bancos/RegistroPagoIntermediario.aspx.vb
Normal file
@@ -0,0 +1,261 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Partial Class Bancos_PagosIntermediarios
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Property FacturasCheckadas As Integer
|
||||
Get
|
||||
Return ViewState("FacturasCheckadas").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("FacturasCheckadas") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property IdCuentaBancaria As Integer
|
||||
Get
|
||||
Return ViewState("IdCuentaBancaria").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("IdCuentaBancaria") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property CveCuentaBancaria As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaBancaria").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveCuentaBancaria") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property CveMoneda As Integer
|
||||
Get
|
||||
Return ViewState("CveMoneda").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveMoneda") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
FacturasCheckadas = 0
|
||||
TxtFecha.Text = Now.ToShortDateString
|
||||
CargaCuentas()
|
||||
CargaFiltros()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaFiltros()
|
||||
Dim ObjProveedores As New ClsCompProveedores
|
||||
ObjProveedores.GetProveedorProsepago(UsuarioActual.CveEmpresa)
|
||||
|
||||
DdlProveedorPagoInt.Visible = True
|
||||
DdlProveedorPagoInt.DataSource = ObjProveedores.DtResultados
|
||||
DdlProveedorPagoInt.DataBind()
|
||||
|
||||
ObjProveedores.Dispose()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCuentas()
|
||||
DdlCuentaDeposito.DataSource = GlobalDTBancosCuentas(-1).FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTipoCuenta <> 1", "", {"CveCuenta", "NumCuentaMoneda"})
|
||||
DdlCuentaDeposito.DataBind()
|
||||
DdlCuentaDeposito_SelectedIndexChanged(Nothing, Nothing)
|
||||
End Sub
|
||||
|
||||
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjBancos As New ClsBancos
|
||||
Dim FechaI, FechaF As String
|
||||
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
|
||||
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
|
||||
|
||||
ObjBancos.GetPagosIntermediarios(DdlProveedorPagoInt.SelectedValue.ToEntero, FechaI, FechaF, UsuarioActual.CveEmpresa)
|
||||
GvFacturas.DataSource = ObjBancos.DtResultados
|
||||
GvFacturas.DataBind()
|
||||
|
||||
UpGvFacturas.Update()
|
||||
ObjBancos.Dispose()
|
||||
End Sub
|
||||
Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaDeposito.SelectedIndexChanged
|
||||
|
||||
Dim dr As DataRow = GlobalDTBancosCuentas(-1).FiltroPrimero("CveCuenta = " & DdlCuentaDeposito.SelectedValue)
|
||||
|
||||
If dr IsNot Nothing Then
|
||||
CveMoneda = dr("CveMoneda").ToString.ToEntero
|
||||
IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero
|
||||
CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
|
||||
Dim Folio As Long
|
||||
Dim Banco As New ClsBancos
|
||||
Folio = Banco.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, 2)
|
||||
Banco.Dispose()
|
||||
TxtFolio.Text = Folio.ToString
|
||||
Else
|
||||
TxtFolio.Text = ""
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BtnDepositar_Click(sender As Object, e As EventArgs) Handles BtnDepositar.Click
|
||||
|
||||
If Not TxtTotalBancos.Text.ToEntero > 0 Then
|
||||
Alert("Debe seleccionar por lo menos una factura", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim ObjIE As New ClsBancos()
|
||||
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
||||
Dim CvePrePoliza As Integer = 0
|
||||
Dim IDPoliza As Integer = 0
|
||||
Dim FolioPoliza As String = ""
|
||||
Dim MsgError As String = ""
|
||||
Dim tipoCambio As Decimal
|
||||
Dim CvePlantillaPoliza As Integer = 63
|
||||
Dim FechaMovimiento As Date = TxtFecha.Text.ToDate
|
||||
Dim AboneA As String = "Pagos Intermediarios"
|
||||
Dim ConceptoPoliza As String = String.Format("{0} {1}", AboneA, TxtObservaciones.Text)
|
||||
Dim TotalMovimiento As Decimal = TxtTotalBancos.Text.ToDecimal + TxtTotalComisiones.Text.ToDecimal
|
||||
Dim CveCliente As Integer = -1
|
||||
|
||||
CvePrePoliza = ObjMov.AddPrePolizas("Bancos/RegistroPagoIntermediario", CvePlantillaPoliza, TotalMovimiento, TotalMovimiento, CveMoneda, FechaMovimiento, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
If CvePrePoliza > 0 Then
|
||||
|
||||
Dim dtConceptos As DataTable = Nothing
|
||||
Dim CuentasContablesInvalidas As New StringBuilder
|
||||
Dim CuentasContablesInvalidasSIG As New StringBuilder
|
||||
Dim TotalComisiones As Double = 0
|
||||
Dim TotalPagos As Double = 0
|
||||
Dim ConceptoMovimientoBancos As String = ""
|
||||
|
||||
If CveMoneda = 2 Then
|
||||
tipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal
|
||||
Else
|
||||
tipoCambio = 1
|
||||
End If
|
||||
|
||||
If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then
|
||||
dtConceptos = ObjMov.DtResultados
|
||||
End If
|
||||
|
||||
Dim CveIE As Integer = ObjIE.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, 8, FechaMovimiento, TxtFolio.Text.Trim, AboneA.Trim, TxtTotalBancos.Text.ToDecimal, CveMoneda, 0.0, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
For Each gvr As GridViewRow In GvFacturas.Rows
|
||||
If gvr.FCCheckBox("ChkFactura").Checked Then
|
||||
|
||||
If dtConceptos IsNot Nothing Then
|
||||
For Each Row As DataRow In dtConceptos.Rows
|
||||
|
||||
Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
|
||||
Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
|
||||
Dim ImporteMovimiento As Decimal = 0
|
||||
Dim importeMX As Decimal
|
||||
Dim IdCtaContable As Integer = 0
|
||||
Dim CveCuenta As Integer = 0
|
||||
Dim ConceptoMovimiento As String = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, gvr.FCLiteral("LtCliente").Text, gvr.FCHyperLink("LtSerieFolio").Text, TxtFolio.Text.Trim)
|
||||
CveCliente = gvr.DataKey("CveCliente").ToString.ToEntero
|
||||
|
||||
Select Case ConceptoContable
|
||||
|
||||
Case 253 'Comision por recuperacion de cartera (Prosepago)
|
||||
ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
|
||||
importeMX = ImporteMovimiento * tipoCambio
|
||||
TotalComisiones += ImporteMovimiento
|
||||
|
||||
Dim ObjProv As New ClsCompProveedores
|
||||
If ObjProv.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, DdlProveedorPagoInt.SelectedValue.ToEntero, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa) Then
|
||||
IdCtaContable = ObjProv.IdCtaContDeudor
|
||||
End If
|
||||
ObjProv.Dispose()
|
||||
|
||||
Case 133 'Pago Intermediario
|
||||
ImporteMovimiento = gvr.DataKey("Saldo").ToDecimal
|
||||
importeMX = ImporteMovimiento * tipoCambio
|
||||
TotalPagos += ImporteMovimiento
|
||||
|
||||
Dim ObjCliente As New ClsClientes
|
||||
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
|
||||
IdCtaContable = ObjCliente.IdCtaContClientes
|
||||
End If
|
||||
ObjCliente.Dispose()
|
||||
|
||||
Case 30 'Bancos
|
||||
ConceptoMovimientoBancos = ConceptoMovimiento
|
||||
ImporteMovimiento = 0
|
||||
|
||||
Case Else
|
||||
ImporteMovimiento = 0
|
||||
|
||||
End Select
|
||||
|
||||
If ImporteMovimiento <> 0 Then
|
||||
'Conta ContPAQ
|
||||
If (IdCtaContable < 1 Or IdCuentaBancaria < 1) Then
|
||||
CuentasContablesInvalidas.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
|
||||
End If
|
||||
|
||||
'Conta SIG
|
||||
If (CveCuenta < 1 Or CveCuentaBancaria < 1) Then
|
||||
CuentasContablesInvalidasSIG.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
|
||||
End If
|
||||
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, ConceptoMovimiento, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.DataKey("CveVenta").ToString.ToEntero, -1, -1, CveCliente, CveProveedor:=DdlProveedorPagoInt.SelectedValue.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtTotalBancos.Text.ToDecimal, ConceptoMovimientoBancos, 30, ConceptoMovimientoBancos, FechaMovimiento, IdCuentaBancaria, -1, CveIE, -1, -1, -1, CveCliente, ImporteMX:=TxtTotalBancos.Text.ToDecimal * tipoCambio, CveCuenta:=CveCuentaBancaria) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
|
||||
If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
|
||||
If ObjMov.ValorPolizaDescuadre > 0 Then
|
||||
MsgError = "La suma de los importes no coinciden"
|
||||
End If
|
||||
End If
|
||||
|
||||
Else
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
|
||||
If MsgError = "" Then
|
||||
ObjIE.Commit()
|
||||
TxtFolio.Text = ""
|
||||
TxtObservaciones.Text = ""
|
||||
TxtTotalBancos.Text = ""
|
||||
TxtTotalComisiones.Text = ""
|
||||
TxtFecha.Text = Now.ToShortDateString
|
||||
CargaDatos()
|
||||
Alert(String.Format("El Depósito se ha registrado correctamente."), TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ObjIE.RollBack()
|
||||
Alert(String.Format("Ocurrió un error al registrar el movimiento."), TipoMensaje.MsgError)
|
||||
GuardaLog(MsgError)
|
||||
End If
|
||||
|
||||
ObjIE.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub GvFacturas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvFacturas.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", $"FnCambia({e.Row.FCCheckBox("ChkFactura").ClientID},this,{e.Row.DBCampo("Importe")},1,'{"El Importe no debe de exceder el saldo"}');")
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user