From: erickson Date: Tue, 11 Mar 2008 01:01:15 +0000 (+0000) Subject: added lineitem update and retrieve methods X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ee677f91d7b85b380f8eb3516ad9b12b48493453;p=Evergreen.git added lineitem update and retrieve methods git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8957 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm index 6313a8478d..3c88de48cd 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm @@ -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; +