Acq: Certain workflows produce orphaned fund debits
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
Observed in Evergreen 2.2.8, but probably affecting newer versions too.
Users at an Evergreen site have noticed unexpected and undesired acquisitions fund_debits affecting their funds' balances. Such fund_debits seem to have arrived thanks to interface or middle layer bugs (see later in this bug report).
In cooperation with the site so afflicted, Jason Etheridge put together this SQL query to identify fund_debits that lack clear justification for their existence:
select fd.*
from
acq.fund_debit fd
left join acq.invoice_item ii on ii.fund_debit = fd.id
left join acq.po_item poi on poi.fund_debit = fd.id
left join acq.lineitem_detail ld on ld.fund_debit = fd.id
left join acq.debit_
where
fd.debit_type <> 'prorated_charge'
and ii.id is null
and poi.id is null
and ld.id is null
and da.id is null;
As far as I can tell, indeed, any fund debits that show up in result rows from such a query are either bad data (probably but not necessarily introduced by bugs in Evergreen) or intentional, hand-entered adjustments to funds (users at some sites *may* create fund_debits for balancing purposes, although I wouldn't say it's a good idea).
The user, whom I commend anonymously, along with her associates, until she might wish to claim credit for this legwork, relay these actions of Acquisitions staff at one of her libraries:
> [...] they cancelled the line items by selecting them all and using the PO
> Actions menu "Cancel selected lineitems" option and then used the PO
> Actions menu option "Delete selected items" to delete the line items.
> They then cancelled the PO itself using the cancel option in the
> header of the PO. The result was that the debits were orphaned. The
> actual copies did not get deleted either. They wanted to delete this
> PO because it was a duplicate. Is there any way to delete lineitems
> and POs such that the encumbrance is removed properly and the copy is
> deleted from the catalog?
We need to 1) determine whether the situation is any different in current Evergreen master, 2) make sure there's not some valid reason for keeping the fund_debits and copies around in this situation that I just don't get, and 3) fix it.
Changed in evergreen: | |
status: | New → Triaged |
no longer affects: | evergreen/2.3 |
no longer affects: | evergreen/2.4 |
I know of no reason for a fund_debit, which is linked to a lineitem_detail, to persist after the lineitem_detail has been deleted. In a perfect world, the lineitem_detail would have been cancelled with a cancel_reason whose keep_debits value is FALSE, which would have caused the debits to be deleted during cancellation.
I don't, however, think that we should delete an asset.copy when its linked lineitem_detail is deleted, at least not without a warning/ confirmation.