From 54a4d9536f79008479ef41bfc328038945436a7b Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Fri, 25 Jul 2008 04:26:08 +0000 Subject: [PATCH] Add split function that redistributes old percentages with new total --- bluechips/model/expenditure.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bluechips/model/expenditure.py b/bluechips/model/expenditure.py index 009ba3a..acd7785 100644 --- a/bluechips/model/expenditure.py +++ b/bluechips/model/expenditure.py @@ -28,6 +28,16 @@ class Expenditure(object): split_percentage = Decimal(100) / Decimal(residents.count()) self.split(dict((resident, split_percentage) for resident in residents)) + def update_split(self): + """ + Re-split an expenditure using the same percentages as what is + currently in the database + """ + + old_splits = meta.Session.query(Split).filter(Split.expenditure==self) + split_dict = dict((s.user, Decimal(int(s.share))) for s in old_splits) + self.split(split_dict) + def split(self, split_dict): """ Split up an expenditure. -- 2.45.2