コード例 #1
0
        private void BtnFacturar_Click(object sender, EventArgs e)
        {
            if (_cliente == null)
            {
                _messageBoxDisplayService.ShowError(Resources.ErrorMessageSeleccionarCliente);
                return;
            }

            if (!UcTitulosVenta.Titulos.Any())
            {
                _messageBoxDisplayService.ShowError(Resources.ErrorMessageVentaSinLibros);
                return;
            }

            if (!UcTotalesVenta.Validar())
            {
                return;
            }

            if (UcBuscadorCliente.CondicionVentaSeleccionada == CondicionVentaEnum.CuentaCorriente
                    && UcTotalesVenta.SubTotal.Value <= UcTotalesVenta.Descuento.GetValueOrDefault())
            {
                _messageBoxDisplayService.ShowError("El descuento no puede superar al importe total de la venta");
                return;
            }

            if (UcBuscadorCliente.CondicionVentaSeleccionada == CondicionVentaEnum.CuentaCorriente
                    && UcCuentaCorrienteInfo.Cuotas == null)
            {
                _messageBoxDisplayService.ShowError("Debe indicar la cantidad de cuotas del plan");
                return;
            }

            if (UcTitulosVenta.Titulos.Count > Context.SucursalActual.MaximoNroLineasPorVenta)
            {
                _messageBoxDisplayService.ShowError("Se ha superado el límite máximo de líneas por venta.");
                return;
            }

            //Ahora calculo el porcentaje de descuento para ver si no supera el maximo permitido
            //var porcentaje = (UcTotalesVenta.Descuento.GetValueOrDefault() * 100) / UcTotalesVenta.SubTotal.Value;
            var porcentaje = UcTotalesVenta.Descuento.GetValueOrDefault();
            var porcentajeNoAutorizado = porcentaje > Context.SucursalActual.MaximoPorcentajeDescuento;

            var importeNoAutorizado = UcTotalesVenta.SubTotal.Value >= Context.SucursalActual.MaximoImporteVenta;
            if (UcBuscadorCliente.CondicionVentaSeleccionada == CondicionVentaEnum.Contado)
                importeNoAutorizado = false;


            if (porcentajeNoAutorizado || importeNoAutorizado)
            {
                var operador = this.ObtenerOperadorAdministrador();
                if (operador == null)
                {
                    return;
                }
            }

            //Vuelto
            if (ChkVuelto.IsChecked && UcTotalesVenta.HayPagoEnEfectivo)
            {
                using (var frmVuelto = new FrmVuelto())
                {
                    frmVuelto.APagar = UcTotalesVenta.TotalEnEfectivo;
                    frmVuelto.Paga = UcTotalesVenta.TotalEnEfectivo;
                    frmVuelto.ShowDialog();
                }
            }

            RealizarVenta();
        }
コード例 #2
0
        private void BtnFacturar_Click(object sender, EventArgs e)
        {
            if (_cliente == null)
            {
                _messageBoxDisplayService.ShowError(Resources.ErrorMessageSeleccionarCliente);
                return;
            }

            if (!UcTitulosVenta.Titulos.Any())
            {
                _messageBoxDisplayService.ShowError(Resources.ErrorMessageVentaSinLibros);
                return;
            }

            if (!UcTotalesVenta.Validar())
            {
                return;
            }

            if (UcBuscadorCliente.CondicionVentaSeleccionada == CondicionVentaEnum.CuentaCorriente &&
                UcTotalesVenta.SubTotal.Value <= UcTotalesVenta.Descuento.GetValueOrDefault())
            {
                _messageBoxDisplayService.ShowError("El descuento no puede superar al importe total de la venta");
                return;
            }

            if (UcBuscadorCliente.CondicionVentaSeleccionada == CondicionVentaEnum.CuentaCorriente &&
                UcCuentaCorrienteInfo.Cuotas == null)
            {
                _messageBoxDisplayService.ShowError("Debe indicar la cantidad de cuotas del plan");
                return;
            }

            if (UcTitulosVenta.Titulos.Count > Context.SucursalActual.MaximoNroLineasPorVenta)
            {
                _messageBoxDisplayService.ShowError("Se ha superado el límite máximo de líneas por venta.");
                return;
            }

            //Ahora calculo el porcentaje de descuento para ver si no supera el maximo permitido
            //var porcentaje = (UcTotalesVenta.Descuento.GetValueOrDefault() * 100) / UcTotalesVenta.SubTotal.Value;
            var porcentaje             = UcTotalesVenta.Descuento.GetValueOrDefault();
            var porcentajeNoAutorizado = porcentaje > Context.SucursalActual.MaximoPorcentajeDescuento;

            var importeNoAutorizado = UcTotalesVenta.SubTotal.Value >= Context.SucursalActual.MaximoImporteVenta;

            if (UcBuscadorCliente.CondicionVentaSeleccionada == CondicionVentaEnum.Contado)
            {
                importeNoAutorizado = false;
            }


            if (porcentajeNoAutorizado || importeNoAutorizado)
            {
                var operador = this.ObtenerOperadorAdministrador();
                if (operador == null)
                {
                    return;
                }
            }

            //Vuelto
            if (ChkVuelto.IsChecked && UcTotalesVenta.HayPagoEnEfectivo)
            {
                using (var frmVuelto = new FrmVuelto())
                {
                    frmVuelto.APagar = UcTotalesVenta.TotalEnEfectivo;
                    frmVuelto.Paga   = UcTotalesVenta.TotalEnEfectivo;
                    frmVuelto.ShowDialog();
                }
            }

            RealizarVenta();
        }
コード例 #3
0
        private void BtnRendirConsignacion_Click(object sender, EventArgs e)
        {
            if (UcTitulosConsignacionVenta.Titulos.Sum(t => t.CntARendir) == 0 && UcTitulosConsignacionVenta.Titulos.Sum(t => t.CntADevolver) == 0)
            {
                _messageBoxDisplayService.ShowError("Debe seleccionar libros a facturar");
                return;
            }

            if (_cliente == null)
            {
                _messageBoxDisplayService.ShowError(Resources.ErrorMessageSeleccionarCliente);
                return;
            }

            if (!UcTitulosConsignacionVenta.Titulos.Any())
            {
                _messageBoxDisplayService.ShowError(Resources.ErrorMessageVentaSinLibros);
                return;
            }

            if (!UcTotalesVenta.Validar())
            {
                return;
            }

            if (UcBuscadorConsignacion.CondicionVentaSeleccionada == CondicionVentaEnum.CuentaCorriente &&
                UcTotalesVenta.SubTotal.HasValue &&
                UcTotalesVenta.SubTotal.Value > 0 && 
                UcTotalesVenta.SubTotal.Value <= UcTotalesVenta.Descuento.GetValueOrDefault())
            {
                _messageBoxDisplayService.ShowError("El descuento no puede superar al importe total de la venta");
                return;
            }

            if (UcBuscadorConsignacion.CondicionVentaSeleccionada == CondicionVentaEnum.CuentaCorriente
                    && UcCuentaCorrienteInfo.Cuotas == null)
            {
                _messageBoxDisplayService.ShowError("Debe indicar la cantidad de cuotas del plan");
                return;
            }

            if (UcTitulosConsignacionVenta.Titulos.Count > Context.SucursalActual.MaximoNroLineasPorVenta)
            {
                _messageBoxDisplayService.ShowError("Se ha superado el límite máximo de líneas por venta.");
                return;
            }


            //Ahora calculo el porcentaje de descuento para ver si no supera el maximo permitido
            //var porcentaje = (UcTotalesVenta.Descuento.GetValueOrDefault() * 100) / UcTotalesVenta.SubTotal.Value;
            var porcentaje = UcTotalesVenta.Descuento.GetValueOrDefault();
            var porcentajeNoAutorizado = porcentaje > Context.SucursalActual.MaximoPorcentajeDescuento;

            var importeNoAutorizado = UcTotalesVenta.SubTotal.Value >= Context.SucursalActual.MaximoImporteVenta;
            if (UcBuscadorConsignacion.CondicionVentaSeleccionada == CondicionVentaEnum.Contado)
                importeNoAutorizado = false;


            if (porcentajeNoAutorizado || importeNoAutorizado)
            {
                using (var login = FormFactory.Create<FrmLogin>())
                {
                    login.RolesAceptados = new List<string>() { "Admin", "SuperAdmin" };
                    login.CambiarIdentity = false;
                    if (login.ShowDialog() != DialogResult.OK)
                    {
                        //_messageBoxDisplayService.ShowError(Resources.ErrorMessageVentaSinLibros);
                        return;
                    }
                }
            }

            //Vuelto
            if (ChkVuelto.IsChecked)
            {
                decimal? efectivo = 0;
                foreach (VentaPago pago in this.UcTotalesVenta.Pagos)
                {
                    if (pago.TipoPago == FormaPago.Efectivo)
                        efectivo = pago.Importe;
                }

                using (var frmVuelto = new FrmVuelto())
                {
                    frmVuelto.APagar = efectivo;
                    frmVuelto.Paga = efectivo;
                    frmVuelto.ShowDialog();
                }
            }

            RealizarVenta();
        }