Exemple #1
0
def clientesmascompradores():
    topClients = None
    dataSalesClients = None
    session = functions.userInSession()
    if session:
        login = functions.messageUserSession(session)
        numberItems = None

        numberForm = forms.numberForm(request.form)
        if request.method == "POST" and numberForm.validate():
            if numberForm.numberItems.data:
                numberItems = int(numberForm.numberItems.data)

            dataSales = functions.readSales()
            positionClient = functions.positionData("CLIENTE")
            positionPrice = functions.positionData("PRECIO")
            topClients = functions.orderClients(dataSales, positionClient,
                                                positionPrice)

            dataSalesClients = functions.dataResult(topClients, numberItems)
            pathcsv = functions.generatecsv(dataSalesClients)

        title = "Clientes mas compradores de este mes"
        return render_template("clientesmascompradores.html",
                               title=title,
                               login=login,
                               dataSalesClients=dataSalesClients,
                               numberItems=numberItems,
                               form=numberForm)
    else:
        return redirect(url_for("index"))
Exemple #2
0
def productosMasVendidos():
    dataSalesProduct = None
    session = functions.userInSession()
    if session:
        login = functions.messageUserSession(session)
        numberItems = None

        numberForm = forms.numberForm(request.form)
        if request.method == "POST" and numberForm.validate():
            numberItems = int(numberForm.numberItems.data)

            dataSales = functions.readSales()
            positionProduct = functions.positionData("PRODUCTO")
            positionAmount = functions.positionData("CANTIDAD")
            positionCode = functions.positionData("CODIGO")
            topProducts = functions.orderProducts(dataSales, positionProduct,
                                                  positionAmount, positionCode)

            dataSalesProduct = functions.dataResult(topProducts, numberItems)
            pathcsv = functions.generatecsv(dataSalesProduct)

        title = "Los productos mas vendidos este mes"
        return render_template("productosmasvendidos.html",
                               title=title,
                               login=login,
                               dataSalesProduct=dataSalesProduct,
                               numberItems=numberItems,
                               form=numberForm)
    else:
        return redirect(url_for("index"))
Exemple #3
0
def ventas(client=None):
    session = functions.userInSession()
    if session:
        login = functions.messageUserSession(session)

        dataSales = functions.readSales()
        countSales = len(dataSales)

        pathcsv = functions.generatecsv(dataSales)

        title = "Consulta las ventas del mes"
        return render_template("ventas.html",
                               title=title,
                               dataSales=dataSales,
                               countSales=countSales,
                               login=login,
                               pathcsv=pathcsv)
    else:
        return redirect(url_for("index"))
Exemple #4
0
def clientesPorProducto(product=None):
    productSearch = None
    positionProduct = None
    listProducts = None
    pathcsv = None
    dataSalesProduct = None
    session = functions.userInSession()
    if session:
        login = functions.messageUserSession(session)

        dataSales = functions.readSales()
        product_form = forms.ProductForm(request.form)

        if request.method == "POST" and product_form.validate():
            productSearchOriginal = product_form.product.data
            productSearch = productSearchOriginal.upper()
            positionProduct = functions.positionData("PRODUCTO")
            listProducts = functions.searchData(productSearch, dataSales,
                                                positionProduct)
            if len(listProducts) == 0:
                listProducts = None

        if product:
            dataSalesProduct = functions.dataResultSerch(dataSales, product)
            pathcsv = functions.generatecsv(dataSalesProduct)

        title = "Consulta los clientes que compraron un producto"
        return render_template("clientes_por_producto.html",
                               product=product,
                               form=product_form,
                               title=title,
                               login=login,
                               dataSalesProduct=dataSalesProduct,
                               option=productSearch,
                               listProducts=listProducts,
                               pathcsv=pathcsv)
    else:
        return redirect(url_for("index"))
Exemple #5
0
def productosPorClientes(client=None):
    clientSearch = None
    positionClient = None
    listClients = None
    pathcsv = None
    dataSalesClient = None
    session = functions.userInSession()
    if session:
        login = functions.messageUserSession(session)

        dataSales = functions.readSales()
        client_form = forms.ClientsForm(request.form)

        if request.method == "POST" and client_form.validate():
            clientSearchOriginal = client_form.client.data
            clientSearch = clientSearchOriginal.upper()
            positionClient = functions.positionData("CLIENTE")
            listClients = functions.searchData(clientSearch, dataSales,
                                               positionClient)
            if len(listClients) == 0:
                listClients = None

        if client:
            dataSalesClient = functions.dataResultSerch(dataSales, client)
            pathcsv = functions.generatecsv(dataSalesClient)

        title = "Consulta las compras realizadas por cliente"
        return render_template("productos_por_cliente.html",
                               client=client,
                               form=client_form,
                               title=title,
                               login=login,
                               dataSalesClient=dataSalesClient,
                               option=clientSearch,
                               listClients=listClients,
                               pathcsv=pathcsv)
    else:
        return redirect(url_for("index"))