Esempio n. 1
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.'}
Esempio n. 2
0
def spend_view(request):
    if not request.session.get('admin'):
        return HTTPFound(location=route_url('home', request))
    today = datetime.date.today()
    period_id = request.GET.get('period', None)
    if period_id:
        dbsession = DBSession()
        expenses = dbsession.query(Expense).\
            filter(Expense.period_id==int(period_id)).\
            filter(Expense.date==today).all()

        period = Period.get_by_id(period_id)
        expenses_sum = period.get_expenses(today)
        return {'expenses': expenses, 'expenses_sum': expenses_sum}

    return HTTPFound(location=route_url('app', request))
Esempio n. 3
0
def spend_view(request):
    if not request.session.get('admin'):
        return HTTPFound(location=route_url('home', request))
    today = datetime.date.today()
    period_id = request.GET.get('period', None)
    if period_id:
        dbsession = DBSession()
        expenses = dbsession.query(Expense).\
            filter(Expense.period_id==int(period_id)).\
            filter(Expense.date==today).all()

        period = Period.get_by_id(period_id)
        expenses_sum = period.get_expenses(today)
        return {'expenses': expenses,
                'expenses_sum': expenses_sum}

    return HTTPFound(location=route_url('app', request))
Esempio n. 4
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()
Esempio n. 5
0
def active_period(request):
    if 'period' in request.POST:
        period = Period.get_by_id(request.POST['period'])
        period.make_active()
    return {'error': 'Labas'}
Esempio n. 6
0
def active_period(request):
    if 'period' in request.POST:
        period = Period.get_by_id(request.POST['period'])
        period.make_active()
    return {'error':'Labas'}