示例#1
0
文件: views.py 项目: kepkin/easyfin
def lala(request):
    data = []
    for o in RegularExpenses.objects.all():
        c = o.money.get_income(Period.this_month())
        data.append("{0}.{1}".format(*c))
    json_data = serializers.serialize("json", RegularExpenses.objects.all())
    return HttpResponse(json_data, content_type="application/json")
示例#2
0
文件: views.py 项目: kepkin/easyfin
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")
示例#3
0
文件: views.py 项目: kepkin/easyfin
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")
示例#4
0
文件: views.py 项目: kepkin/easyfin
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")
示例#5
0
文件: views.py 项目: kepkin/easyfin
def debug(request):
    p = Period.this_month()
    mh = MoneyHolder.objects.get(pk=2)
    data = mh.get_income(p)
    return HttpResponse(json.dumps(data), content_type="application/json")