[open-ils-commits] r9905 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Jun 21 12:05:14 EDT 2008
Author: erickson
Date: 2008-06-21 12:05:12 -0400 (Sat, 21 Jun 2008)
New Revision: 9905
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
Log:
added method to create bibs/assets for all lineitems for a given PO
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm 2008-06-20 20:39:21 UTC (rev 9904)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm 2008-06-21 16:05:12 UTC (rev 9905)
@@ -59,7 +59,49 @@
return $li->id;
}
+__PACKAGE__->register_method(
+ method => 'create_po_assets',
+ api_name => 'open-ils.acq.purchase_order.assets.create',
+ signature => {
+ desc => q/Creates assets for each lineitem in the purchase order/,
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'The purchase order id', type => 'number'},
+ {desc => q/Options hash./}
+ ],
+ return => {desc => 'Streams a total versus completed counts object, event on error'}
+ }
+);
+sub create_po_assets {
+ my($self, $conn, $auth, $po_id, $options) = @_;
+ my $e = new_editor(authtoken=>$auth, xact=>1);
+ return $e->die_event unless $e->checkauth;
+
+ my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->event;
+ return $e->die_event unless
+ $e->allowed('CREATE_PURCHASE_ORDER', $po->ordering_agency);
+
+ my $li_ids = $e->search_acq_lineitem({purchase_order=>$po_id},{idlist=>1});
+ my $total = @$li_ids;
+ my $count = 0;
+
+ for my $li_id (@$li_ids) {
+ my $resp = create_lineitem_assets_impl($e, $auth, $li_id);
+ if($U->event_code($resp)) {
+ $e->rollback;
+ return $resp;
+ }
+ $conn->respond({total=>$count, progress=>++$count});
+ }
+
+ $po->edit_time('now');
+ $e->update_acq_purchase_order($po) or return $e->die_event;
+ $e->commit;
+
+ return {complete=>1};
+}
+
__PACKAGE__->register_method(
method => 'create_lineitem_assets',
api_name => 'open-ils.acq.lineitem.assets.create',
@@ -78,7 +120,17 @@
my($self, $conn, $auth, $li_id, $options) = @_;
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
+ my $resp = create_lineitem_assets_impl($e, $auth, $li_id, $options);
+ if($U->event_code($resp)) {
+ $e->rollback;
+ return $resp;
+ }
+ $e->commit;
+ return $resp;
+}
+sub create_lineitem_assets_impl {
+ my($e, $auth, $li_id, $options) = @_;
my $li = $e->retrieve_acq_lineitem([
$li_id,
{ flesh => 1,
@@ -160,7 +212,6 @@
$e->update_acq_lineitem_detail($li_detail) or return $e->die_event;
}
- $e->commit;
return 1;
}
More information about the open-ils-commits
mailing list