From 3e03b3cc6bbf0c9b51c97c9b77f3a059a3af7cf4 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 14 Jun 2021 17:35:21 -0400 Subject: [PATCH] LP1929741 Apply default lineitem order identifers Apply a default order identifier to lineitems instead of leaving the selector blank. Ensure the value that will display in the selector matches what's in the database by setting the value on load when needed. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- .../src/app/staff/acq/lineitem/lineitem.service.ts | 3 ++- .../lib/OpenILS/Application/Acq/Lineitem.pm | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts index f669555181..e3202947ef 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts @@ -101,7 +101,8 @@ export class LineitemService { flesh_pl: true, flesh_formulas: true, flesh_copies: true, - clear_marc: false + clear_marc: false, + apply_order_identifiers: true }, params.fleshMore || {}); return this.net.request( diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm index e510286adc..60eeb59e03 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm @@ -265,9 +265,13 @@ sub retrieve_lineitem_batch { return $e->die_event unless $e->checkauth; for my $li_id (@$li_ids) { + my $li = retrieve_lineitem_impl($e, $li_id, $options); + + set_default_order_ident($self, $e, $options, $li); + $client->respond({ id => $li_id, - lineitem => retrieve_lineitem_impl($e, $li_id, $options), + lineitem => $li, existing_copies => $AC->li_existing_copies($e, $li_id) }); } @@ -277,6 +281,26 @@ sub retrieve_lineitem_batch { return undef; } +sub set_default_order_ident { + my ($self, $e, $options, $li) = @_; + + if (!$$options{flesh_attrs}) { return; } + if (!$$options{apply_order_identifiers}) { return; } + if (grep {$_->order_ident eq 't'} @{$li->attributes}) { return ; } + + # Caller wants us to apply a default order identifier + # Use the first ISBN as the default. + + my ($attr) = grep {$_->attr_name eq 'isbn'} @{$li->attributes}; + + if (!$attr) { return; } + + my $method = $self->method_lookup('open-ils.acq.lineitem.order_identifier.set'); + my ($ident_attr) = $method->run($e->authtoken, {source_attr_id => $attr->id}); + + push(@{$li->attributes}, $ident_attr); +} + __PACKAGE__->register_method( -- 2.11.0