Beispiel #1
0
def index():
    cash_in_hand = document().cash_in_hand.get_balance()

    recievable_cash = 0
    for a in accounts().accounts.values():
        b = a.get_balance()
        if b < 0:
            recievable_cash += abs(b)

    income = 0
    expenses = 0
    profit = 0
    for p in inventory().products.values():
        expenses += p.total_purchase()
        income += p.income.get_balance()
        profit += p.profit.get_balance()

    template_response("/page/index.mako",
        comment = document().comment,
        date = document().date,
        income = income,
        expenses = expenses,
        recievable_cash = recievable_cash,
        cash_in_hand = cash_in_hand,
        profit = profit

    )
Beispiel #2
0
def new_form():
    accounts_list = [(a.id, a.name) for a in accounts().list_by_name()]
    products = [(a.id, a.name, a.get_fixedprice(1)) for a in inventory().list_by_name()]

    template_response("/page/usage/form.mako",
        accounts = accounts_list,
        products = products,
    )
Beispiel #3
0
def update_usage_from_form():
    for p in inventory().list_by_name():
        try:
            stock = int(local.request.form.get("stock_%s" % (p.id, ), "0"))
        except:
            stock = 0
        p.stock = stock

        profit = parsenumber(local.request.form.get("profit_%s" % (p.id, ), "0"))

        usage().set_profit(p.id, profit or 0)

        for a in accounts().list_by_name():
            try:
                amount = int(local.request.form.get("usage_%s_%s" % (a.id, p.id), "0"))
            except:
                amount = 0
            usage().update(a.id, p.id, amount)