[open-ils-commits] [GIT] Evergreen ILS branch master updated. 827c7f915a1175f663e4c9371e6883a3bb7784b1
Evergreen Git
git at git.evergreen-ils.org
Tue Jul 24 10:28:46 EDT 2012
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 827c7f915a1175f663e4c9371e6883a3bb7784b1 (commit)
via a0f9b77361a434c42ce39eb88661c7926d158395 (commit)
from 37953470cdd9b9a7441722275aeead3c232d1466 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 827c7f915a1175f663e4c9371e6883a3bb7784b1
Author: Bill Erickson <berick at esilibrary.com>
Date: Tue Jul 10 16:29:39 2012 -0400
Show zero-copy lineitem's in zero-copy activation warning
When PO activation fails as a result of zero-copy lineitems, show the
IDs of the zero-copy lineitems along with the failure message.
This adds a new API call
open-ils.acq.purchase_order.no_copy_lineitems.id_list(auth, po_id)
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
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 8116ca3..6e4711e 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -3390,5 +3390,44 @@ sub add_li_to_po {
return {success => 1};
}
+__PACKAGE__->register_method(
+ method => 'po_lineitems_no_copies',
+ api_name => 'open-ils.acq.purchase_order.no_copy_lineitems.id_list',
+ stream => 1,
+ authoritative => 1,
+ signature => {
+ desc => q/Returns the set of lineitem IDs for a given PO that have no copies attached/,
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'The purchase order id', type => 'number'},
+ ],
+ return => {desc => 'Stream of lineitem IDs on success, event on error'}
+ }
+);
+
+sub po_lineitems_no_copies {
+ my ($self, $conn, $auth, $po_id) = @_;
+
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
+
+ # first check the view perms for LI's attached to this PO
+ my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->event;
+ return $e->event unless $e->allowed('VIEW_PURCHASE_ORDER', $po->ordering_agency);
+
+ my $ids = $e->json_query({
+ select => {jub => ['id']},
+ from => {jub => {acqlid => {type => 'left'}}},
+ where => {
+ '+jub' => {purchase_order => $po_id},
+ '+acqlid' => {lineitem => undef}
+ }
+ });
+
+ $conn->respond($_->{id}) for @$ids;
+ return undef;
+}
+
+
1;
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 626e5ce..53acfa4 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
@@ -481,6 +481,21 @@ function checkCouldActivatePo() {
d.innerHTML = localeStrings.NO + ": " +
other[0].desc + " (" + other[0].textcode + ")";
openils.Util.hide(a);
+
+ if (other[0].textcode == 'ACQ_LINEITEM_NO_COPIES') {
+ // when LIs w/ zero LIDs are present, list them
+ fieldmapper.standardRequest(
+ [ 'open-ils.acq',
+ 'open-ils.acq.purchase_order.no_copy_lineitems.id_list.authoritative.atomic' ],
+ { async : true,
+ params : [openils.User.authtoken, poId],
+ oncomplete : function(r) {
+ var ids = openils.Util.readResponse(r);
+ d.innerHTML += ' (' + ids + ')';
+ }
+ }
+ );
+ }
} else if (stops.length) {
d.innerHTML =
dojo.string.substitute(
commit a0f9b77361a434c42ce39eb88661c7926d158395
Author: Bill Erickson <berick at esilibrary.com>
Date: Tue Jul 10 11:56:05 2012 -0400
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 <berick at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
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 ec94c04..8116ca3 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 ec2c9ea..605ad7a 100644
--- a/Open-ILS/src/templates/acq/po/view.tt2
+++ b/Open-ILS/src/templates/acq/po/view.tt2
@@ -105,6 +105,11 @@
</td>
</tr>
<tr>
+ <th></th>
+ <td></td>
+ <th>[% l('Allow activation with <br/> zero-copy lineitems') %]</th>
+ <td><input type='checkbox' id='acq-po-activate-zero-copies' onclick='checkCouldActivatePo()'/></td>
+ <tr>
<td colspan='3'>
<a class="hidden" id="acq-po-split" href="javascript:void(0);"
onclick="if (confirm(localeStrings.CONFIRM_SPLIT_PO)) splitPo();">
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 ed4d55e..626e5ce 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
@@ -446,7 +446,12 @@ function checkCouldActivatePo() {
fieldmapper.standardRequest(
["open-ils.acq", "open-ils.acq.purchase_order.activate.dry_run"], {
- "params": [openils.User.authtoken, PO.id()],
+ "params": [
+ openils.User.authtoken,
+ PO.id(),
+ null, // vandelay options
+ {zero_copy_activate : dojo.byId('acq-po-activate-zero-copies').checked}
+ ],
"async": true,
"onresponse": function(r) {
if ((r = openils.Util.readResponse(r, true /* eventOk */))) {
@@ -523,7 +528,12 @@ function activatePoStage2() {
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(),
+ null, // vandelay options
+ {zero_copy_activate : dojo.byId('acq-po-activate-zero-copies').checked}
+ ],
"onresponse": function(r) {
want_refresh = Boolean(openils.Util.readResponse(r));
},
-----------------------------------------------------------------------
Summary of changes:
.../perlmods/lib/OpenILS/Application/Acq/Order.pm | 57 ++++++++++++++++++--
Open-ILS/src/templates/acq/po/view.tt2 | 5 ++
Open-ILS/web/js/ui/default/acq/po/view_po.js | 29 +++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list