Encumbrances that have been released when an invoice was approved need to be unreleased when the invoice is cancelled.
- This only applies to invoice lines with releaseEncumbrance=true
- This should only be done if Orders are in the status "Open" and POL payment status is Awaiting payment, Partially paid or Fully paid.
- Update encumbrances to change their status to Unreleased (by calling mod-finance, which should update the budgets accordingly)
- Update InvoiceCancelService to unrelease encumbrances at the end of the cancelling process.
- Select all unique po line ids from invoice lines with releaseEncumbrance=true.
- Get the related order lines and orders, filter order lines based on order workflowStatus and order line paymentStatus.
- Use baseTransactionService.getEncumbrancesByPoLineIds to get the encumbrances.
- Change encumbrances status to Unreleased.
- For each order, update order transaction summaries and use baseTransactionService.updateTransactions().
- If an error occurs while doing this, return an error message saying there was an error while unreleasing the encumbrance after cancelling the invoice and include the initial error message.
- Unit tests updated
- Cross-module integration test cancel-invoice-linked-to-order from