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

(-)a/C4/Items.pm (+13 lines)
Lines 293-298 sub ModItemFromMarc { Link Here
293
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
293
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
294
    my $item_object = Koha::Items->find($itemnumber);
294
    my $item_object = Koha::Items->find($itemnumber);
295
    my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
295
    my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
296
297
    # Retrieving the values for the fields that are not linked
298
    my @mapped_fields = Koha::MarcSubfieldStructures->search(
299
        {
300
            frameworkcode => $frameworkcode,
301
            kohafield     => { -like => "items.%" }
302
        }
303
    )->get_column('kohafield');
304
    for my $c ( $item_object->_result->result_source->columns ) {
305
        next if grep { "items.$c" eq $_ } @mapped_fields;
306
        $item->{$c} = $item_object->$c;
307
    }
308
296
    $item->{cn_source} = delete $item->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
309
    $item->{cn_source} = delete $item->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
297
    $item->{cn_sort}   = delete $item->{'items.cn_sort'};   # Because of C4::Biblio::_disambiguate
310
    $item->{cn_sort}   = delete $item->{'items.cn_sort'};   # Because of C4::Biblio::_disambiguate
298
    $item->{itemnumber} = $itemnumber;
311
    $item->{itemnumber} = $itemnumber;
(-)a/t/db_dependent/Items.t (-4 / +7 lines)
Lines 601-612 subtest 'SearchItems test' => sub { Link Here
601
601
602
    # Make sure the link is used
602
    # Make sure the link is used
603
    my $item3 = Koha::Items->find($item3_itemnumber);
603
    my $item3 = Koha::Items->find($item3_itemnumber);
604
    ok($item3->itemnotes eq 'foobar', 'itemnotes eq "foobar"');
604
    is($item3->itemnotes, 'foobar', 'itemnotes eq "foobar"');
605
605
606
    # Do the same search again.
606
    # Do the same search again.
607
    # This time it will search in items.itemnotes
607
    # This time it will search in items.itemnotes
608
    ($items, $total_results) = SearchItems($filter);
608
    ($items, $total_results) = SearchItems($filter);
609
    ok(scalar @$items == 1, 'found 1 item with itemnotes = "foobar"');
609
    is(scalar(@$items), 1, 'found 1 item with itemnotes = "foobar"');
610
610
611
    my ($cpl_items_after) = SearchItems( { field => 'homebranch', query => $library1->{branchcode} } );
611
    my ($cpl_items_after) = SearchItems( { field => 'homebranch', query => $library1->{branchcode} } );
612
    is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItems should return something' );
612
    is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItems should return something' );
Lines 984-990 subtest 'Split subfields in Item2Marc (Bug 21774)' => sub { Link Here
984
};
984
};
985
985
986
subtest 'ModItemFromMarc' => sub {
986
subtest 'ModItemFromMarc' => sub {
987
    plan tests => 2;
987
    plan tests => 4;
988
    $schema->storage->txn_begin;
988
    $schema->storage->txn_begin;
989
989
990
    my $builder = t::lib::TestBuilder->new;
990
    my $builder = t::lib::TestBuilder->new;
Lines 1009-1014 subtest 'ModItemFromMarc' => sub { Link Here
1009
    my $item = Koha::Items->find($itemnumber);
1009
    my $item = Koha::Items->find($itemnumber);
1010
    is( $item->itemlost, 1, 'itemlost picked from the item marc');
1010
    is( $item->itemlost, 1, 'itemlost picked from the item marc');
1011
1011
1012
    $item->paidfor("this is something")->store;
1013
1012
    my $updated_item_record = new MARC::Record;
1014
    my $updated_item_record = new MARC::Record;
1013
    $updated_item_record->append_fields(
1015
    $updated_item_record->append_fields(
1014
        MARC::Field->new(
1016
        MARC::Field->new(
Lines 1019-1024 subtest 'ModItemFromMarc' => sub { Link Here
1019
1021
1020
    my $updated_item = ModItemFromMarc($updated_item_record, $biblio->biblionumber, $itemnumber);
1022
    my $updated_item = ModItemFromMarc($updated_item_record, $biblio->biblionumber, $itemnumber);
1021
    is( $updated_item->{itemlost}, 0, 'itemlost should have been reset to the default value in DB' );
1023
    is( $updated_item->{itemlost}, 0, 'itemlost should have been reset to the default value in DB' );
1024
    is( $updated_item->{paidfor}, "this is something", "Non mapped field has not been reset" );
1025
    is( Koha::Items->find($itemnumber)->paidfor, "this is something" );
1022
1026
1023
    $schema->storage->txn_rollback;
1027
    $schema->storage->txn_rollback;
1024
};
1028
};
1025
- 

Return to bug 25964