Example #1
0
def newExpense(request):
    amount, cents = request.POST['plan'].split(".")
    amount = int(amount)
    cents = int(cents)
    month = int(request.POST['month'])
    year = int(request.POST['year'])
    
    per = Period.specific_month(year, month)
    m = MoneyHolder.objects.create(name=request.POST['name'], initial=0, amount=0, cents=0)
    p = RegularExpenses.objects.create(money=m, amount=amount, cents=cents, start=per.date_from, stop=None)
    
    return HttpResponse("", content_type="application/json")
Example #2
0
def getExpenses(request):
    data = []
    
    month = int(request.POST['month'])
    year = int(request.POST['year'])
    
    p = Period.specific_month(year, month)
    for i in RegularExpenses.actual(p):
        plan = "{0}.{1}".format(i.amount, i.cents)
        real = "{0}.{1}".format(*i.money.get_income(p))
        data.append({'pk': i.pk, 'name': i.money.name, 'plan': plan, 'real': real})
    return HttpResponse(json.dumps(data), content_type="application/json")
Example #3
0
def updateExpense(request):
    amount, cents = request.POST['plan'].split(".")
    amount = int(amount)
    cents = int(cents)
    month = int(request.POST['month'])
    year = int(request.POST['year'])
    
    data = RegularExpenses.objects.get(pk=request.POST['pk'])
    
    per = Period.specific_month(year, month)
    data.Update(amount, cents, per.date_from)
    
    return HttpResponse("", content_type="application/json")