From 9fcf488269a6bdf5ce0c849455677a5a27dab8f8 Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Tue, 8 Oct 2013 14:48:14 -0400 Subject: [PATCH] get_billable_amount round down to nearest penny. --- r2/r2/lib/promote.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/promote.py b/r2/r2/lib/promote.py index a2486fbe5..64a8aaa20 100644 --- a/r2/r2/lib/promote.py +++ b/r2/r2/lib/promote.py @@ -24,7 +24,7 @@ from __future__ import with_statement from collections import defaultdict, OrderedDict, namedtuple from datetime import datetime, timedelta -from decimal import Decimal, ROUND_UP +from decimal import Decimal, ROUND_DOWN, ROUND_UP import itertools import json import math @@ -971,7 +971,10 @@ def get_billable_amount(camp, impressions): else: # pre-CPM campaigns are charged in full regardless of impressions billable_amount = camp.bid - return billable_amount + + billable_amount = Decimal(billable_amount).quantize(Decimal('.01'), + rounding=ROUND_DOWN) + return float(billable_amount) def get_spent_amount(campaign):