}
-
-
-# this call duplicates a call in Order.pm and makes references to subs that don't exist.
-# TODO: Verify then remove.
-__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)
- or return $e->die_event;
-
- my $evt = update_li_edit_time($e, $li);
- return $evt if $evt;
-
- # XXX check lineitem provider perms
-
- 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);
- }
-
- $e->create_acq_lineitem_detail($li_detail) or return $e->die_event;
-
- unless($li_detail->barcode) {
- my $pfx = $U->ou_ancestor_setting_value($li_detail->owning_lib, 'acq.tmp_barcode_prefix') || 'ACQ';
- $li_detail->barcode($pfx.$li_detail->id);
- }
- unless($li_detail->cn_label) {
- my $pfx = $U->ou_ancestor_setting_value($li_detail->owning_lib, 'acq.tmp_callnumber_prefix') || 'ACQ';
- $li_detail->cn_label($pfx.$li_detail->id);
- }
-
- if(my $loc = $U->ou_ancestor_setting_value($li_detail->owning_lib, 'acq.default_copy_location')) {
- $li_detail->location($loc);
- }
-
- $e->update_acq_lineitem_detail($li_detail) or return $e->die_event;
-
- return $li_detail if $$options{return_obj};
- return $li_detail->id
-}
-
-
-sub update_li_edit_time {
- my ($e, $li) = @_;
- # some lineitem edits are allowed after approval time...
-# return OpenILS::Event->new('ACQ_LINEITEM_APPROVED', payload => $li->id)
-# if $li->state eq 'approved';
- $li->edit_time('now');
- $li->editor($e->requestor->id);
- $e->update_acq_lineitem($li) or return $e->die_event;
- return undef;
-}
-
-
__PACKAGE__->register_method(
method => 'retrieve_lineitem_detail',
api_name => 'open-ils.acq.lineitem_detail.retrieve',