fixed calculation issue (archived bills are no longer calculated)

This commit is contained in:
Maimoonah Almashhadani 2022-11-11 14:16:34 +03:00
parent 28f99c9506
commit b9d705da79

View file

@ -114,12 +114,13 @@ class Project(db.Model):
balances, should_pay, should_receive = (defaultdict(int) for time in (1, 2, 3)) balances, should_pay, should_receive = (defaultdict(int) for time in (1, 2, 3))
for bill in self.get_bills_unordered().all(): for bill in self.get_bills_unordered().all():
should_receive[bill.payer.id] += bill.converted_amount if not bill.archive:
total_weight = sum(ower.weight for ower in bill.owers) should_receive[bill.payer.id] += bill.converted_amount
for ower in bill.owers: total_weight = sum(ower.weight for ower in bill.owers)
should_pay[ower.id] += ( for ower in bill.owers:
ower.weight * bill.converted_amount / total_weight should_pay[ower.id] += (
) ower.weight * bill.converted_amount / total_weight
)
for person in self.members: for person in self.members:
balance = should_receive[person.id] - should_pay[person.id] balance = should_receive[person.id] - should_pay[person.id]