aboutsummaryrefslogtreecommitdiff
path: root/budget/models.py
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2011-10-18 23:26:13 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2011-10-18 23:26:13 +0200
commit6f4f04b11756086fa4ace404d4f00c856dc6f157 (patch)
treec5cb1261cb570a6ef59e0fb76279dc2949196eda /budget/models.py
parent4e1819523f50114ce5e3f0524fc27eb85701da37 (diff)
downloadihatemoney-mirror-6f4f04b11756086fa4ace404d4f00c856dc6f157.zip
ihatemoney-mirror-6f4f04b11756086fa4ace404d4f00c856dc6f157.tar.gz
ihatemoney-mirror-6f4f04b11756086fa4ace404d4f00c856dc6f157.tar.bz2
Document the API. Fix #46
Diffstat (limited to 'budget/models.py')
-rw-r--r--budget/models.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/budget/models.py b/budget/models.py
index e5d5ea9..152ad34 100644
--- a/budget/models.py
+++ b/budget/models.py
@@ -12,7 +12,7 @@ db = SQLAlchemy()
class Project(db.Model):
_to_serialize = ("id", "name", "password", "contact_email",
- "members", "active_members")
+ "members", "active_members", "balance")
id = db.Column(db.String, primary_key=True)
@@ -25,7 +25,8 @@ class Project(db.Model):
def active_members(self):
return [m for m in self.members if m.activated]
- def get_balance(self):
+ @property
+ def balance(self):
balances, should_pay, should_receive = defaultdict(int), defaultdict(int), defaultdict(int)
@@ -39,7 +40,7 @@ class Project(db.Model):
should_receive[bill.payer] += bill.pay_each()
for person in self.members:
- balances[person] = round(should_receive[person] - should_pay[person], 2)
+ balances[person.id] = round(should_receive[person] - should_pay[person], 2)
return balances