From bc9b805468865055184eb1f2232855a21e224124 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 27 Nov 2012 15:26:48 -0500 Subject: [PATCH] Support PO activation w/o loading items Allow for the activation of purchase orders without requiring that bibs and items be loaded. (Currently, if bibs and items are not manually loaded, they are loaded during PO activation). Adds a new link next to the existing PO Activate link for "Activate Withoug Loading Items". Apart from the fact that there are no underlying bibs/copies, such a PO behaves the same as any other PO. Signed-off-by: Bill Erickson Conflicts: Open-ILS/src/templates/acq/po/view.tt2 Open-ILS/web/js/ui/default/acq/po/view_po.js Signed-off-by: Kathy Lussier --- .../lib/OpenILS/Application/Acq/Order.pm | 21 ++++++++++------ Open-ILS/src/templates/acq/po/view.tt2 | 10 +++++++- Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 1 + Open-ILS/web/js/ui/default/acq/po/view_po.js | 25 ++++++++++++++----- 4 files changed, 42 insertions(+), 15 deletions(-) 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 9661f9212e..194fdb5fff 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -2599,21 +2599,24 @@ __PACKAGE__->register_method( sub activate_purchase_order { my($self, $conn, $auth, $po_id, $vandelay, $options) = @_; $options ||= {}; + $$options{dry_run} = ($self->api_name =~ /\.dry_run/) ? 1 : 0; - 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, $options); + my $die_event = activate_purchase_order_impl($mgr, $po_id, $vandelay, $options); return $e->die_event if $die_event; $conn->respond_complete(1); - $mgr->run_post_response_hooks unless $dry_run; + $mgr->run_post_response_hooks unless $$options{dry_run}; return undef; } # xacts managed within sub activate_purchase_order_impl { - my ($mgr, $po_id, $vandelay, $dry_run, $options) = @_; + my ($mgr, $po_id, $vandelay, $options) = @_; + $options ||= {}; + my $dry_run = $$options{dry_run}; + my $no_assets = $$options{no_assets}; # read-only until lineitem asset creation my $e = $mgr->editor; @@ -2636,9 +2639,11 @@ sub activate_purchase_order_impl { my $li_ids = $e->search_acq_lineitem($query, {idlist => 1}); - my $vl_resp; # imported li's and the queue the managing queue - if (!$dry_run) { + my $vl_resp; # imported li's and the managing queue + unless ($dry_run or $no_assets) { $e->rollback; # read-only thus far + + # list_assets manages its own transactions $vl_resp = create_lineitem_list_assets($mgr, $li_ids, $vandelay) or return OpenILS::Event->new('ACQ_LI_IMPORT_FAILED'); $e->xact_begin; @@ -2649,7 +2654,7 @@ sub activate_purchase_order_impl { for my $li_id (@$li_ids) { my $li = $e->retrieve_acq_lineitem($li_id); - if (!$li->eg_bib_id and !$dry_run) { + unless ($li->eg_bib_id or $dry_run or $no_assets) { # we encountered a lineitem that was not successfully imported. # we cannot continue. rollback and report. $e->rollback; @@ -2659,7 +2664,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, $options) or return $e->die_event; + create_lineitem_debits($mgr, $li, $dry_run) 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 143a9d2c31..ab1ba88922 100644 --- a/Open-ILS/src/templates/acq/po/view.tt2 +++ b/Open-ILS/src/templates/acq/po/view.tt2 @@ -21,7 +21,15 @@ [% l('Activatable?') %] - + diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index d95fc4f8a7..dd7e8544b4 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -57,6 +57,7 @@ "PO_COULD_ACTIVATE" : "Yes.", "PO_WARNING_NO_BLOCK_ACTIVATION" : "Yes; fund ${0} (${1}) would be encumbered beyond its warning level.", "PO_STOP_BLOCKS_ACTIVATION" : "No; fund ${0} (${1}) would be encumbered beyond its stop level.", + "PO_ALREADY_ACTIVATED" : "Activated", "PO_FUND_WARNING_CONFIRM" : "Are you sure? Did you see the warning about over-encumbering a fund?", "CONFIRM_FUNDS_AT_STOP" : "One or more of the selected funds has a balance below its stop level.\nYou may not be able to activate purchase orders incorporating these copies.\nContinue?", "CONFIRM_FUNDS_AT_WARNING" : "One or more of the selected funds has a balance below its warning level.\nContinue?", diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 0159b5b6b2..f1ef20cc41 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -366,7 +366,11 @@ function renderPo() { if (PO.lineitem_count() > 1) openils.Util.show("acq-po-split"); } else { - dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.NO; + if (PO.order_date()) { + dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.PO_ALREADY_ACTIVATED; + } else { + dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.NO; + } } // XXX we probably don't *always* need to do this... @@ -493,7 +497,7 @@ function init2() { function checkCouldActivatePo() { var d = dojo.byId("acq-po-activate-checking"); - var a = dojo.byId("acq-po-activate-link"); /* not now, but no diff */ + var a = dojo.byId("acq-po-activate-links"); /* not now, but no diff */ d.innerHTML = localeStrings.PO_CHECKING; var warnings = []; var stops = []; @@ -579,8 +583,9 @@ function checkCouldActivatePo() { ); } -function activatePo() { +function activatePo(noAssets) { activatePoButton.attr("disabled", true); + activatePoNoAssetsButton.attr("disabled", true); if (openils.Util.isTrue(PO.prepayment_required())) { if (!confirm(localeStrings.PREPAYMENT_REQUIRED_REMINDER)) { @@ -596,10 +601,15 @@ function activatePo() { } } - liTable.showAssetCreator(activatePoStage2); + if (noAssets) { + // no need for AssetCreator when assets are not desired + activatePoStage2(true); + } else { + liTable.showAssetCreator(activatePoStage2); + } } -function activatePoStage2() { +function activatePoStage2(noAssets) { var want_refresh = false; progressDialog.show(true); @@ -610,7 +620,10 @@ function activatePoStage2() { openils.User.authtoken, PO.id(), null, // vandelay options - {zero_copy_activate : dojo.byId('acq-po-activate-zero-copies').checked} + { + no_assets : noAssets, // no bibs/volumes/copies required + zero_copy_activate : dojo.byId('acq-po-activate-zero-copies').checked + } ], "onresponse": function(r) { progressDialog.hide(); -- 2.43.2