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 519-525 sub import_biblios_list { Link Here
519
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
519
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
520
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
520
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
521
521
522
        my $infos = Koha::Acquisition::Utils::get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']);
522
        my $infos = Koha::Acquisition::Utils::GetMarcFieldsToOrderValues('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']);
523
        my $price = $infos->{price};
523
        my $price = $infos->{price};
524
        my $replacementprice = $infos->{replacementprice};
524
        my $replacementprice = $infos->{replacementprice};
525
        my $quantity = $infos->{quantity};
525
        my $quantity = $infos->{quantity};
(-)a/acqui/neworderempty.pl (-1 / +1 lines)
Lines 631-637 sub staged_items_field { Link Here
631
    my ($marcrecord, $encoding) = MARCfindbreeding($breedingid);
631
    my ($marcrecord, $encoding) = MARCfindbreeding($breedingid);
632
    die("Could not find the selected record in the reservoir, bailing") unless $marcrecord;
632
    die("Could not find the selected record in the reservoir, bailing") unless $marcrecord;
633
633
634
    my $infos = Koha::Acquisition::Utils::get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice']);
634
    my $infos = Koha::Acquisition::Utils::GetMarcFieldsToOrderValues('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice']);
635
    my $price = $infos->{price};
635
    my $price = $infos->{price};
636
    my $replacementprice = $infos->{replacementprice};
636
    my $replacementprice = $infos->{replacementprice};
637
    my $quantity = $infos->{quantity};
637
    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