diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index b392ba7ff..37cd442b5 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -3,9 +3,9 @@ Imports System.Data Imports System.Linq Partial Class Ventas_ClientesAbonar - Inherits ClsPaginas - - + Inherits ClsPaginas + + #Region "Propiedades" Private ReadOnly Property CveCliente As Integer Get @@ -273,9 +273,9 @@ Partial Class Ventas_ClientesAbonar Set(value As Date) ViewState("Fecha") = value End Set - End Property + End Property #End Region - + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then CveMonedaPago = -1 @@ -2308,8 +2308,8 @@ Partial Class Ventas_ClientesAbonar UpDatos.Update() UPVentas.Update() - End Sub - + End Sub + #Region " PAGAR CON PESOS " Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs) If ChkPagarPesos.Checked Then @@ -2330,9 +2330,9 @@ Partial Class Ventas_ClientesAbonar CargaDatos(2) RegistraScript("CambiaPesosDolares();") - End Sub + End Sub #End Region - + #Region "PAGAR CON DOLARES" Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs) If ChkPagarDolares.Checked Then @@ -2353,9 +2353,9 @@ Partial Class Ventas_ClientesAbonar CargaDatos(1) RegistraScript("CambiaDolaresPesos();") - End Sub + End Sub #End Region - + #Region " CUENTAS DEPOSITOS" Private Sub CargaCuentasDepositos() DdlCuentaDeposito.Items.Clear() @@ -2422,9 +2422,9 @@ Partial Class Ventas_ClientesAbonar End If Dep.Dispose() UpCuentaDeposito.Update() - End Sub + End Sub #End Region - + #Region " COMPLEMENTOS PAGO " Private Function EmitirComplementoPago(CveIE As Integer, CveVentas As List(Of Integer), Series As List(Of String)) As String If Not ChkComplementoPago.Checked Then @@ -2476,14 +2476,14 @@ Partial Class Ventas_ClientesAbonar ' Next Return Retorno.ToString - End Function - - + End Function + + #End Region - + #Region "SALDAR CUENTAS" - - + + Private Sub BtnSaldarCuentasIncobrables_Click(sender As Object, e As EventArgs) Handles BtnSaldarCuentasIncobrables.Click Dim ObjConta As New ClsContabilidad ObjConta.IniciaTransacSQL() @@ -2507,7 +2507,10 @@ Partial Class Ventas_ClientesAbonar End If End If - ObjIE.Dispose() + ObjIE.Dispose() + + CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFechaIncobrable.Text.ToDate, TxtObsSaldarIncobrable.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + For Each gr As GridViewRow In GvCxC.Rows If gr.FCCheckBox("Chk").Checked Then @@ -2540,6 +2543,7 @@ Partial Class Ventas_ClientesAbonar Dim ImpuestosMovto As Boolean = False Dim IdCuentaContableNoDeducible As Integer = 0 Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero + Dim ConceptoPartida As String = TxtObsSaldarIncobrable.Text.Trim & " " & gr.DataKey("SerieFolio").ToString If CveConceptoDeduccion = 255 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(266).ToEntero If CveConceptoDeduccion = 211 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(559).ToEntero @@ -2561,9 +2565,8 @@ Partial Class Ventas_ClientesAbonar UsaComplementaria = True End If - If MsgError = "" Then - CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, gr.DataKey("Saldo").ToDecimal, gr.DataKey("Saldo").ToDecimal, gr.DataKey("CveMoneda").ToEntero, TxtFechaIncobrable.Text.ToDate, TxtObsSaldarIncobrable.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - + If MsgError = "" Then + If tCveMoneda = 2 Then IdCtaContable = IdCtaContMonedaExtranjera Else @@ -2572,16 +2575,16 @@ Partial Class Ventas_ClientesAbonar If UsaComplementaria AndAlso tCveMoneda = 2 Then 'normal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If 'complementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, 0, gr.DataKey("SerieFolio").ToString, 207, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContComplementaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, (Saldo * TCVenta) - Saldo), ImporteME:=Saldo, CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, 0, gr.DataKey("SerieFolio").ToString, 207, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContComplementaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, (Saldo * TCVenta) - Saldo), ImporteME:=Saldo, CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If Else - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo * TCVenta), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo * TCVenta), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If @@ -2592,11 +2595,11 @@ Partial Class Ventas_ClientesAbonar Dim ImporteFluctuacion As Decimal = 0 ImporteFluctuacion = Saldo * (TCPago - TCVenta) If TCPago > TCVenta Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 64, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaGananciaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 64, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaGananciaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If Else - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 65, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 65, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If End If @@ -2620,18 +2623,18 @@ Partial Class Ventas_ClientesAbonar IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) CveCuenta = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar) - If IVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 13, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If IVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 13, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar - If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 38, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 38, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If 'al gasto,Subtotal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, TxtObsSaldarIncobrable.Text.Trim, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If @@ -2772,10 +2775,10 @@ Partial Class Ventas_ClientesAbonar UpGuardar.Update() - End Sub - + End Sub + #End Region - + #Region "COMPLEMENTO DE PAGO - ELIMINAR POR SUSTITUCION" Protected Sub CargaIESustituir() Dim ObjIE As New ClsBancos() @@ -2952,10 +2955,10 @@ Partial Class Ventas_ClientesAbonar Private Sub BtnVincularIntermediario_Click(sender As Object, e As EventArgs) Handles BtnVincularIntermediario.Click RegistraScript("$('#ModalVincularIntermediario').modal('hide')", "hidemodal") - End Sub + End Sub #End Region - - + + Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs) CambiaTipoMoneda() End Sub diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 7660824e9..d3fb8d54f 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5938,16 +5938,17 @@ Partial Class Ventas Dim ClienteRetIVA = Me.ClienteRetIVA If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then - ClienteRetIVA = 0.0D - If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then - ClienteRetIVA = 0.106667D - ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then - ClienteRetIVA = 0.04D - ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(TmpDT.Rows(e.RowIndex)("EsOutSourcing").ToString()) Then - ClienteRetIVA = 0.06D + 'ClienteRetIVA = 0.0D + If ClienteRetIVA <= 0 Then + If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then + ClienteRetIVA = 0.106667D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then + ClienteRetIVA = 0.04D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(TmpDT.Rows(e.RowIndex)("EsOutSourcing").ToString()) Then + ClienteRetIVA = 0.06D + End If End If - - LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero + ' LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero DdlTipoRetencion.Visible = True End If @@ -14260,16 +14261,19 @@ Partial Class Ventas Dim ClienteRetIVA = Me.ClienteRetIVA If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then - ClienteRetIVA = 0.0D - If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then - ClienteRetIVA = 0.106667D - ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then - ClienteRetIVA = 0.04D - ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(DrPS("EsOutSourcing").ToString()) Then - ClienteRetIVA = 0.06D + 'ClienteRetIVA = 0.0D + If ClienteRetIVA <= 0 Then + If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then + ClienteRetIVA = 0.106667D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then + ClienteRetIVA = 0.04D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(DrPS("EsOutSourcing").ToString()) Then + ClienteRetIVA = 0.06D + End If + End If - LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero + ' LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero DdlTipoRetencion.Visible = True End If @@ -24068,13 +24072,16 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then For Each RowServicio As DataRow In TmpDT.Rows - Dim ClienteRetIVA = 0.0D - If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then - ClienteRetIVA = 0.106667D - ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then - ClienteRetIVA = 0.04D - ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(RowServicio("EsOutSourcing").ToString()) Then - ClienteRetIVA = 0.06D + Dim tClienteRetIVA = ClienteRetIVA + If tClienteRetIVA <= 0 Then + If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then + tClienteRetIVA = 0.106667D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then + tClienteRetIVA = 0.04D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso CBool(RowServicio("EsOutSourcing").ToString()) Then + tClienteRetIVA = 0.06D + End If + ViewState("ClienteRetIVA") = tClienteRetIVA End If Dim TotalCalculableImpuestos As Decimal = (RowServicio("Cantidad").ToString().ToDecimal() * RowServicio("PU").ToString().ToDecimal()) - RowServicio("Descuento").ToString().ToDecimal()