MODINVOICE-52 we implemented calculation of the invoice totals. These currently happen "on the fly", so the totals are never persisted. This works great if you're using GET by ID to retrieve invoices, but it means that the totals are not present in search results.
Having these totals appear in the invoice search resutls is apparently needed, so we need to change this behavior.
- Calculate the totals upon invoice and invoiceLine creation/update and persist the values.
- It might make sense to do some of this asynchronously via the eventBus like we've done in other places (po/pol)
- In order to mitigate the possibility of the invoice/invoiceLine totals getting out of sync (e.g. if the call fails to update one but not the other), we should re-calculate the invoice totals upon GET by ID as well, and if different from what we just got from the DB, update them.
- Once an invoice is "Approved", the totals should be read-only and the values should not be recalculated but used as is in DB (see Acquisitions Interface Fields - Invoice)
- adjustmentTotal, and total appear in the invoices retrieved via GET by Query and GET by ID.
- Unit tests are updated
- API tests are updated
- Sample data is updated as needed (may or may not be)
NOTE: It may make sense to do this before implementing prorated adjustments (