Merge pull request #429 from grant-project/proposal-funded-precision
Proposal funding precision
This commit is contained in:
commit
71990d9dcd
|
@ -1,5 +1,5 @@
|
|||
import datetime
|
||||
from decimal import Decimal
|
||||
from decimal import Decimal, ROUND_DOWN
|
||||
from functools import reduce
|
||||
|
||||
from flask import current_app
|
||||
|
@ -611,7 +611,6 @@ class Proposal(db.Model):
|
|||
|
||||
@hybrid_property
|
||||
def funded(self):
|
||||
|
||||
target = Decimal(self.target)
|
||||
# apply matching multiplier
|
||||
funded = Decimal(self.contributed) * Decimal(1 + self.contribution_matching)
|
||||
|
@ -620,9 +619,9 @@ class Proposal(db.Model):
|
|||
funded = funded + Decimal(self.contribution_bounty)
|
||||
# if funded > target, just set as target
|
||||
if funded > target:
|
||||
return str(target)
|
||||
return str(target.quantize(Decimal('.001'), rounding=ROUND_DOWN))
|
||||
|
||||
return str(funded)
|
||||
return str(funded.quantize(Decimal('.001'), rounding=ROUND_DOWN))
|
||||
|
||||
@hybrid_property
|
||||
def is_staked(self):
|
||||
|
|
Loading…
Reference in New Issue