@@ -, +, @@ GetMarcItemFieldsToOrderValues --- Koha/Acquisition/Utils.pm | 8 ++++---- acqui/addorderiso2709.pl | 2 +- acqui/neworderempty.pl | 2 +- t/Acquisition/Utils.t | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) --- a/Koha/Acquisition/Utils.pm +++ a/Koha/Acquisition/Utils.pm @@ -65,9 +65,9 @@ sub get_infos_syspref { return $r; } -=head3 get_infos_syspref_on_item($syspref_name, $record, $field_list) +=head3 GetMarcItemFieldsToOrderValues($syspref_name, $record, $field_list) -my $data = get_infos_syspref_on_item('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); +my $data = GetMarcItemFieldsToOrderValues('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); This subroutine accepts a syspref ( MarcItemFieldsToOrder ), a marc record, and an arrayref of fields to retrieve. @@ -76,13 +76,13 @@ The return value is a hashref of key value pairs, where the keys are the field l and the values are extracted from the MARC record based on the key to MARC field mapping from the given system preference. -The largest difference between get_infos_syspref and get_infos_syspref_on_item is that the former deals +The largest difference between get_infos_syspref and GetMarcItemFieldsToOrderValues is that the former deals with singular marc fields, while the latter works on multiple matching marc fields and returns -1 if it cannot find a matching number of all fields to be looked up. =cut -sub get_infos_syspref_on_item { +sub GetMarcItemFieldsToOrderValues { my ($syspref_name, $record, $field_list) = @_; my $syspref = C4::Context->preference($syspref_name); $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt --- a/acqui/addorderiso2709.pl +++ a/acqui/addorderiso2709.pl @@ -532,7 +532,7 @@ sub import_biblios_list { # Items my @itemlist = (); my $all_items_quantity = 0; - my $alliteminfos = C4::Acquisition::Utils::get_infos_syspref_on_item('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); + my $alliteminfos = C4::Acquisition::Utils::GetMarcItemFieldsToOrderValues('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); if ($alliteminfos != -1) { foreach my $iteminfos (@$alliteminfos) { my $item_homebranch = $iteminfos->{homebranch}; --- a/acqui/neworderempty.pl +++ a/acqui/neworderempty.pl @@ -637,7 +637,7 @@ sub staged_items_field { # Items my @itemlist = (); my $all_items_quantity = 0; - my $alliteminfos = C4::Acquisition::Utils::get_infos_syspref_on_item('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); + my $alliteminfos = C4::Acquisition::Utils::GetMarcItemFieldsToOrderValues('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']); if ($alliteminfos != -1) { foreach my $iteminfos (@$alliteminfos) { my %itemrecord=( --- a/t/Acquisition/Utils.t +++ a/t/Acquisition/Utils.t @@ -63,7 +63,7 @@ test4: 541$a is( $data->{test4}, "Test 4", "Got test 4 correctly" ); }; -subtest "get_infos_syspref_on_item" => sub { +subtest "GetMarcItemFieldsToOrderValues" => sub { plan tests => 13; my $record = MARC::Record->new; @@ -85,7 +85,7 @@ testC: 976$a testD: 976$b }; t::lib::Mocks::mock_preference('MarcItemFieldsToOrder', $MarcItemFieldsToOrder); - my $data = Koha::Acquisition::Utils::get_infos_syspref_on_item( + my $data = Koha::Acquisition::Utils::GetMarcItemFieldsToOrderValues( 'MarcItemFieldsToOrder', $record, [ 'testA', 'testB', 'testC', 'testD' ] @@ -116,7 +116,7 @@ testD: 976$b MARC::Field->new( '976', '', '', a => 'Test 11', b => "Test 12" ), ); - $data = Koha::Acquisition::Utils::get_infos_syspref_on_item( + $data = Koha::Acquisition::Utils::GetMarcItemFieldsToOrderValues( 'MarcItemFieldsToOrder', $record, [ 'testA', 'testB', 'testC', 'testD' ] --