Merge pull request #2349 from alphagov/display-postage-on-usage-page

Display postage on usage page
This commit is contained in:
Katie Smith
2018-10-04 14:37:18 +01:00
committed by GitHub
5 changed files with 78 additions and 62 deletions

View File

@@ -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]

View File

@@ -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 @@
) }}
<ul>
{% if month.free %}
<li class="tabular-numbers">{{ "{:,}".format(month.free) }} free text messages</li>
<li class="tabular-numbers">{{ "{:,}".format(month.free) }} free {{ message_count_label(month.free, 'sms', '') }}</li>
{% endif %}
{% if month.paid %}
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} text messages at
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} {{ message_count_label(month.paid, 'sms', '') }}at
{{- ' {:.2f}p'.format(sms_rate * 100) }}</li>
{% endif %}
{% if not (month.free or month.paid) %}
@@ -113,8 +114,8 @@
<ul>
{% for letter in month.letters%}
{% if letter[0] %}
<li class="tabular-numbers">{{ "{:,}".format(letter[0])}} letters at {{ '{:.0f}p'.format(letter[1] * 100) }}
</li>
<li class="tabular-numbers">{{ "{:,} {}".format(letter[0], letter[3])}} class {{ message_count_label(letter[0], 'letter', '') }}at
{{ '{:.0f}p'.format(letter[1] * 100) }}</li>
{% endif %}
{% endfor %}
</ul>

View File

@@ -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 %}
@@ -83,10 +84,10 @@
) }}
<ul>
{% if month.free %}
<li class="tabular-numbers">{{ "{:,}".format(month.free) }} free text messages</li>
<li class="tabular-numbers">{{ "{:,}".format(month.free) }} free {{ message_count_label(month.free, 'sms', '') }}</li>
{% endif %}
{% if month.paid %}
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} text messages at
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} {{ message_count_label(month.free, 'sms', '') }}at
{{- ' {:.2f}p'.format(sms_rate * 100) }}</li>
{% endif %}
{% if not (month.free or month.paid) %}
@@ -113,4 +114,4 @@
</div>
</div>
{% endblock %}
{% endblock %}