From 492dd6a1ef0efde6fd968aa04429c45858864483 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 24 Aug 2011 17:45:15 -0400 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 --- .../src/perlmods/lib/OpenILS/Application/Acq/Order.pm | 19 +++++++++++++------ Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 1 + Open-ILS/web/js/ui/default/acq/po/view_po.js | 14 +++++++++----- .../web/templates/default/acq/common/li_table.tt2 | 2 +- Open-ILS/web/templates/default/acq/po/view.tt2 | 6 +++++- 5 files changed, 29 insertions(+), 13 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 7313cc1e7b..22cca5fce6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -2168,15 +2168,18 @@ __PACKAGE__->register_method( ); sub activate_purchase_order { - my($self, $conn, $auth, $po_id) = @_; + my($self, $conn, $auth, $po_id, $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(xact=>1, 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, $dry_run); + my $die_event = activate_purchase_order_impl($mgr, $po_id, $options); return $e->die_event if $die_event; - if ($dry_run) { + if ($$options{dry_run}) { $e->rollback; } else { $e->commit; @@ -2187,8 +2190,12 @@ sub activate_purchase_order { } sub activate_purchase_order_impl { - my ($mgr, $po_id, $dry_run) = @_; + my ($mgr, $po_id, $options) = @_; + $options ||= {}; + my $e = $mgr->editor; + my $dry_run = $$options{dry_run}; + my $no_assets = $$options{no_assets}; my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->die_event; return $e->die_event unless $e->allowed('CREATE_PURCHASE_ORDER', $po->ordering_agency); @@ -2210,7 +2217,7 @@ sub activate_purchase_order_impl { while( my $li_id = $e->search_acq_lineitem($query, {idlist => 1})->[0] ) { my $li; - if($dry_run) { + if($dry_run or $no_assets) { $li = $e->retrieve_acq_lineitem($li_id); } else { # can't activate a PO w/o assets. Create lineitem assets as necessary 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 0525d48e11..f5a64c372f 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -54,6 +54,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 8e510f956e..77cde210b8 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 @@ -337,7 +337,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... @@ -438,7 +442,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 = []; @@ -494,7 +498,7 @@ function checkCouldActivatePo() { warnings[0].payload.fund.year() ] ); - openils.Util.show(a, "inline"); + openils.Util.show(a, "inline") } } } @@ -502,7 +506,7 @@ function checkCouldActivatePo() { ); } -function activatePo() { +function activatePo(noAssets) { if (openils.Util.isTrue(PO.prepayment_required())) { if (!confirm(localeStrings.PREPAYMENT_REQUIRED_REMINDER)) return false; @@ -518,7 +522,7 @@ function activatePo() { fieldmapper.standardRequest( ["open-ils.acq", "open-ils.acq.purchase_order.activate"], { "async": true, - "params": [openils.User.authtoken, PO.id()], + "params": [openils.User.authtoken, PO.id(), {no_assets : noAssets}], "onresponse": function(r) { want_refresh = Boolean(openils.Util.readResponse(r)); }, diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index 1851833182..f038cf9787 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -110,7 +110,7 @@ - Copies(0) + Copies(0) Notes(0) diff --git a/Open-ILS/web/templates/default/acq/po/view.tt2 b/Open-ILS/web/templates/default/acq/po/view.tt2 index bfbc776dc4..30fb2a0db9 100644 --- a/Open-ILS/web/templates/default/acq/po/view.tt2 +++ b/Open-ILS/web/templates/default/acq/po/view.tt2 @@ -20,7 +20,11 @@ Activatable? - + -- 2.11.0