Add automated jobs for the invoice approval flow.
This PR adds monthly jobs that do the following:
- Sends invoice preparation notifications.
- Sends invoice approval requests.
- Sends finalized invoices.
Testing Instructions:
Endpoints
- Make an invoice as usual. Get the invoice's UUID.
- Go to
http://localhost:1786/invoice/{uuid}/approve/
and see that it gets marked as manually approved when it previously wasn't. - Go to
http://localhost:1786/invoice/{uuid}/approve/
again and see that you cannot approve an invoice when it's already approved. - Go to
http://localhost:1786/invoice/{uuid}/pay/
and see that it gets marked as paid. - Go to
http://localhost:1786/invoice/{uuid}/pay
again and see that you cannot pay an invoice when it's already paid.
Invoice Tasks
- Delete the old invoice.
- Make 3 accounts: 1 client, 2 providers, with an HourlyRate connection between the client and providers. Make sure the client's username matches what you have in
BILLING_CYCLE_USERS
. Make the client and providers have emails that're available to you, i.e.me+client1@opencraft.com
,me+provider1@opencraft.com
,me+provider2@opencraft.com
, since you'll need to see the emails sent to providers with clients CC'd.
Testing invoice tasks locally and on stage will be slightly different:
Locally
- Go into the shell with
make shell
, and run the following to make sure it comes out as expected: from accounting.invoice.tasks import *
send_invoice_prep_notification()
- You can temporarily disable GDrive uploads by switching the flag, so you can see the email message in your console rather than a huge wall of text representing the PDF, for the following two tasks:
send_invoice_approval_request()
send_final_invoices()
Stage
- Go into the shell with
make shell
, and run the following to make sure it comes out as expected: from accounting.invoice.tasks import *
- For all of these, check that the email arrives for everyone with the proper subject, body, to, bcc, and cc, as appropriate:
send_invoice_prep_notification()
-
send_invoice_approval_request()
-- check theinvoices-in/draft/{month}
folder for the invoice. -
send_final_invoices()
-- check theinvoices-in/{month}
folder for the invoice. If you did not approve the invoice manually by using the URL, check that it's marked as 'automatically' approved instead.
Preferably, do these twice, so you can see cases where the invoice doesn't exist when starting the pipeline, and cases where an invoice does exist.
MERGE TODO
- Make a
draft
folder on Accounting prod GDrive.