From: Bill Erickson Date: Tue, 27 Nov 2012 20:26:48 +0000 (-0500) Subject: Support PO activation w/o loading items X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=08ac64caf47de7d5e6ff5d0a7f8c8a0a53f81cb2;p=working%2FEvergreen.git 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 --- 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 7c66162f4a..38cd2a72f0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -2410,21 +2410,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; @@ -2447,9 +2450,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; @@ -2460,7 +2465,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; @@ -2470,7 +2475,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 1baf68a7b4..72b74c14d1 100644 --- a/Open-ILS/src/templates/acq/po/view.tt2 +++ b/Open-ILS/src/templates/acq/po/view.tt2 @@ -21,7 +21,15 @@ 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 fd7949ff84..e9d33ee7c2 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -56,6 +56,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 4c2a7e712f..777b39bf23 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 @@ -338,7 +338,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... @@ -461,7 +465,7 @@ function init() { function checkCouldActivatePo() { var d = dojo.byId("acq-po-activate-checking"); - var a = dojo.byId("acq-po-activate-link"); + var a = dojo.byId("acq-po-activate-links"); d.innerHTML = localeStrings.PO_CHECKING; var warnings = []; var stops = []; @@ -545,7 +549,7 @@ function checkCouldActivatePo() { ); } -function activatePo() { +function activatePo(noAssets) { if (openils.Util.isTrue(PO.prepayment_required())) { if (!confirm(localeStrings.PREPAYMENT_REQUIRED_REMINDER)) return false; @@ -556,10 +560,15 @@ function activatePo() { return false; } - 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); @@ -570,7 +579,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) { want_refresh = Boolean(openils.Util.readResponse(r));