Support PO activation w/o loading items
authorBill Erickson <berick@esilibrary.com>
Wed, 24 Aug 2011 21:45:15 +0000 (17:45 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 25 Aug 2011 14:35:16 +0000 (10:35 -0400)
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 <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/po/view_po.js
Open-ILS/web/templates/default/acq/common/li_table.tt2
Open-ILS/web/templates/default/acq/po/view.tt2

index 7313cc1..22cca5f 100644 (file)
@@ -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
index 0525d48..f5a64c3 100644 (file)
@@ -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?",
index 8e510f9..77cde21 100644 (file)
@@ -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));
             },
index 1851833..f038cf9 100644 (file)
                             </tbody>
                         </table>
                     </td>
-                    <td><a title='FOOOBAR' name='copieslink' href='javascript:void(0);'>Copies(<span name='count'>0</span>)</a></td>
+                    <td><a title='Copies' name='copieslink' href='javascript:void(0);'>Copies(<span name='count'>0</span>)</a></td>
                     <td>
                         <a name='noteslink' href='javascript:void(0);'>Notes(<span name='notes_count'>0</span>)</a><span name="notes_alert_flag"></span>
                     </td>
index bfbc776..30fb2a0 100644 (file)
                     <th>Activatable?</th>
                     <td>
                         <span id="acq-po-activate-checking"></span>
-                        <a class="hidden" id="acq-po-activate-link" href="javascript:void(0);" onclick="activatePo()">Activate Order</a>
+                        <span class="hidden" id="acq-po-activate-links" style='padding: 5px'>
+                            <a href="javascript:;" onclick="activatePo()">Activate Order</a>
+                            <span style='padding: 5px;'> / </span>
+                            <a href="javascript:;" onclick="activatePo(true)">Activate Without Loading Items</a>
+                        </span>
                     </td>
                 </tr>
                 <tr>