Merge branch 'develop' into admin-notifications

This commit is contained in:
Daniel Ternyak 2019-04-28 17:32:04 -05:00 committed by GitHub
commit b39e6098c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 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

View File

@ -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
@ -623,7 +623,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)
@ -632,9 +631,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):

View File

@ -4,7 +4,7 @@
Flask==1.0.2
MarkupSafe==1.0
Werkzeug==0.14.1
Jinja2==2.10
Jinja2==2.10.1
itsdangerous==0.24
click>=5.0