diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index 30d86e5aa..f9d40297c 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -38,47 +38,48 @@ - + +
+ Fecha Inicio Docto: +
+
+
+ + + + +
+ + + + + + +
+
+ Fecha Fin Docto: +
+
+
+ + + + +
+ + + + + + +
@@ -257,7 +258,7 @@
$ - +
@@ -271,7 +272,8 @@
- + +
@@ -287,5 +289,31 @@ - + diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index 660217f72..fa46e1e24 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -7,9 +7,20 @@ Imports Extensiones Partial Class Ventas_PVCobranza Inherits ClsPaginas + Private Property CveCorte As Integer + Get + Return ViewState("CveCorte").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCorte") = value + End Set + End Property + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then + CveCorte = 0 CargaFiltros() + CargaCorteCaja() End If End Sub @@ -18,7 +29,7 @@ Partial Class Ventas_PVCobranza DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) DdlSubProyecto.DataBind() - txtFechaI.Text = Now.AddDays(-7).ToShortDateString + txtFechaI.Text = Now.AddDays(-1).ToShortDateString txtFechaF.Text = Now.ToShortDateString 'DdlCuentaEfectivo.Items.Clear() @@ -34,19 +45,11 @@ Partial Class Ventas_PVCobranza 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlCuentaEfectivo.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 0", CveMon)) DdlCuentaCheque.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 0", CveMon)) - 'Else - ' DdlCuentaEfectivo.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", CveMon)) - ' DdlCuentaCheque.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", CveMon)) - 'End If + 'If UsuarioActual.Empresa.Funcionalidad(558) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlCuentaTarjetaCredito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 1", CveMon)) DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 1", CveMon)) - 'Else - ' DdlCuentaTarjetaCredito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND (CveTipoCuenta <> 1 OR TieneTerminal = 1)", CveMon)) - 'DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND (CveTipoCuenta <> 1 OR TieneTerminal = 1)", CveMon)) - 'End If - DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", CveMon)) DtCC.Dispose() @@ -56,6 +59,28 @@ Partial Class Ventas_PVCobranza DdlCuentaTarjetaDebito.DataBind() DdlCuentaCheque.DataBind() DdlCuentaTransferencia.DataBind() + TxtImporteEfectivo.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteCredito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteDebito.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteCheque.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteTransferencia.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + TxtImporteOtrosContado.Attributes.Add("onKeyUp", "CalculaTotalPagoContado();") + + End Sub + + Private Sub CargaCorteCaja() + Dim DebeCerrarCorte As Boolean = False + 'Checar si hay un Turno Abierto + Dim ObjPVenta As New ClsPuntoVenta + + If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then + + If ObjPVenta.DtResultados.Rows.Count > 0 Then + CveCorte = ObjPVenta.CveCorte + End If + End If + ObjPVenta.Dispose() + End Sub @@ -65,21 +90,27 @@ Partial Class Ventas_PVCobranza Dim FechaI, FechaF As Date FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim().ToDate, MinFecha) FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim().ToDate, MaxFecha).AddDays(1) + If ObjMovtos.GetRemisionesCobranza(UsuarioActual.CveEmpresa, DdlSubProyecto.SelectedValue.ToEntero, FechaI, FechaF) Then - If ObjMovtos.GetCxCDetalle(FechaI, FechaF, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, -1, "-1", "-1", -1, "-1", -1, - "-1", 1, UsuarioActual.CveEmpresa, -1, 1, - TipoDocto:="Rem", FechaCorte:=NowADS.AddDays(1), CveUsuarioConsulta:=UsuarioActual.CveUsuario, AplicaAnticiposPagados:=0) Then - - Dim dtt As DataTable = ObjMovtos.DSResultados.Tables(0).FiltraParametros($"CveVenta > 0 AND (CveUsuarioCobranza IS NULL OR CveUsuarioCobranza = {UsuarioActual.CveUsuario})") + Dim dtt As DataTable = ObjMovtos.DtResultados.FiltraParametros($"CveVenta > 0 AND (CveUsuarioCobranza IS NULL OR CveUsuarioCobranza = {UsuarioActual.CveUsuario})") 'si hay ya asignado, solo la mostrará Dim Dtta As DataTable = dtt.FiltraParametros($"CveUsuarioCobranza = {UsuarioActual.CveUsuario}") If Dtta IsNot Nothing AndAlso Dtta.Rows.Count > 0 Then dtt = Dtta GvDatos.DataSource = dtt End If + ObjMovtos.Dispose() GvDatos.DataBind() UpL.Update() + TxtImporteEfectivo.Text = "" + TxtImporteCredito.Text = "" + TxtImporteDebito.Text = "" + TxtImporteCheque.Text = "" + TxtImporteTransferencia.Text = "" + TxtImporteOtrosContado.Text = "" + TxtCambio.Text = "" + End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click @@ -109,7 +140,9 @@ Partial Class Ventas_PVCobranza TieneError = True End If HdnCveVenta.Value = CveVenta.ToString - TxtImporteEfectivo.Text = GvRow.DataKey("Saldo") + TxtImporteEfectivo.Text = GvRow.DataKey("Saldo").FormatoNumero + TxtImporteContado.Text = GvRow.DataKey("Saldo").FormatoNumero + HdnTotal.Value = GvRow.DataKey("Saldo") TxtImporteEfectivo.Focus() LtlNombre.Text = GvRow.DataKey("DescripcionVenta") LtlSaldo.Text = GvRow.DataKey("Saldo").ToDecimal.FormatoNumero @@ -164,26 +197,38 @@ Partial Class Ventas_PVCobranza Dim ObjConta As New ClsContabilidad Dim ObjIE As New ClsBancos(ObjConta.IniciaTransacSQL()) + Dim ObjVentas2 As New ClsVentas(ObjConta.IniciaTransacSQL()) Dim CvePrePoliza As Integer Dim Fecha As Date = NowADS() + Dim PagoEfectivo As Decimal = TxtImporteEfectivo.Text.ToDecimal Dim Mensaje As String = "" + Dim SaldoPendiente As Decimal = VentaActual.Total CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 5, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If CvePrePoliza > 0 Then - If TxtImporteEfectivo.Text.ToDecimal > 0 Then - Mensaje = RegistraIE(13, DdlCuentaEfectivo.SelectedValue.ToEntero, TxtImporteEfectivo.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta) + If PagoEfectivo > 0 Then + If PagoEfectivo > VentaActual.Total Then + TxtCambio.Text = (VentaActual.Total - PagoEfectivo).FormatoNumero + PagoEfectivo = VentaActual.Total + End If + Mensaje = RegistraIE(13, DdlCuentaEfectivo.SelectedValue.ToEntero, PagoEfectivo, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) End If - If TxtImporteCredito.Text.ToDecimal > 0 Then - Mensaje = RegistraIE(12, DdlCuentaTarjetaCredito.SelectedValue.ToEntero, TxtImporteCredito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta) + SaldoPendiente -= PagoEfectivo + If SaldoPendiente > 0 AndAlso TxtImporteCredito.Text.ToDecimal > 0 Then + Mensaje = RegistraIE(12, DdlCuentaTarjetaCredito.SelectedValue.ToEntero, TxtImporteCredito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + PagoEfectivo = TxtImporteCredito.Text.ToDecimal End If - If TxtImporteDebito.Text.ToDecimal > 0 Then - Mensaje = RegistraIE(11, DdlCuentaTarjetaDebito.SelectedValue.ToEntero, TxtImporteDebito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta) + SaldoPendiente -= PagoEfectivo + If SaldoPendiente > 0 AndAlso TxtImporteDebito.Text.ToDecimal > 0 Then + Mensaje = RegistraIE(11, DdlCuentaTarjetaDebito.SelectedValue.ToEntero, TxtImporteDebito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + PagoEfectivo = TxtImporteDebito.Text.ToDecimal End If - If TxtImporteCheque.Text.ToDecimal > 0 Then - Mensaje = RegistraIE(3, DdlCuentaCheque.SelectedValue.ToEntero, TxtImporteCheque.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta) + If SaldoPendiente > 0 AndAlso TxtImporteCheque.Text.ToDecimal > 0 Then + Mensaje = RegistraIE(3, DdlCuentaCheque.SelectedValue.ToEntero, TxtImporteCheque.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2) + PagoEfectivo = TxtImporteCheque.Text.ToDecimal End If Else @@ -194,7 +239,7 @@ Partial Class Ventas_PVCobranza PnlContado.Visible = False ObjConta.Commit() CargaDatos() - Alert("Pago Registrado correctamente.", TipoMensaje.MsgInformacion) + Alert("Pago Registrado correctamente.

Imprimir ticket", TipoMensaje.MsgInformacion) Else ObjConta.RollBack() End If @@ -202,11 +247,11 @@ Partial Class Ventas_PVCobranza End Sub - Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad) As String + Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas) As String Dim Retorno As String = "" Dim CveIEPago As Integer = 0 Dim ErrorConta As Boolean - CveIEPago = ObjIE.AddBancos_IE(CveBancoCuenta, Metodo, Fecha, "-1", VentaActual.ClienteNombre, ImportePago, 1, 1, VentaActual.SerieFolio, "", False, True, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + CveIEPago = ObjIE.AddBancos_IE(CveBancoCuenta, Metodo, Fecha, "-1", VentaActual.ClienteNombre, ImportePago, 1, 1, VentaActual.SerieFolio, "", False, True, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=CveCorte) If CveIEPago > 0 Then Dim Pago As New VentaPago Pago.ImportePagoVenta = ImportePago @@ -220,6 +265,11 @@ Partial Class Ventas_PVCobranza If ErrorConta Then Retorno = "Error en aplicación de pago" End If + Dim MetodoPago As Integer = If(Metodo = 13, 1, If(Metodo = 12, 4, If(Metodo = 11, 5, If(Metodo = 3, 2, 3)))) + If Not ErrorConta AndAlso Not ObjVentas.AddVta_VentaPago(VentaActual.CveVenta, MetodoPago, ImportePago) Then + Retorno = "Error en aplicación de pago.." + ErrorConta = True + End If Else Retorno = "Pago en Bancos no registrado" ErrorConta = True