[open-ils-commits] r12892 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/dojo/openils/acq/nls web/js/ui/default/acq/common web/templates/default/acq/common (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 16 11:29:56 EDT 2009
Author: erickson
Date: 2009-04-16 11:29:54 -0400 (Thu, 16 Apr 2009)
New Revision: 12892
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
implemented PO receive rollback and api's for li and lid rollback. li/lid ui to come
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2009-04-16 14:56:01 UTC (rev 12891)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2009-04-16 15:29:54 UTC (rev 12892)
@@ -276,6 +276,22 @@
return check_purchase_order_received($mgr, $li->purchase_order);
}
+sub rollback_receive_lineitem {
+ my($mgr, $li_id) = @_;
+ my $li = $mgr->editor->retrieve_acq_lineitem($li_id) or return 0;
+
+ my $lid_ids = $mgr->editor->search_acq_lineitem_detail(
+ {lineitem => $li_id, recv_time => {'!=' => undef}}, {idlist => 1});
+
+ for my $lid_id (@$lid_ids) {
+ rollback_receive_lineitem_detail($mgr, $lid_id, 1) or return 0;
+ }
+
+ $mgr->add_li;
+ $li->state('on-order');
+ return update_lineitem($mgr, $li);
+}
+
# ----------------------------------------------------------------------------
# Lineitem Detail
# ----------------------------------------------------------------------------
@@ -367,6 +383,39 @@
}
+sub rollback_receive_lineitem_detail {
+ my($mgr, $lid_id) = @_;
+ my $e = $mgr->editor;
+
+ my $lid = $e->retrieve_acq_lineitem_detail([
+ $lid_id,
+ { flesh => 1,
+ flesh_fields => {
+ acqlid => ['fund_debit']
+ }
+ }
+ ]) or return 0;
+
+ return 1 unless $lid->recv_time;
+
+ $lid->clear_recv_time;
+ $e->update_acq_lineitem_detail($lid) or return 0;
+
+ my $copy = $e->retrieve_asset_copy($lid->eg_copy_id) or return 0;
+ $copy->status(OILS_COPY_STATUS_ON_ORDER);
+ $copy->edit_date('now');
+ $copy->editor($e->requestor->id);
+ $e->update_asset_copy($copy) or return 0;
+
+ if($lid->fund_debit) {
+ $lid->fund_debit->encumbrance('t');
+ $e->update_acq_fund_debit($lid->fund_debit) or return 0;
+ }
+
+ $mgr->add_lid;
+ return $lid;
+}
+
# ----------------------------------------------------------------------------
# Lineitem Attr
# ----------------------------------------------------------------------------
@@ -1296,11 +1345,11 @@
__PACKAGE__->register_method(
- method => 'receive_po',
+ method => 'receive_po_api',
api_name => 'open-ils.acq.purchase_order.receive'
);
-sub receive_po {
+sub receive_po_api {
my($self, $conn, $auth, $po_id) = @_;
my $e = new_editor(xact => 1, authtoken => $auth);
return $e->die_event unless $e->checkauth;
@@ -1400,5 +1449,118 @@
}
+__PACKAGE__->register_method(
+ method => 'rollback_receive_po_api',
+ api_name => 'open-ils.acq.purchase_order.receive.rollback'
+);
+sub rollback_receive_po_api {
+ my($self, $conn, $auth, $po_id) = @_;
+ 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 $po = $e->retrieve_acq_purchase_order($po_id) or return $e->die_event;
+ return $e->die_event unless $e->allowed('RECEIVE_PURCHASE_ORDER', $po->ordering_agency);
+
+ my $li_ids = $e->search_acq_lineitem({purchase_order => $po_id}, {idlist => 1});
+
+ for my $li_id (@$li_ids) {
+ rollback_receive_lineitem($mgr, $li_id) or return $e->die_event;
+ $mgr->respond;
+ }
+
+ $po->state('on-order');
+ update_purchase_order($mgr, $po) or return $e->die_event;
+
+ $e->commit;
+ return $mgr->respond_complete;
+}
+
+
+__PACKAGE__->register_method(
+ method => 'rollback_receive_lineitem_detail_api',
+ api_name => 'open-ils.acq.lineitem_detail.receive.rollback',
+ signature => {
+ desc => 'Mark a lineitem_detail as received',
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'lineitem detail ID', type => 'number'}
+ ],
+ return => {desc => '1 on success, Event on error'}
+ }
+);
+
+sub rollback_receive_lineitem_detail_api {
+ my($self, $conn, $auth, $lid_id) = @_;
+
+ 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 $lid = $e->retrieve_acq_lineitem_detail([
+ $lid_id, {
+ flesh => 2,
+ flesh_fields => {
+ acqlid => ['lineitem'],
+ jub => ['purchase_order']
+ }
+ }
+ ]);
+ my $li = $lid->lineitem;
+ my $po = $li->purchase_order;
+
+ return $e->die_event unless $e->allowed('RECEIVE_PURCHASE_ORDER', $po->ordering_agency);
+ rollback_receive_lineitem_detail($mgr, $lid_id) or return $e->die_event;
+
+ $li->state('on-order');
+ $po->state('on-order');
+ udpate_lineitem($mgr, $li) or return $e->die_event;
+ udpate_purchase_order($mgr, $po) or return $e->die_event;
+
+ $e->commit;
+ return 1;
+}
+
+__PACKAGE__->register_method(
+ method => 'rollback_receive_lineitem_api',
+ api_name => 'open-ils.acq.lineitem.receive.rollback',
+ signature => {
+ desc => 'Mark a lineitem as received',
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'lineitem detail ID', type => 'number'}
+ ],
+ return => {desc => '1 on success, Event on error'}
+ }
+);
+
+sub rollback_receive_lineitem_api {
+ my($self, $conn, $auth, $li_id) = @_;
+
+ 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 $li = $e->retrieve_acq_lineitem_detail([
+ $li_id, {
+ flesh => 1,
+ flesh_fields => {
+ jub => ['purchase_order']
+ }
+ }
+ ]);
+ my $po = $li->purchase_order;
+
+ return $e->die_event unless $e->allowed('RECEIVE_PURCHASE_ORDER', $po->ordering_agency);
+
+ rollback_receive_lineitem($mgr, $li_id) or return $e->die_event;
+
+ $po->state('on-order');
+ update_purchase_order($mgr, $po) or return $e->die_event;
+
+ $e->commit;
+ return 1;
+}
+
1;
Modified: trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js 2009-04-16 14:56:01 UTC (rev 12891)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js 2009-04-16 15:29:54 UTC (rev 12892)
@@ -1,3 +1,4 @@
{
- 'CREATE_PO_ASSETS_CONFIRM' : "This will create bibliographic, call number, and copy records for this purchase order in the ILS.\n\nContinue?"
+ 'CREATE_PO_ASSETS_CONFIRM' : "This will create bibliographic, call number, and copy records for this purchase order in the ILS.\n\nContinue?",
+ 'ROLLBACK_PO_RECEIVE_CONFIRM' : "This will rollback receipt of all copies for this purchase order.\n\nContinue?"
}
Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-04-16 14:56:01 UTC (rev 12891)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-04-16 15:29:54 UTC (rev 12892)
@@ -485,6 +485,10 @@
this.receivePO();
break;
+ case 'rollback_receive_po':
+ this.rollbackPoReceive();
+ break;
+
case 'create_assets':
this.createAssets();
break;
@@ -544,6 +548,23 @@
);
}
+ this.rollbackPoReceive = function() {
+ if(!this.isPO) return;
+ if(!confirm(localeStrings.ROLLBACK_PO_RECEIVE_CONFIRM)) return;
+ this.show('acq-lit-progress-numbers');
+ var self = this;
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.purchase_order.receive.rollback'],
+ { async: true,
+ params: [this.authtoken, this.isPO],
+ onresponse : function(r) {
+ var resp = openils.Util.readResponse(r);
+ self._updateProgressNumbers(resp, true);
+ },
+ }
+ );
+ }
+
this._updateProgressNumbers = function(resp, reloadOnComplete) {
if(!resp) return;
dojo.byId('acq-pl-lit-li-processed').innerHTML = resp.li;
Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-04-16 14:56:01 UTC (rev 12891)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-04-16 15:29:54 UTC (rev 12892)
@@ -18,6 +18,7 @@
<option mask='pl' value='order_ready'>Mark Ready for Order</option>
<option mask='pl' value='create_order'>Create Purchase Order</option>
<option mask='po' value='receive_po'>Mark Purchase Order as Received</option>
+ <option mask='po' value='rollback_receive_po'>Un-Receive Purchase Order</option>
<option mask='po' value='print_po'>Print Purchase Order</option>
<option mask='po' value='create_assets'>Create PO Assets</option>
<option mask='*' value='delete_selected'>Delete Selected Items</option>
More information about the open-ils-commits
mailing list