- offers = [o for o in Offer.objects.all() if o.state() == 'lose' and o.sum()]
- amount = sum(o.sum() for o in offers) - sum(o.amount for o in Spent.objects.all())
+ offers = []
+ for o in Offer.objects.all():
+ if o.state() == 'lose':
+ o.wlfund = o.sum()
+ if o.wlfund > 0:
+ offers.append(o)
+ elif o.state() == 'win':
+ o.wlfund = o.sum() - o.target
+ if o.wlfund > 0:
+ offers.append(o)
+ amount = sum(o.wlfund for o in offers) - sum(o.amount for o in Spent.objects.all())