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

(-)a/Koha/Acquisition/Utils.pm (-4 / +4 lines)
Lines 25-33 Koha::Acquisition::Utils - Additional Koha functions for dealing with orders and Link Here
25
25
26
=head1 SUBROUTINES
26
=head1 SUBROUTINES
27
27
28
=head3 get_infos_syspref($syspref_name, $record, $field_list)
28
=head3 GetMarcFieldsToOrderValues($syspref_name, $record, $field_list)
29
29
30
my $data = Koha::Acquisition::Utils::get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', etc.]);
30
my $data = Koha::Acquisition::Utils::GetMarcFieldsToOrderValues('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', etc.]);
31
31
32
This subroutine accepts a syspref ( MarcFieldsToOrder ),
32
This subroutine accepts a syspref ( MarcFieldsToOrder ),
33
a marc record, and an arrayref of fields to retrieve.
33
a marc record, and an arrayref of fields to retrieve.
Lines 38-44 given system preference. Link Here
38
38
39
=cut
39
=cut
40
40
41
sub get_infos_syspref {
41
sub GetMarcFieldsToOrderValues {
42
    my ($syspref_name, $record, $field_list) = @_;
42
    my ($syspref_name, $record, $field_list) = @_;
43
    my $syspref = C4::Context->preference($syspref_name);
43
    my $syspref = C4::Context->preference($syspref_name);
44
    $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt
44
    $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt
Lines 76-82 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 GetMarcItemFieldsToOrderValues is that the former deals
79
The largest difference between GetMarcFieldsToOrderValues 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
(-)a/acqui/addorderiso2709.pl (-1 / +1 lines)
Lines 513-519 sub import_biblios_list { Link Here
513
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
513
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
514
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
514
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
515
515
516
        my $infos = Koha::Acquisition::Utils::get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']);
516
        my $infos = Koha::Acquisition::Utils::GetMarcFieldsToOrderValues('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']);
517
        my $price = $infos->{price};
517
        my $price = $infos->{price};
518
        my $replacementprice = $infos->{replacementprice};
518
        my $replacementprice = $infos->{replacementprice};
519
        my $quantity = $infos->{quantity};
519
        my $quantity = $infos->{quantity};
(-)a/acqui/neworderempty.pl (-1 / +1 lines)
Lines 619-625 sub staged_items_field { Link Here
619
    my ($marcrecord, $encoding) = MARCfindbreeding($breedingid);
619
    my ($marcrecord, $encoding) = MARCfindbreeding($breedingid);
620
    die("Could not find the selected record in the reservoir, bailing") unless $marcrecord;
620
    die("Could not find the selected record in the reservoir, bailing") unless $marcrecord;
621
621
622
    my $infos = Koha::Acquisition::Utils::get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice']);
622
    my $infos = Koha::Acquisition::Utils::GetMarcFieldsToOrderValues('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice']);
623
    my $price = $infos->{price};
623
    my $price = $infos->{price};
624
    my $replacementprice = $infos->{replacementprice};
624
    my $replacementprice = $infos->{replacementprice};
625
    my $quantity = $infos->{quantity};
625
    my $quantity = $infos->{quantity};
(-)a/t/Acquisition/Utils.t (-3 / +2 lines)
Lines 33-39 $schema->storage->txn_begin; Link Here
33
my $builder = t::lib::TestBuilder->new;
33
my $builder = t::lib::TestBuilder->new;
34
my $dbh = C4::Context->dbh;
34
my $dbh = C4::Context->dbh;
35
35
36
subtest "get_infos_syspref" => sub {
36
subtest "GetMarcFieldsToOrderValues" => sub {
37
    plan tests => 4;
37
    plan tests => 4;
38
38
39
    my $record = MARC::Record->new;
39
    my $record = MARC::Record->new;
Lines 51-57 test3: 520$a Link Here
51
test4: 541$a
51
test4: 541$a
52
    };
52
    };
53
    t::lib::Mocks::mock_preference('MarcFieldsToOrder', $MarcFieldsToOrder);
53
    t::lib::Mocks::mock_preference('MarcFieldsToOrder', $MarcFieldsToOrder);
54
    my $data = Koha::Acquisition::Utils::get_infos_syspref(
54
    my $data = Koha::Acquisition::Utils::GetMarcFieldsToOrderValues(
55
        'MarcFieldsToOrder',
55
        'MarcFieldsToOrder',
56
        $record,
56
        $record,
57
        [ 'test1', 'test2', 'test3', 'test4' ]
57
        [ 'test1', 'test2', 'test3', 'test4' ]
58
- 

Return to bug 20817