[open-ils-commits] r15500 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Feb 11 10:44:52 EST 2010
Author: erickson
Date: 2010-02-11 10:44:50 -0500 (Thu, 11 Feb 2010)
New Revision: 15500
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
Log:
moved user request hold promotion to its own sub. exit early on error. promote holds when the lineitem is 'imported' instead of with each lineitem update
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2010-02-10 22:10:13 UTC (rev 15499)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2010-02-11 15:44:50 UTC (rev 15500)
@@ -197,57 +197,62 @@
$li->edit_time('now');
$li->editor($mgr->editor->requestor->id);
$mgr->add_li;
- my $success = $mgr->editor->update_acq_lineitem($li);
+ return $li if $mgr->editor->update_acq_lineitem($li);
+ return undef;
+}
- if ($success) { # check for requests, create holds
- my $requests = $mgr->editor->search_acq_user_request(
- { lineitem => $li->id,
- '-or' =>
- [ { need_before => {'>' => 'now'} },
- { need_before => undef }
- ]
- }
- );
- for my $request ( @$requests ) {
+# ----------------------------------------------------------------------------
+# Create real holds from patron requests for a given lineitem
+# ----------------------------------------------------------------------------
+sub promote_lineitem_holds {
+ my($mgr, $li) = @_;
- $request->eg_bib( $li->eg_bib_id );
- $mgr->editor->update_acq_user_request( $request );
+ my $requests = $mgr->editor->search_acq_user_request(
+ { lineitem => $li->id,
+ '-or' =>
+ [ { need_before => {'>' => 'now'} },
+ { need_before => undef }
+ ]
+ }
+ );
- next unless ($U->is_true( $request->hold ));
+ for my $request ( @$requests ) {
- my $hold = Fieldmapper::action::hold_request->new;
- $hold->usr( $request->usr );
- $hold->requestor( $request->usr );
- $hold->request_time( $request->request_date );
- $hold->pickup_lib( $request->pickup_lib );
- $hold->request_lib( $request->pickup_lib );
- $hold->selection_ou( $request->pickup_lib );
- $hold->phone_notify( $request->phone_notify );
- $hold->email_notify( $request->email_notify );
- $hold->expire_time( $request->need_before );
+ $request->eg_bib( $li->eg_bib_id );
+ $mgr->editor->update_acq_user_request( $request ) or return 0;
- if ($request->holdable_formats) {
- my $mrm = $mgr->editor->search_metabib_metarecord_source_map( { source => $li->eg_bib_id } )->[0];
- if ($mrm) {
- $hold->hold_type( 'M' );
- $hold->holdable_formats( $request->holdable_formats );
- $hold->target( $mrm->metarecord );
- }
- }
+ next unless ($U->is_true( $request->hold ));
- if (!$hold->target) {
- $hold->hold_type( 'T' );
- $hold->target( $li->eg_bib_id );
+ my $hold = Fieldmapper::action::hold_request->new;
+ $hold->usr( $request->usr );
+ $hold->requestor( $request->usr );
+ $hold->request_time( $request->request_date );
+ $hold->pickup_lib( $request->pickup_lib );
+ $hold->request_lib( $request->pickup_lib );
+ $hold->selection_ou( $request->pickup_lib );
+ $hold->phone_notify( $request->phone_notify );
+ $hold->email_notify( $request->email_notify );
+ $hold->expire_time( $request->need_before );
+
+ if ($request->holdable_formats) {
+ my $mrm = $mgr->editor->search_metabib_metarecord_source_map( { source => $li->eg_bib_id } )->[0];
+ if ($mrm) {
+ $hold->hold_type( 'M' );
+ $hold->holdable_formats( $request->holdable_formats );
+ $hold->target( $mrm->metarecord );
}
+ }
- $mgr->editor->create_actor_hold_request( $hold );
+ if (!$hold->target) {
+ $hold->hold_type( 'T' );
+ $hold->target( $li->eg_bib_id );
}
- return $li;
+ $mgr->editor->create_actor_hold_request( $hold ) or return 0;
}
- return undef;
+ return $li;
}
sub delete_lineitem {
@@ -817,6 +822,12 @@
$new_bib = 1;
}
+
+ # -----------------------------------------------------------------
+ # The lineitem is going live, promote user request holds to real holds
+ # -----------------------------------------------------------------
+ promote_lineitem_holds($mgr, $li) or return 0;
+
my $li_details = $mgr->editor->search_acq_lineitem_detail({lineitem => $li_id}, {idlist=>1});
# -----------------------------------------------------------------
More information about the open-ils-commits
mailing list