Commit Graph

272 Commits

Author SHA1 Message Date
Beverly Nguyen
66909e9624 added conditional 2024-02-23 17:50:25 -08:00
Kenneth Kehl
4742cc77b5 change batch file report to look like full csv report 2024-02-21 07:45:21 -08:00
Beverly Nguyen
d7606b2986 added PR requested changes 2024-02-15 10:40:15 -08:00
Beverly Nguyen
ef5ed8ecab updated pytest 2024-02-12 15:29:26 -08:00
Beverly Nguyen
7b8a187db0 update sort imports 2024-02-09 17:19:15 -08:00
Beverly Nguyen
b7f21a6efd update sort imports 2024-02-09 17:15:44 -08:00
Beverly Nguyen
72aa14fd3b fixed duplicates to notification by adding aggregate 2024-02-09 17:09:48 -08:00
Beverly Nguyen
45ffa70c3c fixing mocker patch for jobs 2024-01-26 09:43:41 -08:00
Beverly Nguyen
6e05fd5147 removed comments 2024-01-25 15:39:32 -08:00
Beverly Nguyen
524a1e4687 updated download links and table html 2024-01-25 15:32:44 -08:00
Beverly Nguyen
65bccb3f95 changed time column 2024-01-23 16:18:43 -08:00
Beverly Nguyen
8baf9682a1 update table css and format 2024-01-23 15:24:57 -08:00
Beverly Nguyen
9b0dc3dc3c updated table titles and fields 2024-01-19 11:44:25 -08:00
Beverly Nguyen
321ddbd27a removed notification conditional 2024-01-12 13:32:10 -08:00
Beverly Nguyen
653c7d8624 fix style checks 2024-01-08 15:33:24 -08:00
Beverly Nguyen
ec1d9a49bf updated dashboard 2024-01-08 14:53:34 -08:00
Beverly Nguyen
751947c421 updated dashboard.py def 2024-01-05 12:45:21 -08:00
Beverly Nguyen
e7ce8814dd fixing imports alphabetized 2024-01-04 14:04:04 -08:00
Beverly Nguyen
80285a6546 fixing style checks 2024-01-04 13:56:35 -08:00
Beverly Nguyen
3ad5fb1d7c moved table to parent dashboard 2024-01-04 13:43:47 -08:00
Beverly Nguyen
aac23a754f moved table to parent dashboard 2024-01-04 13:40:36 -08:00
Beverly Nguyen
a920528902 moved table to dashboard 2024-01-03 00:26:49 -08:00
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Kenneth Kehl
c6eb007386 merge from main 2023-08-25 08:57:24 -07:00
stvnrlly
944715ac46 big commit with letters removal 2022-12-05 15:33:44 -05:00
stvnrlly
33eaa60e5b mock the api call 2022-12-02 11:27:41 -05:00
stvnrlly
a8b8d09fb7 post-gray test updates 2022-12-02 10:30:37 -05:00
stvnrlly
de30221ae3 more dashboard rearrangment 2022-12-02 09:29:12 -05:00
stvnrlly
f49e2a9e6e more gray for dashboard 2022-12-01 10:18:12 -05:00
stvnrlly
f16b5dd1c4 remove broadcast-related code 2022-10-04 03:04:13 +00:00
jimmoffet
f3f3b914a1 remove unnecessary noqa comment 2022-09-12 17:51:32 -07:00
jimmoffet
69abec0bb3 change dashboard test to reflect demo changes to uploads view 2022-09-09 17:02:48 -07:00
Ben Thorner
4abb6110c8 Fix keys used to render monthly usage
These were out-of-sync with the API.
2022-05-11 13:28:33 +01:00
Ben Thorner
bb0fb73bc8 Minor tweaks in response to PR comments
In response to [^1] and [^2].

[^1]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869181152
[^2]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869186063
2022-05-10 17:00:51 +01:00
Ben Thorner
3449ccd923 Support multiple SMS rates per month on usage page 2022-05-03 16:01:13 +01:00
Ben Thorner
91e902bc2c Tidy up "format" method for monthly letter usage
This did more than it said and had some unconventional behaviour:

- It modified the input data. We can avoid this by computing the
postage group on-the-fly and using "sorted" instead of "sort".

- It defined a custom, named tuple. This isn't necessary as Jinja
allows us to access elements by qualification (".") already.

We can also use the same lambda function to group and sort items,
since the sort predicate is the same one we use to group them.
2022-05-03 16:01:09 +01:00
Ben Thorner
fb7c116046 Finish migration from billing_units to API fields
This is now only used for letters and represents the number sent
[^1].  We could use the chargeable_units field, but using "_sent"
is more consistent with the annual attributes [^2].

In fact, chargeable_units isn't actually used anywhere, but I've
kept it in the test data as it is part of the real API and helps
clarify the other values for SMS - free vs. charged.

Note: for SMS I've used an arbitrary "1234" for "chargeable_units"
to indicate it's not used and may be different to the number sent -
for SMS it's related to the number of fragments.

[^1]: bb62d22f25/app/dao/fact_billing_dao.py (L339)
[^2]: 3a1ac189ff/app/main/views/dashboard.py (L339)
2022-05-03 16:01:08 +01:00
Ben Thorner
c0ee24ff19 Migrate letter cost calculation to use API field
The values in the tests are calculated manually from other fields
in the mocked API response.
2022-05-03 16:01:07 +01:00
Ben Thorner
d798a0d60f Replace manual SMS monthly calculations with API
This starts using the sms_{cost, charged, free_allowance_used}
fields in the new API to replace the "get_free_paid_breakdown"
function we had before, which could not support multiple rates.

In order to use "get_free_paid_breakdown" the calling method had
to store a "cumulative" variable to calculate the free allowance
used so far, which is now done by the API.

To calculate the data for conftest.py, I had to start from the
bottom ("April") and manually calculate the free allowance used
to emulate the API - this is what "cumulative" used to do.
2022-05-03 16:01:06 +01:00
Ben Thorner
4ab795ad68 Replace "sum_billing_units" with inline code
This is also an opportunity to DRY-up the filtering of usage by
month, which we will reuse in the following commits. Doing a sum
is simple enough that it can be done inline, avoiding indirection.
2022-05-03 16:01:02 +01:00
Ben Thorner
246356649f Rename monthly usage attributes to match API
This should make the subsequent changes to use the new API fields
a bit clearer, and also matches the annual usage attributes [^1].

[^1]: 3a1ac189ff/app/main/views/dashboard.py (L343-L350)
2022-05-03 16:01:01 +01:00
Ben Thorner
215a688250 Reuse helper function to filter usage rows
I've also dispensed with the "units" terminology here, which didn't
represent the "rows" returned by the API.
2022-05-03 16:01:00 +01:00
Ben Thorner
ca2ff00931 Rename monthly helper function to match annual one 2022-05-03 16:00:59 +01:00
Ben Thorner
4ab7e3ceec Rename billing API methods to be recognisable
I struggled to distinguish which was which as neither mentioned if
the data they returned was monthly or annual.
2022-05-03 16:00:57 +01:00
Ben Thorner
e6c04ef556 Support variable rates for annual usage stats
Note: I've removed the pricing assertion in the "0_free_allowance"
test as it's covered elsewhere - the value of the test is really to
check that we don't show the remainder if there never was any.
2022-04-27 17:06:17 +01:00
Ben Thorner
715a3c137f Rename ambiguous "sms_chargeable" Jinja variable
Now that we have the term "charge*able*_units" we should clarify
this variable is the number we will actually charge for.
2022-04-27 17:06:16 +01:00
Ben Thorner
e0aa51c306 Use new "cost" field in usage APIs
The previous, manual calculation could be incorrect depending on
which SMS rates the free allowance was attributed to.

The new field also supersedes the old "letter_total" bolt-on so we
can get cost information consistently for both types.
2022-04-27 17:06:12 +01:00
Ben Thorner
55ea5d90c7 Migrate away from ambiguous "billing_units"
This uses two new fields in the annual usage API instead of the
old one, which was actually a mix of two kinds of data [^1].

[^1]: fc378fed96
2022-04-27 16:32:52 +01:00
Ben Thorner
0648f80b9d Refactor "calculate_usage" function
This will make the following changes clearer.

In the next commits we'll go into more detail about "billing_units"
and how it differs for SMS vs. emails and letters.
2022-04-27 16:30:26 +01:00
David McDonald
2706ec4c73 Take sms_rate from monthly usage data
At the moment, we put the sms rate on the usage page for each
months billing data by taking the single sms rate for the year.

The assumption that there will be a single sms rate for the year is
no longer going to be true. Therefore, instead we take the sms
rate from the monthly data itself which tells us the rate for
a months worth of sent SMS.
2022-04-26 10:38:10 +01:00