View | Details | Raw Unified | Return to bug 20817
Collapse All | Expand All

(-)a/Koha/Acquisition/Utils.pm (-4 / +4 lines)
Lines 65-73 sub get_infos_syspref { Link Here
65
    return $r;
65
    return $r;
66
}
66
}
67
67
68
=head3 get_infos_syspref_on_item($syspref_name, $record, $field_list)
68
=head3 GetMarcItemFieldsToOrderValues($syspref_name, $record, $field_list)
69
69
70
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']);
70
my $data = GetMarcItemFieldsToOrderValues('MarcItemFieldsToOrder', $marcrecord, ['homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', 'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code']);
71
71
72
This subroutine accepts a syspref ( MarcItemFieldsToOrder ),
72
This subroutine accepts a syspref ( MarcItemFieldsToOrder ),
73
a marc record, and an arrayref of fields to retrieve.
73
a marc record, and an arrayref of fields to retrieve.
Lines 76-88 The return value is a hashref of key value pairs, where the keys are the field l Link Here
76
and the values are extracted from the MARC record based on the key to MARC field mapping from the
76
and the values are extracted from the MARC record based on the key to MARC field mapping from the
77
given system preference.
77
given system preference.
78
78
79
The largest difference between get_infos_syspref and get_infos_syspref_on_item is that the former deals
79
The largest difference between get_infos_syspref and GetMarcItemFieldsToOrderValues is that the former deals
80
with singular marc fields, while the latter works on multiple matching marc fields and returns -1 if it cannot
80
with singular marc fields, while the latter works on multiple matching marc fields and returns -1 if it cannot
81
find a matching number of all fields to be looked up.
81
find a matching number of all fields to be looked up.
82
82
83
=cut
83
=cut
84
84
85
sub get_infos_syspref_on_item {
85
sub GetMarcItemFieldsToOrderValues {
86
    my ($syspref_name, $record, $field_list) = @_;
86
    my ($syspref_name, $record, $field_list) = @_;
87
    my $syspref = C4::Context->preference($syspref_name);
87
    my $syspref = C4::Context->preference($syspref_name);
88
    $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt
88
    $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt
(-)a/acqui/addorderiso2709.pl (-1 / +1 lines)
Lines 532-538 sub import_biblios_list { Link Here
532
        # Items
532
        # Items
533
        my @itemlist = ();
533
        my @itemlist = ();
534
        my $all_items_quantity = 0;
534
        my $all_items_quantity = 0;
535
        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']);
535
        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']);
536
        if ($alliteminfos != -1) {
536
        if ($alliteminfos != -1) {
537
            foreach my $iteminfos (@$alliteminfos) {
537
            foreach my $iteminfos (@$alliteminfos) {
538
                my $item_homebranch = $iteminfos->{homebranch};
538
                my $item_homebranch = $iteminfos->{homebranch};
(-)a/acqui/neworderempty.pl (-1 / +1 lines)
Lines 637-643 sub staged_items_field { Link Here
637
    # Items
637
    # Items
638
    my @itemlist = ();
638
    my @itemlist = ();
639
    my $all_items_quantity = 0;
639
    my $all_items_quantity = 0;
640
    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']);
640
    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']);
641
    if ($alliteminfos != -1) {
641
    if ($alliteminfos != -1) {
642
        foreach my $iteminfos (@$alliteminfos) {
642
        foreach my $iteminfos (@$alliteminfos) {
643
            my %itemrecord=(
643
            my %itemrecord=(
(-)a/t/Acquisition/Utils.t (-4 / +3 lines)
Lines 63-69 test4: 541$a Link Here
63
    is( $data->{test4}, "Test 4", "Got test 4 correctly" );
63
    is( $data->{test4}, "Test 4", "Got test 4 correctly" );
64
};
64
};
65
65
66
subtest "get_infos_syspref_on_item" => sub {
66
subtest "GetMarcItemFieldsToOrderValues" => sub {
67
    plan tests => 13;
67
    plan tests => 13;
68
68
69
    my $record = MARC::Record->new;
69
    my $record = MARC::Record->new;
Lines 85-91 testC: 976$a Link Here
85
testD: 976$b
85
testD: 976$b
86
    };
86
    };
87
    t::lib::Mocks::mock_preference('MarcItemFieldsToOrder', $MarcItemFieldsToOrder);
87
    t::lib::Mocks::mock_preference('MarcItemFieldsToOrder', $MarcItemFieldsToOrder);
88
    my $data = Koha::Acquisition::Utils::get_infos_syspref_on_item(
88
    my $data = Koha::Acquisition::Utils::GetMarcItemFieldsToOrderValues(
89
        'MarcItemFieldsToOrder',
89
        'MarcItemFieldsToOrder',
90
        $record,
90
        $record,
91
        [ 'testA', 'testB', 'testC', 'testD' ]
91
        [ 'testA', 'testB', 'testC', 'testD' ]
Lines 116-122 testD: 976$b Link Here
116
        MARC::Field->new( '976', '', '', a => 'Test 11', b => "Test 12" ),
116
        MARC::Field->new( '976', '', '', a => 'Test 11', b => "Test 12" ),
117
    );
117
    );
118
118
119
    $data = Koha::Acquisition::Utils::get_infos_syspref_on_item(
119
    $data = Koha::Acquisition::Utils::GetMarcItemFieldsToOrderValues(
120
        'MarcItemFieldsToOrder',
120
        'MarcItemFieldsToOrder',
121
        $record,
121
        $record,
122
        [ 'testA', 'testB', 'testC', 'testD' ]
122
        [ 'testA', 'testB', 'testC', 'testD' ]
123
- 

Return to bug 20817