diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 72f8f62b8..1aa5c1c37 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -418,8 +418,8 @@ def get_months_for_year(start, end, year): def get_sum_billing_units(billing_units, month=None): if month: - return sum(b['billing_units'] * b.get('rate_multiplier', 1) for b in billing_units if b['month'] == month) - return sum(b['billing_units'] * b.get('rate_multiplier', 1) for b in billing_units) + return sum(b['billing_units'] for b in billing_units if b['month'] == month) + return sum(b['billing_units'] for b in billing_units) def get_free_paid_breakdown_for_billable_units(year, free_sms_fragment_limit, billing_units): @@ -435,8 +435,12 @@ def get_free_paid_breakdown_for_billable_units(year, free_sms_fragment_limit, bi free_sms_fragment_limit, cumulative, previous_cumulative, [billing_month for billing_month in sms_units if billing_month['month'] == month] ) - letter_billing = [(x['billing_units'], x['rate'], (x['billing_units'] * x['rate'])) + letter_billing = [(x['billing_units'], x['rate'], (x['billing_units'] * x['rate']), x['postage']) for x in letter_units if x['month'] == month] + + if letter_billing: + letter_billing.sort(key=lambda x: (x[3], x[1])) + letter_total = 0 for x in letter_billing: letter_total += x[2] diff --git a/app/templates/views/usage-with-letters.html b/app/templates/views/usage-with-letters.html index 7d26976d6..ea5e06678 100644 --- a/app/templates/views/usage-with-letters.html +++ b/app/templates/views/usage-with-letters.html @@ -1,4 +1,5 @@ {% from "components/big-number.html" import big_number %} +{% from "components/message-count-label.html" import message_count_label %} {% from "components/table.html" import list_table, field, hidden_field_heading, row_heading, text_field %} {% from "components/pill.html" import pill %} @@ -100,10 +101,10 @@ ) }}