check calcs of grant totals for proposals that are over-funded

This commit is contained in:
Aaron 2019-04-16 15:53:19 -05:00
parent df4d892d3b
commit 96b9bc3c49
No known key found for this signature in database
GPG Key ID: 3B5B7597106F0A0E
1 changed files with 4 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from datetime import datetime
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_DOWN
from functools import reduce
from flask import Blueprint, request
@ -773,7 +773,7 @@ def financials():
}
def add_str_dec(a: str, b: str):
return str(Decimal(a) + Decimal(b))
return str((Decimal(a) + Decimal(b)).quantize(Decimal('0.001'), rounding=ROUND_HALF_DOWN))
proposals = Proposal.query.all()
@ -782,13 +782,13 @@ def financials():
if p.stage in [ProposalStage.WIP, ProposalStage.COMPLETED]:
# matching
matching = Decimal(p.contributed) * Decimal(p.contribution_matching)
remaining = Decimal(p.target) - Decimal(p.contributed)
remaining = max(Decimal(p.target) - Decimal(p.contributed), Decimal('0.0'))
if matching > remaining:
matching = remaining
# bounty
bounty = Decimal(p.contribution_bounty)
remaining = Decimal(p.target) - (matching + Decimal(p.contributed))
remaining = max(Decimal(p.target) - (matching + Decimal(p.contributed)), Decimal('0.0'))
if bounty > remaining:
bounty = remaining