Filter and navigate usage by financial year

Right now we tell people that the usage page is for the current
financial year. This is a lie – it’s for all time.

So this commit calls through to the API to get the stats for (by
default) the current financial year.

We already do this for the monthly breakdown, this just does the same
thing for the yearly totals.

It also adds navigation to show the data for other financial years:
- previous so you can go back and see your usage and verify that the
  bill you’re about to pay is correct
- next so that you can check what your SMS allowance is going to be
  before you actually get into it
This commit is contained in:
Chris Hill-Scott
2017-01-25 15:59:06 +00:00
parent 8b2ea28111
commit 2a502753a4
8 changed files with 112 additions and 75 deletions

View File

@@ -4,6 +4,7 @@ from io import StringIO, BytesIO
from os import path
from functools import wraps
import unicodedata
from datetime import datetime
from flask import (
abort,
@@ -322,3 +323,10 @@ def png_from_pdf(pdf_endpoint):
filename_or_fp=output,
mimetype='image/png',
)
def get_current_financial_year():
now = datetime.utcnow()
current_month = int(now.strftime('%-m'))
current_year = int(now.strftime('%Y'))
return current_year if current_month > 3 else current_year - 1