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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 15 15:32:30 EDT 2009


Author: erickson
Date: 2009-04-15 15:32:27 -0400 (Wed, 15 Apr 2009)
New Revision: 12883

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
Log:
moved li_detail CUD into order.  removed old lid code

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2009-04-15 16:09:30 UTC (rev 12882)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2009-04-15 19:32:27 UTC (rev 12883)
@@ -354,31 +354,7 @@
 }
 
 
-__PACKAGE__->register_method(
-	method => 'create_lineitem_detail',
-	api_name	=> 'open-ils.acq.lineitem_detail.create',
-	signature => {
-        desc => q/Creates a new purchase order line item detail.  
-            Additionally creates the associated fund_debit/,
-        params => [
-            {desc => 'Authentication token', type => 'string'},
-            {desc => 'lineitem_detail to create', type => 'object'},
-        ],
-        return => {desc => 'The purchase order line item detail id, Event on failure'}
-    }
-);
 
-sub create_lineitem_detail {
-    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',
@@ -463,50 +439,6 @@
 }
 
 
-
-__PACKAGE__->register_method(
-	method => 'update_lineitem_detail',
-	api_name	=> 'open-ils.acq.lineitem_detail.update',
-	signature => {
-        desc => q/Updates a lineitem detail/,
-        params => [
-            {desc => 'Authentication token', type => 'string'},
-            {desc => 'lineitem_detail to update', type => 'object'},
-        ],
-        return => {desc => '1 on success, Event on failure'}
-    }
-);
-
-sub update_lineitem_detail {
-    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 
-            $e->allowed('MANAGE_FUND', $fund->org, $fund);
-    }
-
-    # XXX check lineitem perms
-
-    my $li = $e->retrieve_acq_lineitem($li_detail->lineitem)
-        or return $e->die_event;
-    my $evt = update_li_edit_time($e, $li);
-    return $evt if $evt;
-
-    $e->update_acq_lineitem_detail($li_detail) or return $e->die_event;
-    return 1;
-}
-
 sub update_li_edit_time {
     my ($e, $li) = @_;
     # some lineitem edits are allowed after approval time...
@@ -520,54 +452,6 @@
 
 
 __PACKAGE__->register_method(
-	method => 'delete_lineitem_detail',
-	api_name	=> 'open-ils.acq.lineitem_detail.delete',
-	signature => {
-        desc => q/Deletes a lineitem detail/,
-        params => [
-            {desc => 'Authentication token', type => 'string'},
-            {desc => 'lineitem_detail ID to delete', type => 'number'},
-        ],
-        return => {desc => '1 on success, Event on failure'}
-    }
-);
-
-sub delete_lineitem_detail {
-    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,
-            flesh_fields => {acqlid => ['lineitem']}
-        }
-    ]) or return $e->die_event;
-
-    my $li = $li_detail->lineitem;
-
-    my $evt = update_li_edit_time($e, $li);
-    return $evt if $evt;
-
-    return OpenILS::Event->new('BAD_PARAMS') unless 
-        $li->state =~ /new|approved/;
-
-    # XXX check lineitem perms
-
-    $e->delete_acq_lineitem_detail($li_detail) or return $e->die_event;
-    return 1;
-}
-
-
-__PACKAGE__->register_method(
 	method => 'retrieve_lineitem_detail',
 	api_name	=> 'open-ils.acq.lineitem_detail.retrieve',
 	signature => {

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm	2009-04-15 16:09:30 UTC (rev 12882)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm	2009-04-15 19:32:27 UTC (rev 12883)
@@ -53,6 +53,7 @@
 sub total {
     my($self, $val) = @_;
     $self->{args}->{total} = $val if defined $val;
+    $self->{args}->{maximum} = $self->{args}->{total};
     return $self->{args}->{total};
 }
 sub purchase_order {
@@ -1161,4 +1162,61 @@
 }
 
 
+__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) = @_;
+
+    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, 
+        throttle => 5
+    );
+
+    # XXX perms
+
+    $mgr->total(scalar(@$li_details));
+    
+    my %li_cache;
+
+    for my $lid (@$li_details) {
+
+        my $li = $li_cache{$lid->lineitem} || $e->retrieve_acq_lineitem($lid->lineitem);
+
+        if($lid->isnew) {
+            create_lineitem_detail($mgr, %{$lid->to_bare_hash}) or return $e->die_event;
+
+        } elsif($lid->ischanged) {
+            $e->update_acq_lineitem_detail($lid) or return $e->die_event;
+
+        } elsif($lid->isdeleted) {
+            delete_lineitem_detail($mgr, $lid) or return $e->die_event;
+        }
+
+        $mgr->respond(li => $li);
+        $li_cache{$lid->lineitem} = $li;
+    }
+
+    $e->commit;
+    return $mgr->respond_complete;
+}
+
+
+
 1;



More information about the open-ils-commits mailing list