[open-ils-commits] r12572 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Mar 18 10:43:32 EDT 2009


Author: erickson
Date: 2009-03-18 10:43:30 -0400 (Wed, 18 Mar 2009)
New Revision: 12572

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
Log:
added batch lineitem detail CUD method

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2009-03-18 12:51:48 UTC (rev 12571)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2009-03-18 14:43:30 UTC (rev 12572)
@@ -522,6 +522,59 @@
     my($self, $conn, $auth, $li_detail, $options) = @_;
     my $e = new_editor(xact=>1, authtoken=>$auth);
     return $e->die_event unless $e->checkauth;
+    my $res = create_lineitem_detail_impl($self, $conn, $e, $li_detail, $options);
+    return $e->event if $e->died;
+    $e->commit;
+    return $res;
+}
+
+
+__PACKAGE__->register_method(
+	method => 'lineitem_detail_CUD_batch',
+	api_name => 'open-ils.acq.lineitem_detail.cud.batch',
+    stream => 1,
+	signature => {
+        desc => q/Creates a new purchase order line item detail.  
+            Additionally creates the associated fund_debit/,
+        params => [
+            {desc => 'Authentication token', type => 'string'},
+            {desc => 'List of lineitem_details to create', type => 'array'},
+        ],
+        return => {desc => 'Streaming response of current position in the array'}
+    }
+);
+
+sub lineitem_detail_CUD_batch {
+    my($self, $conn, $auth, $li_details, $options) = @_;
+    my $e = new_editor(xact=>1, authtoken=>$auth);
+    return $e->die_event unless $e->checkauth;
+    my $pos = 0;
+    my $total = scalar(@$li_details);
+    for my $li_detail (@$li_details) {
+        my $res;
+
+        use Data::Dumper;
+        $logger->info(Dumper($li_detail));
+        $logger->info('lid id ' . $li_detail->id);
+        $logger->info('lineitem ' . $li_detail->lineitem);
+
+        if($li_detail->isnew) {
+            $res = create_lineitem_detail_impl($self, $conn, $e, $li_detail, $options);
+        } elsif($li_detail->ischanged) {
+            $res = update_lineitem_detail_impl($self, $conn, $e, $li_detail);
+        } elsif($li_detail->isdeleted) {
+            $res = delete_lineitem_detail_impl($self, $conn, $e, $li_detail->id);
+        }
+        return $e->event if $e->died;
+        $conn->respond({maximum => $total, progress => $pos++, li => $res});
+    }
+    $e->commit;
+    return {complete => 1};
+}
+
+
+sub create_lineitem_detail_impl {
+    my($self, $conn, $e, $li_detail, $options) = @_;
     $options ||= {};
 
     my $li = $e->retrieve_acq_lineitem($li_detail->lineitem)
@@ -560,6 +613,8 @@
     return $li_detail->id
 }
 
+
+
 __PACKAGE__->register_method(
 	method => 'update_lineitem_detail',
 	api_name	=> 'open-ils.acq.lineitem_detail.update',
@@ -577,7 +632,15 @@
     my($self, $conn, $auth, $li_detail) = @_;
     my $e = new_editor(xact=>1, authtoken=>$auth);
     return $e->die_event unless $e->checkauth;
+    my $res = update_lineitem_detail_impl($self, $conn, $e, $li_detail);
+    return $e->event if $e->died;
+    $e->commit;
+    return $res;
+}
 
+sub update_lineitem_detail_impl {
+    my($self, $conn, $e, $li_detail) = @_;
+
     if($li_detail->fund) {
         my $fund = $e->retrieve_acq_fund($li_detail->fund) or return $e->die_event;
         return $e->die_event unless 
@@ -625,6 +688,15 @@
     my($self, $conn, $auth, $li_detail_id) = @_;
     my $e = new_editor(xact=>1, authtoken=>$auth);
     return $e->die_event unless $e->checkauth;
+    my $res = delete_lineitem_detail_impl($self, $conn, $e, $li_detail_id);
+    return $e->event if $e->died;
+    $e->commit;
+    return $res;
+}
+
+sub delete_lineitem_detail_impl {
+    my($self, $conn, $e, $li_detail_id) = @_;
+
     my $li_detail = $e->retrieve_acq_lineitem_detail([
         $li_detail_id,
         {   flesh => 1,



More information about the open-ils-commits mailing list