$localitemmarc->append_fields( $item_marc->field($itemtag) );
my $item_object = Koha::Items->find($itemnumber);
my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
+
+ # Retrieving the values for the fields that are not linked
+ my @mapped_fields = Koha::MarcSubfieldStructures->search(
+ {
+ frameworkcode => $frameworkcode,
+ kohafield => { -like => "items.%" }
+ }
+ )->get_column('kohafield');
+ for my $c ( $item_object->_result->result_source->columns ) {
+ next if grep { "items.$c" eq $_ } @mapped_fields;
+ $item->{$c} = $item_object->$c;
+ }
+
$item->{cn_source} = delete $item->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
$item->{cn_sort} = delete $item->{'items.cn_sort'}; # Because of C4::Biblio::_disambiguate
$item->{itemnumber} = $itemnumber;
# Make sure the link is used
my $item3 = Koha::Items->find($item3_itemnumber);
- ok($item3->itemnotes eq 'foobar', 'itemnotes eq "foobar"');
+ is($item3->itemnotes, 'foobar', 'itemnotes eq "foobar"');
# Do the same search again.
# This time it will search in items.itemnotes
($items, $total_results) = SearchItems($filter);
- ok(scalar @$items == 1, 'found 1 item with itemnotes = "foobar"');
+ is(scalar(@$items), 1, 'found 1 item with itemnotes = "foobar"');
my ($cpl_items_after) = SearchItems( { field => 'homebranch', query => $library1->{branchcode} } );
is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItems should return something' );
};
subtest 'ModItemFromMarc' => sub {
- plan tests => 2;
+ plan tests => 4;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $item = Koha::Items->find($itemnumber);
is( $item->itemlost, 1, 'itemlost picked from the item marc');
+ $item->paidfor("this is something")->store;
+
my $updated_item_record = new MARC::Record;
$updated_item_record->append_fields(
MARC::Field->new(
my $updated_item = ModItemFromMarc($updated_item_record, $biblio->biblionumber, $itemnumber);
is( $updated_item->{itemlost}, 0, 'itemlost should have been reset to the default value in DB' );
+ is( $updated_item->{paidfor}, "this is something", "Non mapped field has not been reset" );
+ is( Koha::Items->find($itemnumber)->paidfor, "this is something" );
$schema->storage->txn_rollback;
};