Exemplo n.º 1
0
def add_income(request):
    dbsession = DBSession()
    if 'amount' and 'name' in request.POST:
        amount = request.POST['amount']
        name = request.POST['name']
        income = Income(name, float(amount))
        dbsession.add(income)
        return HTTPFound(location=route_url('settings', request))

    return {'error': 'Please enter income name and amount.'}
Exemplo n.º 2
0
def add_periodic_expense(request):
    dbsession = DBSession()
    if 'amount' and 'name' in request.POST:
        amount = request.POST['amount']
        name = request.POST['name']
        expense = PeriodicExpense(name, float(amount))
        dbsession.add(expense)
        return HTTPFound(location=route_url('settings', request))

    return {'error': 'Please enter periodic expence name and amount.'}
Exemplo n.º 3
0
def add_periodic_expense(request):
    dbsession = DBSession()
    if 'amount' and 'name' in request.POST:
        amount = request.POST['amount']
        name = request.POST['name']
        expense = PeriodicExpense(name, float(amount))
        dbsession.add(expense)
        return HTTPFound(location=route_url('settings', request))

    return {'error':'Please enter periodic expence name and amount.'}
Exemplo n.º 4
0
def add_income(request):
    dbsession = DBSession()
    if 'amount' and 'name' in request.POST:
        amount = request.POST['amount']
        name = request.POST['name']
        income = Income(name, float(amount))
        dbsession.add(income)
        return HTTPFound(location=route_url('settings', request))

    return {'error':'Please enter income name and amount.'}
Exemplo n.º 5
0
def add_period(request):
    dbsession = DBSession()
    if 'period' in request.POST:
        period_name = request.POST['period']
        today = datetime.date.today()
        month = datetime.timedelta(days=30)
        period = Period(period_name, today, today + month)
        dbsession.add(period)
        return HTTPFound(location=route_url('settings', request))

    return {'error': 'Please enter period name.'}
Exemplo n.º 6
0
def add_period(request):
    dbsession = DBSession()
    if 'period' in request.POST:
        period_name = request.POST['period']
        today = datetime.date.today()
        month = datetime.timedelta(days=30)
        period = Period(period_name, today, today+month)
        dbsession.add(period)
        return HTTPFound(location=route_url('settings', request))

    return {'error':'Please enter period name.'}
Exemplo n.º 7
0
def add_spending(request):
    dbsession = DBSession()
    if 'amount' and 'name' in request.POST:
        amount = request.POST['amount']
        name = request.POST['name']

        #TODO Add amount validation.

        expense = Expense(name, float(amount))
        dbsession.add(expense)

        q = {'period': 1}
        return HTTPFound(location=route_url('spend', request, _query=q))

    return {'error': 'Please enter spending name and spended amount.'}
Exemplo n.º 8
0
def add_spending(request):
    dbsession = DBSession()
    if 'amount' and 'name' in request.POST:
        amount = request.POST['amount']
        name = request.POST['name']

        #TODO Add amount validation.

        expense = Expense(name, float(amount))
        dbsession.add(expense)

        q = {'period': 1}
        return HTTPFound(location=route_url('spend', request, _query=q))

    return {'error':'Please enter spending name and spended amount.'}
Exemplo n.º 9
0
def populate():
    session = DBSession()
    day = datetime.timedelta(days=1)
    month = datetime.timedelta(days=30)
    today = datetime.date.today()
    tomorrow = today + day

    default = Period('Default', today, today + month)
    session.add(default)

    #Default expences
    apartment = PeriodicExpense('Apartment rent', 300.00)
    session.add(apartment)

    #Incomes
    salary = Income('Salary', 1000.00)
    session.add(salary)

    session.flush()
    transaction.commit()
Exemplo n.º 10
0
def populate():
    session = DBSession()
    day = datetime.timedelta(days=1)
    month = datetime.timedelta(days=30)
    today = datetime.date.today()
    tomorrow = today+day

    default = Period('Default', today, today+month)
    session.add(default)

    #Default expences
    apartment = PeriodicExpense('Apartment rent', 300.00)
    session.add(apartment)

    #Incomes
    salary = Income('Salary', 1000.00)
    session.add(salary)

    session.flush()
    transaction.commit()