Uploaded image for project: 'mod-orders'
  1. mod-orders
  2. MODORDERS-645

Invoice payment fails if order line fund distribution is changed before invoice approval

    XMLWordPrintable

    Details

    • Template:
    • Sprint:
      ACQ Sprint 133
    • Story Points:
      3
    • Development Team:
      Thunderjet
    • Release:
      Lotus R1 2022
    • Potential Workaround:
      Current workaround is to call invoice-storage api directly and put invoice line without encumbrance id in fund distribution.

      Description

      Overview: If order line fund distribution is changed to a different fund before linked invoice approval, invoice is stuck with a link to a deleted encumbrance, which prevents payment.

      Steps to Reproduce:

      1. Log into FOLIO environment (kiwi or later) as a user with admin permissions.
      2. Create an order and order line with fund distribution.
      3. Open order.
      4. Create an invoice and add order line from step 2 as invoice line.
      5. Change order line fund distribution to a different fund by deleting existing fund distribution via clicking on trash icon and adding new (not just selection other fund from dropdown)
      6. Approve invoice.
      7. Pay invoice.

      Expected Results:

      Invoice payment is successful.

      Actual Results:

      Invoice payment fails because it has link to a deleted encumbrance.

      Additional Information:

      Response:

      {
        "errors" : [ {
          "message" : "One or more transactions record(s) failed to be created",
          "code" : "transactionCreationFailure",
          "parameters" : [ {
            "key" : "invoiceLineId",
            "value" : "29e8f0dc-b274-4b88-ab1c-a2be79b89167"
          }, {
            "key" : "fundId",
            "value" : "55f48dc6-efa7-4cfe-bc7c-4786efe493e3"
          } ]
        } ],
        "total_records" : 1
      }
      

      mod-finance-storage logs:

      2021-11-26T13:19:28,360 ERROR [vert.x-eventloop-thread-1] TemporaryInvoiceTransactionDAO Transaction creation with id=c52ce966-2655-44ab-b779-96c4b1631352 failed
      io.vertx.pgclient.PgException: { "message": "insert or update on table \"temporary_invoice_transactions\" violates foreign key constraint \"paymentencumbranceid_transaction_fkey\"", "severity": "ERROR", "code": "23503", "detail": "Key (paymentencumbranceid)=(6e7dd118-e116-4b9c-bd92-d8ff04be9f36) is not present in table \"transaction\".", "file": "ri_triggers.c", "line": "2463", "routine": "ri_ReportViolation", "schema": "diku_mod_finance_storage", "table": "temporary_invoice_transactions", "constraint": "paymentencumbranceid_transaction_fkey" }

       

      Potential resolution:

      In mod-orders, when removing a fund distribution, check if an invoice is linked with order-invoice-relns and if so remove all related encumbrance links from invoice lines, in EncumbranceService$deleteEncumbrances (requires adding permission invoice.invoice-lines.item.put).

        TestRail: Results

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Andrei_Makaranka Andrei Makaranka
                Reporter:
                andriy_kundyukov Andriy Kundyukov
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    TestRail: Runs

                      TestRail: Cases