mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 04:31:49 +02:00
fixed calculation issue (archived bills are no longer calculated)
This commit is contained in:
parent
28f99c9506
commit
b9d705da79
1 changed files with 7 additions and 6 deletions
|
@ -114,12 +114,13 @@ class Project(db.Model):
|
|||
balances, should_pay, should_receive = (defaultdict(int) for time in (1, 2, 3))
|
||||
|
||||
for bill in self.get_bills_unordered().all():
|
||||
should_receive[bill.payer.id] += bill.converted_amount
|
||||
total_weight = sum(ower.weight for ower in bill.owers)
|
||||
for ower in bill.owers:
|
||||
should_pay[ower.id] += (
|
||||
ower.weight * bill.converted_amount / total_weight
|
||||
)
|
||||
if not bill.archive:
|
||||
should_receive[bill.payer.id] += bill.converted_amount
|
||||
total_weight = sum(ower.weight for ower in bill.owers)
|
||||
for ower in bill.owers:
|
||||
should_pay[ower.id] += (
|
||||
ower.weight * bill.converted_amount / total_weight
|
||||
)
|
||||
|
||||
for person in self.members:
|
||||
balance = should_receive[person.id] - should_pay[person.id]
|
||||
|
|
Loading…
Reference in a new issue