Skip to content

Add automated jobs for the invoice approval flow.

Uman Shahzad requested to merge uman/invoice-approval into master

This PR adds monthly jobs that do the following:

  • Sends invoice preparation notifications.
  • Sends invoice approval requests.
  • Sends finalized invoices.

Testing Instructions:

Endpoints

  1. Make an invoice as usual. Get the invoice's UUID.
  2. Go to http://localhost:1786/invoice/{uuid}/approve/ and see that it gets marked as manually approved when it previously wasn't.
  3. Go to http://localhost:1786/invoice/{uuid}/approve/ again and see that you cannot approve an invoice when it's already approved.
  4. Go to http://localhost:1786/invoice/{uuid}/pay/ and see that it gets marked as paid.
  5. Go to http://localhost:1786/invoice/{uuid}/pay again and see that you cannot pay an invoice when it's already paid.

Invoice Tasks

  1. Delete the old invoice.
  2. 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
  1. Go into the shell with make shell, and run the following to make sure it comes out as expected:
  2. from accounting.invoice.tasks import *
  3. send_invoice_prep_notification()
  4. 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:
  5. send_invoice_approval_request()
  6. send_final_invoices()
Stage
  1. Go into the shell with make shell, and run the following to make sure it comes out as expected:
  2. from accounting.invoice.tasks import *
  3. For all of these, check that the email arrives for everyone with the proper subject, body, to, bcc, and cc, as appropriate:
  4. send_invoice_prep_notification()
  5. send_invoice_approval_request() -- check the invoices-in/draft/{month} folder for the invoice.
  6. send_final_invoices() -- check the invoices-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

  1. Make a draft folder on Accounting prod GDrive.

Merge request reports