diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 9569d71cc..a7575fbdf 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -8072,6 +8072,7 @@ Public Class ClsPaginas Dim tFechaUltimaFluctuacion As Date Dim tImportePago, tImporteVenta As Decimal Dim CveConceptoContableComplementaria As Integer = 207 + Dim Contabilizable As Boolean = True If PorcentajePago > 1 Then PorcentajePago = 1 Pago.CveConceptoPago = If(Pago.CveConceptoPago = -1, 2, Pago.CveConceptoPago) 'si viene en parametro lo toma com primera opcion, sino el 2 If VentaActual.CveMoneda <> 1 Then @@ -8088,7 +8089,8 @@ Public Class ClsPaginas TCValuacion = UltimaFluctuacion.TCFluctuacion End If If VentaActual.Fecha < tFechaUltimaFluctuacion Then TCValuacionVenta = TCValuacion - If Pago.Fecha < tFechaUltimaFluctuacion Then TCValuacionPago = TCValuacion + 'si tiene fecha de documento, debe de evaluarse para su tc. y no la fecha de la prepóliza + If IIf(Pago.FechaDocumentoRelacionado > MinFecha, Pago.FechaDocumentoRelacionado, Pago.Fecha).ToString.ToDate < tFechaUltimaFluctuacion Then TCValuacionPago = TCValuacion End If End If If VentaActual.CveMoneda = 1 And Pago.CveMonedaPago <> 1 Then 'factura pesos, pago en dolares @@ -8102,11 +8104,34 @@ Public Class ClsPaginas tImportePago = (Pago.ImportePago * TCValuacionPago).RoundSQL End If If VentaActual.CveMoneda > 1 Then ImporteME = Pago.ImportePagoVenta + 'CONDICION ESPECIAL, PARA ANTICIPOS ESPECIALES, QUE SE EMITE LA VENTA, PERO NO SE CONTABILIZA, EL TRATAMIENTO SE LLEVA POR EL ANTICIPO + If VentaActual.TipoDocto = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then + Pago.AplicaTraslado = False + Dim IdCtaContable As Integer = VentaActual.IdCtaContableClienteAnticipo + If VentaActual.CveMoneda = 2 Then IdCtaContable = VentaActual.IdCtaContableClienteAnticipoExtranjera + Contabilizable = False + + If Pago.CveMonedaPago > 1 Then + 'Agregamos la Extranjera + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 295, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteAnticipoExtranjera, CveVenta:=Pago.CveVentaAmortizacion, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True + ImporteMN = (Pago.ImportePago * TCValuacionPago - Pago.ImportePago).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, ImporteMN, 227, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteAnticipoComplementaria, CveVenta:=Pago.CveVentaAmortizacion, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True + Else + 'Agregamos Nacional + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 3, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteAnticipo, CveVenta:=Pago.CveVentaAmortizacion, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambioPago:=Pago.TCPago) Then ErrorMovtos = True + End If + + If Not ErrorMovtos AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 95, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=Pago.CveIE, CveVenta:=VentaActual.CveVenta, CveSubProyecto:=VentaActual.CveSubProyecto, CveCliente:=VentaActual.CveCliente, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then + ErrorMovtos = True + End If + + End If + 'movimiento de pago cliente - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, Pago.ImportePagoVenta, Pago.CveConceptoPago, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableCliente, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, Pago.ImportePagoVenta, Pago.CveConceptoPago, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableCliente, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, Contabilizable:=Contabilizable) Then ErrorMovtos = True 'movimiento de pago cliente Complementaria If Not ErrorMovtos AndAlso VentaActual.CveMoneda > 1 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, (ImporteME * TCValuacionVenta - ImporteME).RoundSQL, CveConceptoContableComplementaria, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableClienteComplementaria, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, (ImporteME * TCValuacionVenta - ImporteME).RoundSQL, CveConceptoContableComplementaria, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableClienteComplementaria, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, Contabilizable:=Contabilizable) Then ErrorMovtos = True End If If Pago.AplicaTraslado Then 'si tiene iva y su proporcion @@ -8272,6 +8297,7 @@ Public Class ClsPaginas Public Property CveVenta As Integer = -1 Public Property CveCliente As Integer Public Property CveMoneda As Integer + Public Property TipoDocto As String Public Property Fecha As Date Public Property SerieFolio As String = "" Public Property ClienteNombre As String = "" diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 38fb457dc..031d14147 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -36,6 +36,14 @@ Partial Class Ventas_ClientesAbonar ViewState("CveMonedaFiltro") = value End Set End Property + Private Property FechaIngreso As Date + Get + Return ViewState("FechaIngreso").ToString.ToDate + End Get + Set(value As Date) + ViewState("FechaIngreso") = value + End Set + End Property Private Property CveSubProyecto As Integer Get Return ViewState("CveSubProyecto").ToString.ToEntero @@ -855,7 +863,7 @@ Partial Class Ventas_ClientesAbonar End If CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtAboneA.Text.Trim, TxtImporte.Text.ToDecimal, GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TipoCambio, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, CveProveedorIntermediario:=CveProvIntermediario) Else - If RblTipoPago.SelectedValue.Contiene("3") Then + If RblTipoPago.SelectedValue.Contiene("3") Then 'ixc CveIE = DdlIngreso.SelectedValue.ToEntero If CveMonedaPago = 2 And Not ChkPagarPesos.Checked Then CveMoneda = 2 If ChkPagarDolares.Checked Then CveMoneda = 2 @@ -957,6 +965,7 @@ Partial Class Ventas_ClientesAbonar VentaActual.Fecha = gvr.DataKey("Fecha").ToDate VentaActual.CveCliente = gvr.DataKey("CveCliente").ToEntero VentaActual.CveMoneda = gvr.DataKey("CveMoneda").ToEntero + VentaActual.TipoDocto = gvr.DataKey("TipoDocto") VentaActual.SerieFolio = gvr.DataKey("SerieFolio") VentaActual.ClienteNombre = NombreComercial VentaActual.TC = gvr.DataKey("TipoCambio").ToDecimal @@ -981,34 +990,37 @@ Partial Class Ventas_ClientesAbonar Pago.ImportePagoVenta = gvr.FCTextBox("TxtAbonar").Text.ToDecimal Pago.Referencia = TxtFolio.Text - If RblTipoPago.SelectedValue = "3" Then Pago.TipoPago = "I" + If RblTipoPago.SelectedValue = "3" Then + Pago.TipoPago = "I" + Pago.FechaDocumentoRelacionado = FechaIngreso + End If 'Tipos de cambio If Pago.CveMonedaPago = 1 AndAlso VentaActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos Pago.TCPago = TxtTC.Text.ToDecimal - ElseIf Pago.CveMonedaPago = 2 AndAlso VentaActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES + ElseIf Pago.CveMonedaPago = 2 AndAlso VentaActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES Pago.TCPago = IIf(TxtTCDolaresDolares.Visible, TxtTCDolaresDolares.Text.ToDecimal, TxtTCDolares.Text.ToDecimal) - ElseIf Pago.CveMonedaPago = 2 AndAlso VentaActual.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES + ElseIf Pago.CveMonedaPago = 2 AndAlso VentaActual.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES Pago.TCPago = TxtTCDolares.Text.ToDecimal End If tipoCambioPago = Pago.TCPago If gvr.FCTextBox("TxtComision").Text.ToDecimal <> 0 Then Pago.OtroGastoIngreso = gvr.FCTextBox("TxtComision").Text.ToDecimal - If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then - EsAnticipoEspecial = True - Pago.AplicaTraslado = False - Dim IdCtaContable As Integer = If(EsAnticipoEspecial, IdCtaAnticipo, IdCuentaCliente) - If VentaActual.CveMoneda = 2 Then IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaExtranjeraAnticipo, IdCtaContMonedaExtranjera) + 'If gvr.DataKey("TipoDocto") = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then + ' EsAnticipoEspecial = True + ' Pago.AplicaTraslado = False + ' Dim IdCtaContable As Integer = If(EsAnticipoEspecial, IdCtaAnticipo, IdCuentaCliente) + ' If VentaActual.CveMoneda = 2 Then IdCtaContable = If(EsAnticipoEspecial, IdCtaContMonedaExtranjeraAnticipo, IdCtaContMonedaExtranjera) - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 3, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveCliente:=ViewState("CveCliente").ToString.ToEntero, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 95, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveCliente:=ViewState("CveCliente").ToString.ToEntero, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then - MsgError = "No se pudo insertar la póliza" - End If - Else - MsgError = "No se pudo insertar la póliza" - End If - End If + ' If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 3, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveCliente:=ViewState("CveCliente").ToString.ToEntero, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then + ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 95, VentaActual.SerieFolio, VentaActual.SerieFolio, IdCtaContable, CveIE:=CveIE, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyectoContabilizar, CveCliente:=ViewState("CveCliente").ToString.ToEntero, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, Contabilizable:=False) Then + ' MsgError = "No se pudo insertar la póliza" + ' End If + ' Else + ' MsgError = "No se pudo insertar la póliza" + ' End If + 'End If If UsuarioActual.Empresa.Funcionalidad(590) = "1" AndAlso MsgError = "" Then '' si es empresa agrícola Dim FluctuacionAnticipo As Decimal = 0 @@ -2714,6 +2726,8 @@ Partial Class Ventas_ClientesAbonar Dim Deudores As New ClsMovimientos If Deudores.GetIngresosSaldosDetalle(CveCliente, -1, UsuarioActual.CveEmpresa) Then HdnIngresoImporte.Value = Deudores.DtResultados.FiltroPrimeroValor("Saldo", String.Format("CveIE = {0}", DdlIngreso.SelectedValue)) + TxtTCDolares.Text = Deudores.DtResultados.FiltroPrimeroValor("TipoCambio", String.Format("CveIE = {0}", DdlIngreso.SelectedValue)) + FechaIngreso = Deudores.DtResultados.FiltroPrimeroValor("FechaDocumento", String.Format("CveIE = {0}", DdlIngreso.SelectedValue)) End If Deudores.Dispose() End If