from app import db
from app.mod_auth.model import User

class Category(db.Document):
    # The name of the category.
    name = db.StringField(required = True)

class Entry(db.Document):
    # The amount of the entry.
    amount = db.DecimalField(precision = 2, required = True)

    # A short description for the entry.
    description = db.StringField(required = True)

    # The owner of the entry.
    # Should the owner be deleted, we also want to delete all of his entries.
    owner = db.ReferenceField(User, reverse_delete_rule = db.CASCADE, required = True)

    # The category of this entry.
    category = db.ReferenceField(Category, required = True)

class CategoryBudget(db.Document):
    # The amount of the budget.
    amount = db.DecimalField(precision = 2, required = True)

    # The category.
    category = db.ReferenceField(Category, required = True)

def sumEntries():
    return sum([entry.amount for entry in Entry.objects if entry.amount > 0])

@@ -160,21 +160,22 @@
 %0A%0Aclass 
-Entry
+Income
 (db.Docu
@@ -358,32 +358,32 @@
 quired = True)%0A%0A
-
     # The owner 
@@ -653,24 +653,532 @@
 ed = True)%0A%0A
+class Expense(db.Document):%0A    # The amount of the entry.%0A    amount = db.DecimalField(precision = 2, required = True)%0A%0A    # A short description for the expense.%0A    description = db.StringField(required = True)%0A%0A    # The owner of the expense.%0A    # Should the owner be deleted, we also want to delete all of his entries.%0A    owner = db.ReferenceField(User, reverse_delete_rule = db.CASCADE, required = True)%0A%0A    # The category of this entry.%0A    category = db.ReferenceField(Category, required = True)%0A%0A
 class Catego

Split Entry into Income and Expense schemes