added lineitem update and retrieve methods
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 11 Mar 2008 01:01:15 +0000 (01:01 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 11 Mar 2008 01:01:15 +0000 (01:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8957 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm

index 6313a84..3c88de4 100644 (file)
@@ -758,7 +758,7 @@ __PACKAGE__->register_method(
             Additionally creates the associated fund_debit/,
         params => [
             {desc => 'Authentication token', type => 'string'},
-            {desc => 'purchase order line item to create', type => 'object'},
+            {desc => 'lineitem_detail to create', type => 'object'},
             {desc => q/Options hash.  fund_id, the fund funding this line item
                 price, the price we are paying the vendor, in the vendor's currency/, type => 'hash'}
         ],
@@ -861,5 +861,66 @@ sub retrieve_lineitem {
 }
 =cut
 
+__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;
+
+    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
+
+    $e->update_acq_lineitem_detail($li_detail) or return $e->die_event;
+    $e->commit;
+    return 1;
+}
+
 
+__PACKAGE__->register_method(
+       method => 'retrieve_lineitem_detail',
+       api_name        => 'open-ils.acq.lineitem_detail.retrieve',
+       signature => {
+        desc => q/Updates a lineitem detail/,
+        params => [
+            {desc => 'Authentication token', type => 'string'},
+            {desc => 'lineitem_detail to retrieve', type => 'object'},
+        ],
+        return => {desc => '1 on success, Event on failure'}
+    }
+);
+sub retrieve_lineitem_detail {
+    my($self, $conn, $auth, $li_detail_id) = @_;
+    my $e = new_editor(authtoken=>$auth);
+    return $e->event unless $e->checkauth;
+
+    my $li_detail = $e->retrieve_acq_lineitem_detail($li_detail_id)
+        or return $e->event;
+
+    if($li_detail->fund) {
+        my $fund = $e->retrieve_acq_fund($li_detail->fund) or return $e->event;
+        return $e->event unless 
+            $e->allowed('MANAGE_FUND', $fund->org, $fund);
+    }
+
+    # XXX check lineitem perms
+    return $li_detail;
+}
 1;
+