Skip to content

Commit acc3f56

Browse files
Merge pull request #311 from jeffreykirchner/dev
update recruiter payments file with round_up.
2 parents 7bec306 + 1a2408a commit acc3f56

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

main/globals/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
build globals
33
'''
44
from .round_half_away_from_zero import round_half_away_from_zero
5+
from .round_half_away_from_zero import round_up
6+
57
from .send_email import send_mass_email_service
68
from .goods_to_health import convert_goods_to_health
79

main/globals/round_half_away_from_zero.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,22 @@ def round_half_away_from_zero(val, decimal_places):
2121

2222
# logger.info(f'round_half_away_from_zero: value {val_str} place string {place_string}')
2323

24-
return float(Decimal(val_str).quantize(Decimal(place_string), rounding=ROUND_HALF_UP))
24+
return float(Decimal(val_str).quantize(Decimal(place_string), rounding=ROUND_HALF_UP))
25+
26+
def round_up(val, decimal_places):
27+
'''
28+
round half up
29+
'''
30+
logger = logging.getLogger(__name__)
31+
if decimal_places == 0:
32+
place_string = "0"
33+
else:
34+
place_string = "0."
35+
for place in range(decimal_places):
36+
place_string += "0"
37+
38+
val_str = str(val)
39+
40+
# logger.info(f'round_half_away_from_zero: value {val_str} place string {place_string}')
41+
42+
return Decimal(val_str).quantize(Decimal(place_string), rounding=ROUND_UP)

main/models/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from main.globals import ExperimentPhase
3535
from main.globals import HatModes
36+
from main.globals import round_up
3637

3738
#experiment sessoin
3839
class Session(models.Model):
@@ -628,7 +629,7 @@ def get_download_recruiter_csv(self):
628629

629630
for p in self.world_state["avatars"]:
630631
writer.writerow([parameter_set_players[p]["student_id"],
631-
self.world_state["avatars"][p]["earnings"]])
632+
round_up(Decimal(self.world_state["avatars"][p]["earnings"])/100,2)])
632633

633634
v = output.getvalue()
634635
output.close()

0 commit comments

Comments
 (0)