Skip to content

feat: regenerate invoice to include missing items

Kaustav Banerjee requested to merge kaustav/regenerate_invoice into billing-v1

Description

This MR adds the ability to regenerate an invoice by either the admin or by the provider, to include new line items or new JIRA logs.

Admins can regenerate invoices in bulk from the admin panel as long as the invoices are not already paid. image

A invoice regenartion link is now included in the invoice approval emails sent to proivders. A provider can click on the link to sync JIRA worklogs and regenerate their invoice as long as the invoice is not approved. Once an invoice is regenerated, the provider is sent a new invoice approval email with the new invoice.

Approved invoices can only be regenerated by the admin.

Testing instructions

Limited functionality can be tested in local environment. To setup local environment follow these instructions.

Full functionality can be tested in staging environment using the instructions below:

Setup

  1. Login to staging admin
  2. Create a new account, if not already present. Ensure the user has the same username as in JIRA and the correct OpenCraft email id. Reuse a fake address or create a new one.
  3. Setup a new hourly rate if not already present. Selec OpenCraft GmbH as the client and your user account as the provider. Please make sure not to use any real rates and that the hourly rate is marked as active.
  4. Create a new invoice template if not already present.
  5. Trigger the send_invoice_approval_request from django shell.

Provider

  1. Verify a new invoice-approval email is received.
  2. Verify invoice regenaration text and link is present in the email
  3. Log time for last month in a dummy task such as BB-7501
  4. Click on the invoice regeneration link.
  5. Verify "invoice_regenerated": true response
  6. Verify a new invoice-approval email is received, with the correctly revised invoice PDF.
  7. Click on the invoice-approval link
  8. Now click on the invoice regenration link again.
  9. Verify "detail": "Not found." response received.

Admin user

  1. Verify a new invoice is generated for last month.
  2. Verify that the invoice is NOT approved. If it is approved, change the status to Not Approved from the admin and save.
  3. Click and open the invoice PDF. Note the total hours and invoice total value.
  4. Log time for last month in a dummy task such as BB-7501
  5. Select the invoice and select Regenerate selected invoices from the actions dropdown above. Click Go
  6. Wait for the screen to refresh and verify invoice total has changed correctly.
  7. Click and open the PDF and verify the PDF generate is correct.
  8. Log more time for last month in a dummy task such as BB-7501
  9. Change the invoice status to either Automatically or Manually approved from admin.
  10. Regenerate invoice as above and verify that regeneration works correctly.
  11. Log more time for last month in a dummy task such as BB-7501
  12. Change the invoice paid status to True from admin.
  13. Regenerate invoice as above and verify that regeneration DOES NOT work this time.

Cleanup

  1. Delete the time logs in the dummy task
  2. Deactivate the hourly rate setup earlier

Other information

OpenCraft ticket : BB-7381

Edited by Kaustav Banerjee

Merge request reports