Exemple #1
0
def formBusquedaProducto():
    formulario = ProductoForm()
    datosDeVentas = funciones.lecturaDeVentas()
    if len(datosDeVentas) == 1:
        return render_template('errores/errores.html', lista=datosDeVentas)
    posicionDeCliente = funciones.posicionDelDato('CLIENTE')
    posicionDePrecio = funciones.posicionDelDato('PRECIO')
    posicionDeCantidad = funciones.posicionDelDato('CANTIDAD')
    posicionDeCodigo = funciones.posicionDelDato('CODIGO')
    validaciones = funciones.validaciones(datosDeVentas, posicionDePrecio,
                                          posicionDeCantidad, posicionDeCodigo)
    if len(validaciones):
        return render_template('errores/errores.html', lista=validaciones)
    if formulario.validate_on_submit():
        datoIngresado = formulario.producto.data
        producto = datoIngresado.upper()
        posicionDelDato = funciones.posicionDelDato('PRODUCTO')
        listaDeProductos = funciones.buscarDatoEspecifico(
            producto, datosDeVentas, posicionDelDato)
        return render_template(
            'clientes-por-producto/formulario_buscar_producto.html',
            form=formulario,
            buscarProducto=producto,
            lista=listaDeProductos)

        if len(listaDeProductos):
            listaDeProductos = None
        else:
            return redirect(
                url_for('tablaClientesPorProducto', producto=producto))
    return render_template(
        'clientes-por-producto/formulario_buscar_producto.html',
        form=formulario)
Exemple #2
0
def mejoresCliente():
    datosDeVentas = funciones.lecturaDeVentas()
    if len(datosDeVentas) == 1:
        return render_template('errores/errores.html', lista=datosDeVentas)
    posicionDeCliente = funciones.posicionDelDato('CLIENTE')
    posicionDePrecio = funciones.posicionDelDato('PRECIO')
    posicionDeCantidad = funciones.posicionDelDato('CANTIDAD')
    posicionDeCodigo = funciones.posicionDelDato('CODIGO')
    validaciones = funciones.validaciones(datosDeVentas, posicionDePrecio,
                                          posicionDeCantidad, posicionDeCodigo)
    if len(validaciones):
        return render_template('errores/errores.html', lista=validaciones)
    else:
        sumaDePrecios = funciones.clientesQueMasCompraron(
            datosDeVentas, posicionDeCliente, posicionDePrecio)
        tablaCompleta = funciones.ordenarTablaDescendente(
            sumaDePrecios, 'CLIENTE', 'PRECIO')
        return render_template('mejores-clientes/mejores-clientes.html',
                               tabla=tablaCompleta)
Exemple #3
0
def productosMasVendidos():
    datosDeVentas = funciones.lecturaDeVentas()
    if len(datosDeVentas) == 1:
        return render_template('errores/errores.html', lista=datosDeVentas)
    posicionDeProducto = funciones.posicionDelDato('PRODUCTO')
    posicionDeCantidad = funciones.posicionDelDato('CANTIDAD')
    posicionDePrecio = funciones.posicionDelDato('PRECIO')
    posicionDeCodigo = funciones.posicionDelDato('CODIGO')
    validaciones = funciones.validaciones(datosDeVentas, posicionDePrecio,
                                          posicionDeCantidad, posicionDeCodigo)
    if len(validaciones):
        return render_template('errores/errores.html', lista=validaciones)
    else:
        sumaDeProductos = funciones.productosMasVendidos(
            datosDeVentas, posicionDeProducto, posicionDeCantidad)
        tablaCompleta = funciones.ordenarTablaDescendente(
            sumaDeProductos, 'PRODUCTO', 'CANTIDAD')
        return render_template(
            'productos-mas-vendidos/productos_mas_vendidos.html',
            tabla=tablaCompleta)
Exemple #4
0
def formCargarVenta():
    formulario = VentaForm()
    datosIngresados = []
    cont = 1

    posicionDeProducto = funciones.posicionDelDato('PRODUCTO')
    posicionDeCliente = funciones.posicionDelDato('CLIENTE')
    posicionDePrecio = funciones.posicionDelDato('PRECIO')
    posicionDeCantidad = funciones.posicionDelDato('CANTIDAD')
    posicionDeCodigo = funciones.posicionDelDato('CODIGO')

    if formulario.validate_on_submit():
        datoDeProducto = formulario.producto.data.upper()
        datoDeCliente = formulario.cliente.data.upper()
        datoDePrecio = formulario.precio.data
        datoDeCantidad = formulario.cantidad.data
        datoDeCodigo = formulario.codigo.data.upper()

        for caracter in datoDeCodigo:
            if cont <= 3:
                if caracter.isdigit():
                    return render_template('cargar-venta/codigoerror.html')
                    cont = cont + 1
            elif cont >= 4:
                if caracter.isalpha():
                    return render_template('cargar-venta/codigoerror.html')
            cont = cont + 1
        datosIngresados = [
            datoDeCodigo, datoDeProducto, datoDeCliente, datoDeCantidad,
            datoDePrecio
        ]
        resultado = funciones.escrituraDeVentas(datosIngresados)
        return render_template('lista_completa.html',
                               ventas=funciones.lecturaDeVentas())

    return render_template('cargar-venta/formulario_cargar_venta.html',
                           cargarVenta=datosIngresados,
                           form=formulario)
Exemple #5
0
def formBusquedaCliente():
    formulario = ClienteForm()
    datosDeVentas = funciones.lecturaDeVentas()
    if len(datosDeVentas) == 1:
        return render_template('errores/errores.html', lista=datosDeVentas)

    posicionDeCliente = funciones.posicionDelDato('CLIENTE')
    posicionDePrecio = funciones.posicionDelDato('PRECIO')
    posicionDeCantidad = funciones.posicionDelDato('CANTIDAD')
    posicionDeCodigo = funciones.posicionDelDato('CODIGO')
    validaciones = funciones.validaciones(datosDeVentas, posicionDePrecio,
                                          posicionDeCantidad, posicionDeCodigo)

    if len(validaciones):
        return render_template('errores/errores.html', lista=validaciones)

    if formulario.validate_on_submit():
        datoIngresado = formulario.cliente.data

        cliente = datoIngresado.upper()
        posicionDelDato = funciones.posicionDelDato('CLIENTE')

        listaDeClientes = funciones.buscarDatoEspecifico(
            cliente, datosDeVentas, posicionDelDato)
        return render_template(
            'productos-por-cliente/formulario_buscar_cliente.html',
            form=formulario,
            buscarCliente=cliente,
            lista=listaDeClientes)
        if len(listaDeClientes) == 0:
            listaDeClientes = None
        else:
            return redirect(url_for('tablaProductoPorCliente',
                                    cliente=cliente))
    return render_template(
        'productos-por-cliente/formulario_buscar_cliente.html',
        form=formulario)