From: Bill Erickson Date: Fri, 3 Jun 2011 17:21:37 +0000 (-0400) Subject: Delete volume on last copy setting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6a5353e5663501404d1cce7c791b7f873b14f98d;p=evergreen%2Fequinox.git Delete volume on last copy setting When the last copy for a volume is deleted, go ahead and delete the volume when this new setting is activated. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm index 555e4b791b..23f5c5bc05 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm @@ -493,7 +493,27 @@ sub remove_empty_objects { my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($editor, $vol->record); return $evt if $evt; } - } + + } else { + + # this may be the last copy attached to the volume. + + if($U->ou_ancestor_setting_value( + $editor->requestor->ws_ou, 'cat.volume.delete_on_empty', $editor)) { + + # if this volume is "empty" and not mid-delete, delete it. + unless($U->is_true($vol->deleted) || $vol->isdeleted) { + + my $copies = $editor->search_asset_copy( + [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1}); + + if(!@$copies) { + my $evt = $class->delete_volume($editor, $vol, $override, 0, 1); + return $evt if $evt; + } + } + } + } return undef; } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 5e294f1bc8..f41ae3ebc1 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -8707,3 +8707,12 @@ INSERT INTO config.usr_setting_type oils_i18n_gettext('circ.collections.exempt', 'User is exempt from collections tracking/processing', 'cust', 'description'), 'bool' ); + +INSERT INTO config.org_unit_setting_type +( name, label, description, datatype ) VALUES +( 'cat.volume.delete_on_empty', + oils_i18n_gettext('cat.volume.delete_on_empty', 'Cat: Delete volume with last copy', 'coust', 'label'), + oils_i18n_gettext('cat.volume.delete_on_empty', 'Automatically delete a volume when the last linked copy is deleted', 'coust', 'description'), + 'bool' +); +