Commit Graph

37 Commits

Author SHA1 Message Date
Rebecca Law
c4d869175a Add join to LetterRates for the billing query.
Fix the yearly totals to work for letters.
2017-12-18 16:46:59 +00:00
Rebecca Law
e0e64d51d5 [WIP]
Fix the query to count rather than sum the billing units.
Need to fix the query that returns the monhtly billing, there is only one row but there should be two if there are two rates.
2017-12-15 17:29:32 +00:00
Rebecca Law
9b884770e5 Remove extra if clause added when trying to merge. 2017-12-15 11:58:55 +00:00
Rebecca Law
63799f5ff2 Merge branch 'populate-monthly-letter-usages' of github.com:alphagov/notifications-api into populate-monthly-letter-usages 2017-12-15 10:34:20 +00:00
Rebecca Law
012d80003a Update montly billing with letters 2017-12-14 17:17:05 +00:00
Rebecca Law
4ea79d9eb1 Monthly billing has been updated to populate for letters. 2017-12-12 15:54:59 +00:00
Rebecca Law
a836ed037e Added query for billing usage of letter notifications. 2017-12-11 16:55:23 +00:00
Leo Hemsted
28d5f9b87f flake8 - remove unused imports and ensure they're always at the top of the file 2017-11-28 14:28:01 +00:00
Richard Chapman
a77c316d2f Added stats annotation to a few more methods to track which methods need to be improved to increase billing performance 2017-11-09 10:34:49 +00:00
Imdad Ahad
c92b72da6e Remove yearly billing data dao methods 2017-08-30 14:40:29 +01:00
Rebecca Law
17f62723fa Removed unused endpoint and dao methods. 2017-08-24 16:09:48 +01:00
Imdad Ahad
94605d31fa Change how we populate and retrieve MonthlyBilling totals:
1. For both email and sms, store [] in monthly_totals if
there is no billing data (no notifications sent etc.) and
return this via the API

2. General refactoring of indentation
2017-08-15 16:09:42 +01:00
Imdad Ahad
35ad5d74f9 Retrieve billing data (for month) by notification type:
* Previously we were only returning SMS. Let's make this return for
a given notification type.
* General refactor of the monthly retrieval query
* Return an empty BillingData tuple if email billing data is empty
2017-08-11 16:57:18 +01:00
Imdad Ahad
824063ddb8 Fix to return billing data before a rate begins 2017-08-02 15:32:34 +01:00
Rebecca Law
e23d38de26 Fix bug in get rates function. 2017-07-25 15:50:14 +01:00
Rebecca Law
5612ca023e - Add transactional
- Rename function for clarity
2017-07-25 14:26:42 +01:00
Rebecca Law
eaf5cbb868 Add labels to query so that the named tuples can be referenced later.
Remove unnecessary function
2017-07-25 11:43:41 +01:00
Rebecca Law
3e2b8190b9 - Added a scheduled task to create or update billing for the month, yesterday is used to calculate the start and end date for the month.
- The new task has not been added to the beat application yet.
- Added an updated_at column to the monthly billing table, we may want to only calculate from the last updated date rather than the entire month.
2017-07-24 15:13:18 +01:00
Rebecca Law
9400988d72 Monthly billing - part 1
This is still a work in progress but it would be good to get some eyes on it.
This commit includes creating and updating a row in the monthly billing table and a method to fetch the results.
There is a command to populate the monthly billing for a service and month so we can try it out.
The total cost at the moment are wrong, they do not take into account the free allowance - see notes below about adding that to the table.
Left to do:
create a nightly task to run to update the monthly totals.
create an endpoint to return the yearly billing, the current day will need to be calculated on the fly and added to the totals.
Add the free allowance into the total costs.
2017-07-18 18:21:35 +01:00
Martyn Inglis
cad195949a Ensure that the bill includes whatever free allowance is applicable. 2017-06-06 16:21:05 +01:00
Martyn Inglis
96d30d31b1 Get existing tests to pass.
Done by ensuring that the rate limit is 0, so that all messages are billable.
2017-06-06 14:55:37 +01:00
Martyn Inglis
18dcc10a06 Fixed typo 2017-06-06 14:04:11 +01:00
Martyn Inglis
7a03ef3de4 Pseudo Code 2017-06-05 17:25:40 +01:00
Martyn Inglis
517dc6be8b Typo removed. Wrong window focus 2017-05-24 09:59:51 +01:00
Martyn Inglis
9dd6041944 Usage DAO can now return rates and billable amount, alongside units. 2017-05-24 08:56:59 +01:00
Martyn Inglis
35af759f87 Adding rates to the billable units query 2017-05-23 13:54:51 +01:00
Martyn Inglis
2a0669636d Add and test new DAO method that counts the billable units multiplied by rate multiplier for a given service for a given time period.
Currently this is SMS only.

Used by the dashboard for a headline figure.
2017-05-19 16:42:33 +01:00
Rebecca Law
93e76d2362 Update the valid_from date for the rate that is intended to start at the begining of the financial year.
It was the start of the financial year in BST, needed to convert it to UTC.
Small change to the logic to find the rates.
2017-05-03 17:11:48 +01:00
Ken Tsang
a1a8397f74 Update billing data to handle future dates 2017-05-02 19:23:57 +01:00
Rebecca Law
3e0221adec Change get_financial_year to return ending date as 1 microsecond earlier.
That way we can write the queries as between start and end dates, making it easier to read.
This makes more sense.
2017-05-02 10:00:47 +01:00
Rebecca Law
88d92d6070 Fix the logic gettting the rates for a financial year.
The is_between_end_date_exclusive is a bit funny.
Perhaps the better way to handle it is to make the function is_between but change the financial year function return an enddate that is one millisecond less. That way we can always use the between logic and it will be easier to use.
2017-04-28 16:55:41 +01:00
Rebecca Law
1a64509186 Change the resultset from the yearly and monthly billing data queries.
Fix some formatting of the return objects.
2017-04-28 10:10:49 +01:00
Rebecca Law
fdbadf967e Fix the email billing data when there is no results. 2017-04-28 10:10:48 +01:00
Rebecca Law
a186fc95be Added new endpoints to return the yearly-usage and monthly-usage for a given financial year and service id.
Since the response has changed I have created new endpoints so that the deployments for Admin are more managable.

Removed print statements from some tests.
2017-04-28 10:10:48 +01:00
Rebecca Law
e1e55edd9c Add new fields to the usage queries: rate_multiplier, international, phone_prefix. 2017-04-28 10:10:48 +01:00
Rebecca Law
4c37c8bdbb New query to get billing data per month. 2017-04-28 10:10:48 +01:00
Rebecca Law
6dc336ad6c Created new queries to return the rate with the sum of billable units for the year totals.
Once we have the new columns in notifications table, the query will need to include the rate multiplier and if the number is international.
The monthly billing query will be built next.
2017-04-28 10:10:48 +01:00