From: Rogan Hamby Date: Fri, 19 Apr 2019 19:39:57 +0000 (-0400) Subject: LP#1634244 - prevent bibs from being deleted when they have on-order, pending-order... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=18277d2154ada19acddfd8ef294f41084a8b87f2;p=evergreen%2Fequinox.git LP#1634244 - prevent bibs from being deleted when they have on-order, pending-order or new line items attached to them Signed-off-by: Rogan Hamby Signed-off-by: Chris Sharp --- diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 362fff563d..2163696968 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -704,7 +704,9 @@ The requested permission_grp_penalty_threshold was not found - + + The selected bib record has an open lineitem order referencing it. + The non-cataloged type object already exists diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm index 831633717d..4c4d977cca 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm @@ -1296,6 +1296,17 @@ sub delete_bib_record { return $e->die_event unless $e->allowed('DELETE_RECORD', $e->requestor->ws_ou); my $vols = $e->search_asset_call_number({record=>$rec_id, deleted=>'f'}); return OpenILS::Event->new('RECORD_NOT_EMPTY', payload=>$rec_id) if @$vols; + my $acq_li_count = $e->json_query({ + select => {jub => [{column => 'id', transform => 'count'}]}, + from => 'jub', + where => { + '+jub' => { + eg_bib_id => $rec_id, + state => ['new','pending-order','on-order'] + } + } + })->[0]; + return OpenILS::Event->new('RECORD_REFERENCED_BY_LINEITEM', payload => $rec_id) if ($acq_li_count->{id} > 0); my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($e, $rec_id); if($evt) { $e->rollback; return $evt; } $e->commit;