[open-ils-commits] r16356 - in trunk/Open-ILS/src/perlmods/OpenILS/Application: . Acq Cat (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 29 18:07:23 EDT 2010


Author: phasefx
Date: 2010-04-29 18:07:17 -0400 (Thu, 29 Apr 2010)
New Revision: 16356

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AssetCommon.pm
Log:
The associated behavior for the cat.bib.delete_on_no_copy_via_acq_lineitem_cancel org unit setting.

I notice the "alert on empty" setting does not seem to work with bib deletion via lineitem cancel

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm	2010-04-29 21:20:39 UTC (rev 16355)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm	2010-04-29 22:07:17 UTC (rev 16356)
@@ -2486,13 +2486,15 @@
     }
 
     # Attempt to delete the gathered copies (this will also handle volume deletion and bib deletion)
-    # Another edge case, if we have a bib but not copies, are we supposed to delete the bib?
+    # Delete empty bibs according org unit setting
+    my $force_delete_empty_bib = $U->ou_ancestor_setting_value(
+        $mgr->editor->requestor->ws_ou, 'cat.bib.delete_on_no_copy_via_acq_lineitem_cancel', $mgr->editor);
     if (scalar(@$copies)>0) {
         my $override = 1;
         my $delete_stats = undef;
         my $retarget_holds = [];
         my $cat_evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
-            $mgr->editor, $override, undef, $copies, $delete_stats, $retarget_holds);
+            $mgr->editor, $override, undef, $copies, $delete_stats, $retarget_holds,$force_delete_empty_bib);
 
         if( $cat_evt ) {
             $logger->info("fleshed copy update failed with event: ".OpenSRF::Utils::JSON->perl2JSON($cat_evt));

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AssetCommon.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AssetCommon.pm	2010-04-29 21:20:39 UTC (rev 16355)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AssetCommon.pm	2010-04-29 22:07:17 UTC (rev 16356)
@@ -135,7 +135,7 @@
 
 
 sub update_copy {
-	my($class, $editor, $override, $vol, $copy, $retarget_holds) = @_;
+	my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_;
 
 	my $evt;
 	my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
@@ -155,7 +155,7 @@
     $class->check_hold_retarget($editor, $copy, $orig_copy, $retarget_holds);
 
 	return $editor->event unless $editor->update_asset_copy($copy);
-	return $class->remove_empty_objects($editor, $override, $orig_vol);
+	return $class->remove_empty_objects($editor, $override, $orig_vol, $force_delete_empty_bib);
 }
 
 sub check_hold_retarget {
@@ -192,7 +192,7 @@
 
 # this does the actual work
 sub update_fleshed_copies {
-	my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds) = @_;
+	my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, $force_delete_empty_bib) = @_;
 
 	my $evt;
 	my $fetchvol = ($vol) ? 0 : 1;
@@ -225,7 +225,7 @@
 		$copy->clear_stat_cat_entries;
 
 		if( $copy->isdeleted ) {
-			$evt = $class->delete_copy($editor, $override, $vol, $copy, $retarget_holds);
+			$evt = $class->delete_copy($editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib);
 			return $evt if $evt;
 
 		} elsif( $copy->isnew ) {
@@ -234,7 +234,7 @@
 
 		} elsif( $copy->ischanged ) {
 
-			$evt = $class->update_copy( $editor, $override, $vol, $copy, $retarget_holds );
+			$evt = $class->update_copy( $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib);
 			return $evt if $evt;
 		}
 
@@ -250,7 +250,7 @@
 
 
 sub delete_copy {
-	my($class, $editor, $override, $vol, $copy, $retarget_holds ) = @_;
+	my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_;
 
    return $editor->event unless 
       $editor->allowed('DELETE_COPY', $class->copy_perm_org($vol, $copy));
@@ -283,7 +283,7 @@
 
     $class->check_hold_retarget($editor, $copy, undef, $retarget_holds);
 
-	return $class->remove_empty_objects($editor, $override, $vol);
+	return $class->remove_empty_objects($editor, $override, $vol, $force_delete_empty_bib);
 }
 
 
@@ -397,7 +397,7 @@
 
 
 sub remove_empty_objects {
-	my($class, $editor, $override, $vol) = @_; 
+	my($class, $editor, $override, $vol, $force_delete_empty_bib) = @_; 
 
     my $koe = $U->ou_ancestor_setting_value(
         $editor->requestor->ws_ou, 'cat.bib.keep_on_empty', $editor);
@@ -415,10 +415,10 @@
         }
 
         return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record ) 
-            if $aoe and not $override;
+            if $aoe and not $override and not $force_delete_empty_bib;
 
-        unless($koe) {
-            # delete the bib record if the keep-on-empty setting is not set
+        unless($koe and not $force_delete_empty_bib) {
+            # delete the bib record if the keep-on-empty setting is not set (and we're not otherwise forcing things, say through acq settings)
             my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($editor, $vol->record);
             return $evt if $evt;
         }

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2010-04-29 21:20:39 UTC (rev 16355)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2010-04-29 22:07:17 UTC (rev 16356)
@@ -514,7 +514,7 @@
 	my $override = $self->api_name =~ /override/;
     my $retarget_holds = [];
 	$evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
-        $editor, $override, undef, $copies, $delete_stats, $retarget_holds);
+        $editor, $override, undef, $copies, $delete_stats, $retarget_holds, undef);
 
 	if( $evt ) { 
 		$logger->info("fleshed copy update failed with event: ".OpenSRF::Utils::JSON->perl2JSON($evt));
@@ -646,7 +646,7 @@
 		if( $copies and @$copies and !$vol->isdeleted ) {
 			$_->call_number($vol->id) for @$copies;
 			$evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
-                $editor, $override, $vol, $copies, $delete_stats, $retarget_holds);
+                $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, undef);
 			return $evt if $evt;
 		}
 	}



More information about the open-ils-commits mailing list