From: Bill Erickson Date: Tue, 10 Jul 2012 15:56:05 +0000 (-0400) Subject: Control PO activation for zero-copy lineitems X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a0f9b77361a434c42ce39eb88661c7926d158395;p=evergreen%2Fpines.git Control PO activation for zero-copy lineitems By default, prevent activation of POs when any lineitems are present that have no copies attached. This adds a new option in the PO UI called "Allow activation with zero-copy lineitems", which will allow the activation to continue even when zero-copy lineitems exist. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index ec94c04995..8116ca3b3b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -760,7 +760,8 @@ sub set_lineitem_attr { # Lineitem Debits # ---------------------------------------------------------------------------- sub create_lineitem_debits { - my ($mgr, $li, $dry_run) = @_; + my ($mgr, $li, $dry_run, $options) = @_; + $options ||= {}; unless($li->estimated_unit_price) { $mgr->editor->event(OpenILS::Event->new('ACQ_LINEITEM_NO_PRICE', payload => $li->id)); @@ -779,6 +780,12 @@ sub create_lineitem_debits { {idlist=>1} ); + if (@$lid_ids == 0 and !$options->{zero_copy_activate}) { + $mgr->editor->event(OpenILS::Event->new('ACQ_LINEITEM_NO_COPIES', payload => $li->id)); + $mgr->editor->rollback; + return 0; + } + for my $lid_id (@$lid_ids) { my $lid = $mgr->editor->retrieve_acq_lineitem_detail([ @@ -2305,13 +2312,14 @@ __PACKAGE__->register_method( ); sub activate_purchase_order { - my($self, $conn, $auth, $po_id, $vandelay) = @_; + my($self, $conn, $auth, $po_id, $vandelay, $options) = @_; + $options ||= {}; my $dry_run = ($self->api_name =~ /\.dry_run/) ? 1 : 0; my $e = new_editor(authtoken=>$auth); return $e->die_event unless $e->checkauth; my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn); - my $die_event = activate_purchase_order_impl($mgr, $po_id, $vandelay, $dry_run); + my $die_event = activate_purchase_order_impl($mgr, $po_id, $vandelay, $dry_run, $options); return $e->die_event if $die_event; $conn->respond_complete(1); $mgr->run_post_response_hooks unless $dry_run; @@ -2320,7 +2328,7 @@ sub activate_purchase_order { # xacts managed within sub activate_purchase_order_impl { - my ($mgr, $po_id, $vandelay, $dry_run) = @_; + my ($mgr, $po_id, $vandelay, $dry_run, $options) = @_; # read-only until lineitem asset creation my $e = $mgr->editor; @@ -2366,7 +2374,7 @@ sub activate_purchase_order_impl { $li->state('on-order'); $li->claim_policy($provider->default_claim_policy) if $provider->default_claim_policy and !$li->claim_policy; - create_lineitem_debits($mgr, $li, $dry_run) or return $e->die_event; + create_lineitem_debits($mgr, $li, $dry_run, $options) or return $e->die_event; update_lineitem($mgr, $li) or return $e->die_event; $mgr->post_process( sub { create_lineitem_status_events($mgr, $li->id, 'aur.ordered'); }); $mgr->respond; diff --git a/Open-ILS/src/templates/acq/po/view.tt2 b/Open-ILS/src/templates/acq/po/view.tt2 index ec2c9ea8d8..605ad7a13d 100644 --- a/Open-ILS/src/templates/acq/po/view.tt2 +++ b/Open-ILS/src/templates/acq/po/view.tt2 @@ -105,6 +105,11 @@ + + + [% l('Allow activation with
zero-copy lineitems') %] + +