Commit inicial Ventas Productivo
This commit is contained in:
592
Bancos/DepositoTerminal.aspx.vb
Normal file
592
Bancos/DepositoTerminal.aspx.vb
Normal file
@@ -0,0 +1,592 @@
|
||||
|
||||
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Partial Class Bancos_DepositoTerminal
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "Propiedades"
|
||||
Private Property NombreComercial As String
|
||||
Get
|
||||
Return ViewState("NombreComercial").ToString
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("NombreComercial") = 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 IdCuentaBancariaComplementaria As Integer
|
||||
Get
|
||||
Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("IdCuentaBancariaComplementaria") = 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 CveCuentaBancariaComplementaria As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaBancariaComplementaria").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveCuentaBancariaComplementaria") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property IdCuentaCliente As Integer
|
||||
Get
|
||||
Return ViewState("IdCuentaCliente").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("IdCuentaCliente") = value
|
||||
End Set
|
||||
End Property
|
||||
Private ReadOnly Property IdCtaContMonedaExtranjera As Integer
|
||||
Get
|
||||
Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private ReadOnly Property IdCtaContComplementaria As Integer
|
||||
Get
|
||||
Return ViewState("IdCtaContComplementaria").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private ReadOnly Property IdCtaContRetIVA As Integer
|
||||
Get
|
||||
Return ViewState("IdCtaContRetIVA").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private ReadOnly Property IdCtaContRetISR As Integer
|
||||
Get
|
||||
Return ViewState("IdCtaContRetISR").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private Property CveCuentaCliente As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaCliente").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveCuentaCliente") = value
|
||||
End Set
|
||||
End Property
|
||||
Private ReadOnly Property CveCuentaMonedaExtranjera As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaMonedaExtranjera").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private ReadOnly Property CveCuentaComplementaria As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaComplementaria").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private ReadOnly Property CveCuentaRetIVA As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaRetIVA").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private ReadOnly Property CveCuentaRetISR As Integer
|
||||
Get
|
||||
Return ViewState("CveCuentaRetISR").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Private Sub Bancos_DepositoTerminal_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
TxtFecha.Text = Now.ToShortDateString
|
||||
CargaCuentas()
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(1, 4, 7, 11, 12, 72, 80, 119) Then
|
||||
rowComisiones.Visible = True
|
||||
'divTipoPago.Visible = True
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub ChkAjusteOI_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ChkAjusteOI.CheckedChanged
|
||||
|
||||
If ChkAjusteOI.Checked Then
|
||||
TxtOtrosImportes.Visible = True
|
||||
TxtTotal.Visible = True
|
||||
GvFacturas.Columns(5).Visible = True
|
||||
Else
|
||||
TxtOtrosImportes.Visible = False
|
||||
TxtTotal.Visible = False
|
||||
GvFacturas.Columns(5).Visible = False
|
||||
TxtOtrosImportes.Text = ""
|
||||
TxtTotal.Text = ""
|
||||
RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);")
|
||||
End If
|
||||
|
||||
UpGvFacturas.Update()
|
||||
'UPVentas.Update()
|
||||
End Sub
|
||||
|
||||
#Region "CARGA COMBOS"
|
||||
Private Sub CargaCuentas()
|
||||
DdlCuentaDeposito.DataSource = GlobalDTBancosCuentas(-1).FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTipoCuenta <> 1", "", {"CveCuenta", "NumCuentaMoneda"})
|
||||
DdlCuentaTerminal.DataSource = GlobalDTBancosCuentas(-1).FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTipoCuenta = 1", "", {"CveCuenta", "NumCuentaMoneda"})
|
||||
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones().FiltraParametros("CveTipoTransaccion in (11,12)")
|
||||
|
||||
DdlCuentaDeposito.DataBind()
|
||||
DdlCuentaTerminal.DataBind()
|
||||
DdlTipoTransaccion.DataBind()
|
||||
|
||||
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End Sub
|
||||
|
||||
Private Sub DdlCuentaSelectIndexChange()
|
||||
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuentaDeposito.SelectedValue)
|
||||
|
||||
If dr IsNot Nothing Then
|
||||
IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero
|
||||
IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero
|
||||
|
||||
CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero
|
||||
CveCuentaBancariaComplementaria = dr("IdCtaContableComplementariaSIG").ToString.ToEntero
|
||||
Else
|
||||
IdCuentaBancaria = 0
|
||||
IdCuentaBancariaComplementaria = 0
|
||||
|
||||
CveCuentaBancaria = 0
|
||||
CveCuentaBancariaComplementaria = 0
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
|
||||
Dim Folio As Long
|
||||
Dim Banco As New ClsBancos
|
||||
Folio = Banco.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, 8)
|
||||
Banco.Dispose()
|
||||
TxtFolio.Text = Folio.ToString
|
||||
Else
|
||||
TxtFolio.Text = ""
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaDeposito.SelectedIndexChanged
|
||||
DdlCuentaSelectIndexChange()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "CARGA DATOS"
|
||||
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.GetVentasTerminal(FechaI, FechaF, UsuarioActual.CveEmpresa, DdlCuentaTerminal.SelectedValue.ToEntero)
|
||||
|
||||
GvFacturas.DataSource = ObjBancos.DtResultados
|
||||
ObjBancos.Dispose()
|
||||
|
||||
UpGvFacturas.Update()
|
||||
GvFacturas.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "GUARDAR"
|
||||
Private Sub BtnDepositar_Click(sender As Object, e As EventArgs) Handles BtnDepositar.Click
|
||||
Dim TotalImporte As Decimal = 0
|
||||
|
||||
For Each Gvr As GridViewRow In GvFacturas.Rows
|
||||
If Gvr.FCCheckBox("ChkFactura").Checked Then
|
||||
TotalImporte += Gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
||||
End If
|
||||
Next
|
||||
|
||||
If TotalImporte = 0 Then
|
||||
Alert("Seleccion una factura para realizar el deposito", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
Else
|
||||
Dim OcurrioError As Boolean = False
|
||||
Dim ObjContabilidad As New ClsContabilidad()
|
||||
Dim ObjCliente As New ClsClientes(ObjContabilidad.IniciaTransacSQL())
|
||||
Dim ObjBancos As New ClsBancos(ObjContabilidad.IniciaTransacSQL())
|
||||
|
||||
Dim CveIE As Integer 'Banco
|
||||
Dim NuevaCvePrePoliza As Integer
|
||||
Dim CveMoneda As Integer = 1
|
||||
Dim TipoCambio As Double = 1
|
||||
Dim Fecha As Date = TxtFecha.Text.ToDate
|
||||
Dim IdCuentaBancariaOrigen As Integer = 0
|
||||
Dim IdCuentaBancariaDestino As Integer = 0
|
||||
Dim CveCuentaBancariaOrigen As Integer = 0
|
||||
Dim CveCuentaBancariaDestino As Integer = 0
|
||||
Dim IDPoliza As Integer = 0
|
||||
Dim FolioPoliza As String = ""
|
||||
Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero($"CveCuenta = {DdlCuentaDeposito.SelectedValue}")
|
||||
Dim MsgError As String = ""
|
||||
|
||||
If drDestino IsNot Nothing Then
|
||||
CveMoneda = drDestino("CveMoneda").ToString.ToEntero
|
||||
IdCuentaBancariaDestino = drDestino("IdCtaContable").ToString.ToEntero
|
||||
CveCuentaBancariaDestino = drDestino("IdCtaContableSIG").ToString.ToEntero
|
||||
End If
|
||||
|
||||
NuevaCvePrePoliza = ObjContabilidad.AddPrePolizas("Ventas", 11, TotalImporte, TotalImporte, CveMoneda, Fecha, "Depósito Bancario", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
CveIE = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text, "Depósito Bancario", TxtImporte.Text.ToDecimal, CveMoneda, 1, TxtObservaciones.Text, "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
If CveIE > 0 Then
|
||||
If NuevaCvePrePoliza > 0 Then
|
||||
Dim PorcentajePago As Decimal = 1
|
||||
Dim CvePlantillaPoliza As Integer = 11
|
||||
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
|
||||
Dim idCuentaContabilizacion As Long = 1
|
||||
Dim CveCuentaContabilizacion As Long = 1
|
||||
Dim dtConceptos As DataTable = Nothing
|
||||
Dim tipoCambioVenta As Decimal
|
||||
Dim tipoCambioActual As Decimal
|
||||
Dim tipoCambioManual As Decimal
|
||||
Dim CuentasContablesInvalidas As New StringBuilder
|
||||
Dim CuentasContablesInvalidasSIG As New StringBuilder
|
||||
|
||||
If ObjContabilidad.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then
|
||||
dtConceptos = ObjContabilidad.DtResultados
|
||||
End If
|
||||
|
||||
'inserto las ventas que voy a pagar
|
||||
For Each gvr As GridViewRow In GvFacturas.Rows
|
||||
If gvr.FCCheckBox("ChkFactura").Checked Then
|
||||
|
||||
If ObjCliente.GetClientes(gvr.DataKey("CveCliente").ToEntero, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1) Then
|
||||
NombreComercial = ObjCliente.NombreComercial
|
||||
ViewState("CtaCliente") = ObjCliente.IdCtaContClientes
|
||||
ViewState("IdCuentaCliente") = ObjCliente.IdCtaContClientes
|
||||
ViewState("IdCtaContMonedaExtranjera") = ObjCliente.IdCtaContMonedaExtranjera
|
||||
ViewState("IdCtaContComplementaria") = ObjCliente.IdCtaContComplementaria
|
||||
ViewState("IdCtaContRetIVA") = ObjCliente.IdCtaContRetIVA
|
||||
ViewState("IdCtaContRetISR") = ObjCliente.IdCtaContRetISR
|
||||
|
||||
ViewState("CveCuentaCliente") = ObjCliente.CveCuentaClientes
|
||||
ViewState("CveCuentaMonedaExtranjera") = ObjCliente.CveCuentaMonedaExtranjera
|
||||
ViewState("CveCuentaComplementaria") = ObjCliente.CveCuentaComplementaria
|
||||
ViewState("CveCuentaRetIVA") = ObjCliente.CveCuentaRetIVA
|
||||
ViewState("CveCuentaRetISR") = ObjCliente.CveCuentaRetISR
|
||||
|
||||
IdCuentaBancaria = 0
|
||||
CveCuentaBancaria = 0
|
||||
End If
|
||||
|
||||
If gvr.DataKey("CveMoneda").ToEntero = 2 Then
|
||||
tipoCambioVenta = GlobalTipoCambio(gvr.FCLiteral("LtlFecha").Text.ToDate).ToString.ToDecimal
|
||||
tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal
|
||||
tipoCambioManual = tipoCambioActual
|
||||
Else
|
||||
tipoCambioVenta = 1
|
||||
tipoCambioActual = 1
|
||||
tipoCambioManual = 1
|
||||
End If
|
||||
|
||||
|
||||
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 FechaMovimiento As Date = TxtFecha.Text.ToDate
|
||||
Dim IdCtaContable As Integer = 0
|
||||
Dim CveCuenta As Integer = 0
|
||||
Dim ConceptoMovimiento As String = ObjContabilidad.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreComercial, gvr.DataKey("SerieFolio").ToString, TxtFolio.ToString)
|
||||
Dim Referencia As String = gvr.DataKey("SerieFolio").ToString
|
||||
Dim CveSubProyecto As Integer = gvr.DataKey("CveSubProyecto").ToEntero
|
||||
|
||||
Select Case ConceptoContable
|
||||
Case 2 'Pago Cliente
|
||||
ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
||||
importeMX = ImporteMovimiento * tipoCambioVenta
|
||||
|
||||
If tipoCambioVenta = 1 Then
|
||||
IdCtaContable = IdCuentaCliente
|
||||
CveCuenta = CveCuentaCliente
|
||||
Else
|
||||
ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
IdCtaContable = IdCtaContComplementaria
|
||||
CveCuenta = CveCuentaComplementaria
|
||||
If ImporteMovimiento <> 0 AndAlso IdCtaContable > 0 Then
|
||||
importeMX = ImporteMovimiento
|
||||
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, TipoMovimiento, 0, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyecto, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=ImporteMovimiento * tipoCambioVenta - ImporteMovimiento, CveCuenta:=CveCuenta) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
End If
|
||||
|
||||
IdCtaContable = IdCtaContMonedaExtranjera
|
||||
CveCuenta = CveCuentaMonedaExtranjera
|
||||
End If
|
||||
|
||||
Case 8 'Ret IVA x Trasladar
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento, 2) * tipoCambioVenta
|
||||
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
'Conta ContPAQ
|
||||
If IdCtaContRetIVA <> 0 Then
|
||||
IdCtaContable = IdCtaContRetIVA
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
IdCtaContable = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'Conta SIG
|
||||
If CveCuentaRetIVA <> 0 Then
|
||||
CveCuenta = CveCuentaRetIVA
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
CveCuenta = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Case 9 'Ret ISR x Trasladar
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento, 2) * tipoCambioVenta
|
||||
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
'Conta ContPAQ
|
||||
If IdCtaContRetISR <> 0 Then
|
||||
IdCtaContable = IdCtaContRetISR
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
IdCtaContable = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'Conta SIG
|
||||
If CveCuentaRetISR <> 0 Then
|
||||
CveCuenta = CveCuentaRetISR
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
CveCuenta = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Case 13 'Iva por Trasladar
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioVenta, 2)
|
||||
IdCtaContable = UsuarioActual.Empresa.IdCuentaIVAxTrasladar
|
||||
CveCuenta = UsuarioActual.Empresa.CveCuentaIVAxTrasladar
|
||||
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
Case 62 'Ret IVA Trasladado
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioVenta, 2)
|
||||
If tipoCambioManual > 1 Then ConceptoMovimiento += $" TC:{tipoCambioManual} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
'Conta ContPAQ
|
||||
If IdCtaContRetIVA <> 0 Then
|
||||
IdCtaContable = IdCtaContRetIVA
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
IdCtaContable = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'Conta SIG
|
||||
If CveCuentaRetIVA <> 0 Then
|
||||
CveCuenta = CveCuentaRetIVA
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
CveCuenta = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Case 63 'Ret ISR Trasladado
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioManual, 2)
|
||||
If tipoCambioManual > 1 Then ConceptoMovimiento += $" TC:{tipoCambioManual} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
'Conta ContPAQ
|
||||
If IdCtaContRetISR <> 0 Then
|
||||
IdCtaContable = IdCtaContRetISR
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
IdCtaContable = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'Conta SIG
|
||||
If CveCuentaRetISR <> 0 Then
|
||||
CveCuenta = CveCuentaRetISR
|
||||
Else
|
||||
If ObjContabilidad.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
|
||||
If ObjContabilidad.DtResultados.Rows.Count > 0 Then
|
||||
CveCuenta = ObjContabilidad.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Case 61 'Iva Trasladado
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("IVA").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioManual, 2)
|
||||
IdCtaContable = UsuarioActual.Empresa.IdCuentaIVATrasladado
|
||||
CveCuenta = UsuarioActual.Empresa.CveCuentaIVATrasladado
|
||||
If tipoCambioManual > 1 Then ConceptoMovimiento += $" TC:{tipoCambioManual} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
Case 38 'IEPS por trasladar
|
||||
|
||||
ImporteMovimiento = gvr.DataKey("IEPS").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioVenta, 2)
|
||||
|
||||
IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar
|
||||
CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar
|
||||
|
||||
Case 39 'IEPS Trasladado
|
||||
ImporteMovimiento = gvr.DataKey("IEPS").ToDecimal * PorcentajePago
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioManual, 2)
|
||||
|
||||
IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado
|
||||
CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSTrasladado
|
||||
|
||||
Case 78 'Otros Ingresos
|
||||
If ChkAjusteOI.Checked Then
|
||||
ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal
|
||||
importeMX = Math.Round(ImporteMovimiento * tipoCambioVenta, 2)
|
||||
|
||||
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
End If
|
||||
|
||||
Case 30
|
||||
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)
|
||||
idCuentaContabilizacion = 0
|
||||
End If
|
||||
|
||||
'Conta SIG
|
||||
If (CveCuenta < 1 Or CveCuentaBancaria < 1) Then
|
||||
CuentasContablesInvalidasSIG.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
|
||||
CveCuentaContabilizacion = 0
|
||||
End If
|
||||
|
||||
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.DataKey("CveVenta").ToEntero, -1, CveSubProyecto, gvr.DataKey("CveCliente").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 IdCuentaBancariaComplementaria > 0 OrElse CveCuentaBancariaComplementaria > 0 Then
|
||||
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TxtImporte.Text.ToDecimal, "", 30, "", TxtFecha.Text.ToDate, IdCuentaBancaria, -1, CveIE, -1, -1, -1, -1, ImporteMX:=TxtImporte.Text.ToDecimal, CveCuenta:=CveCuentaBancaria) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TxtImporte.Text.ToDecimal, "", 30, "", TxtFecha.Text.ToDate, IdCuentaBancariaComplementaria, -1, CveIE, -1, -1, -1, -1, ImporteMX:=TxtImporte.Text.ToDecimal, CveCuenta:=CveCuentaBancariaComplementaria) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
Else
|
||||
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TxtImporte.Text.ToDecimal, "", 30, "", TxtFecha.Text.ToDate, IdCuentaBancaria, -1, CveIE, -1, -1, -1, -1, ImporteMX:=TxtImporte.Text.ToDecimal, CveCuenta:=CveCuentaBancaria) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
Else
|
||||
MsgError = "No se insertó el encabezado"
|
||||
End If
|
||||
|
||||
If MsgError = "" Then
|
||||
ObjContabilidad.Commit()
|
||||
CargaDatos()
|
||||
DdlCuentaSelectIndexChange()
|
||||
|
||||
TxtObservaciones.Text = ""
|
||||
TxtImporte.Text = ""
|
||||
|
||||
UPPFiltros.Update()
|
||||
|
||||
Dim StrMsg As New StringBuilder
|
||||
StrMsg.Append("Abono Registrado Correctamente.<br/>")
|
||||
If IDPoliza > 0 Then StrMsg.AppendFormat("<br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a>", IDPoliza, FolioPoliza)
|
||||
|
||||
Alert($"{StrMsg.ToString}<br/><br/>", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ObjContabilidad.RollBack()
|
||||
End If
|
||||
|
||||
ObjBancos.Dispose()
|
||||
ObjContabilidad.Dispose()
|
||||
ObjCliente.Dispose()
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub GvFacturas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvFacturas.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.FCCheckBox("ChkFactura").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Importe")))
|
||||
|
||||
If e.Row.DBCampo("CveVenta").ToEntero > 0 Then
|
||||
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1);", e.Row.FCCheckBox("ChkFactura").ClientID, e.Row.DBCampo("Importe")))
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(157).ToDecimal <> 0 Then
|
||||
e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnLimites({0},this,{1},{2},2);", e.Row.FCCheckBox("Chk").ClientID, -UsuarioActual.Empresa.Funcionalidad(157), UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal))
|
||||
e.Row.FCRangeValidator("RVComision").MinimumValue = -UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal
|
||||
e.Row.FCRangeValidator("RVComision").MaximumValue = UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal
|
||||
e.Row.FCRangeValidator("RVComision").Enabled = True
|
||||
Else
|
||||
e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2);", e.Row.FCCheckBox("ChkFactura").ClientID, e.Row.DBCampo("Importe")))
|
||||
e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00
|
||||
e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Importe")
|
||||
End If
|
||||
|
||||
Else
|
||||
e.Row.FCTextBox("TxtAbonar").Visible = False
|
||||
e.Row.FCTextBox("TxtComision").Visible = False
|
||||
e.Row.FCCheckBox("ChkFactura").Visible = False
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
End Class
|
||||
Reference in New Issue
Block a user