+ my $schema = Koha::Database->schema;
+ my ( $biblionumber, $biblioitemnumber );
+ try {
+ $schema->txn_do(sub {
+
+ # transform the data into koha-table style data
+ SetUTF8Flag($record);
+ my $olddata = TransformMarcToKoha({ record => $record, limit_table => 'no_items' });
+
+ my $biblio = Koha::Biblio->new(
+ {
+ frameworkcode => $frameworkcode,
+ author => $olddata->{author},
+ title => $olddata->{title},
+ subtitle => $olddata->{subtitle},
+ medium => $olddata->{medium},
+ part_number => $olddata->{part_number},
+ part_name => $olddata->{part_name},
+ unititle => $olddata->{unititle},
+ notes => $olddata->{notes},
+ serial =>
+ ( $olddata->{serial} || $olddata->{seriestitle} ? 1 : 0 ),
+ seriestitle => $olddata->{seriestitle},
+ copyrightdate => $olddata->{copyrightdate},
+ datecreated => \'NOW()',
+ abstract => $olddata->{abstract},
+ }
+ )->store;
+ $biblionumber = $biblio->biblionumber;
+ Koha::Exceptions::ObjectNotCreated->throw unless $biblio;
+
+ my ($cn_sort) = GetClassSort( $olddata->{'biblioitems.cn_source'}, $olddata->{'cn_class'}, $olddata->{'cn_item'} );
+ my $biblioitem = Koha::Biblioitem->new(
+ {
+ biblionumber => $biblionumber,
+ volume => $olddata->{volume},
+ number => $olddata->{number},
+ itemtype => $olddata->{itemtype},
+ isbn => $olddata->{isbn},
+ issn => $olddata->{issn},
+ publicationyear => $olddata->{publicationyear},
+ publishercode => $olddata->{publishercode},
+ volumedate => $olddata->{volumedate},
+ volumedesc => $olddata->{volumedesc},
+ collectiontitle => $olddata->{collectiontitle},
+ collectionissn => $olddata->{collectionissn},
+ collectionvolume => $olddata->{collectionvolume},
+ editionstatement => $olddata->{editionstatement},
+ editionresponsibility => $olddata->{editionresponsibility},
+ illus => $olddata->{illus},
+ pages => $olddata->{pages},
+ notes => $olddata->{bnotes},
+ size => $olddata->{size},
+ place => $olddata->{place},
+ lccn => $olddata->{lccn},
+ url => $olddata->{url},
+ cn_source => $olddata->{'biblioitems.cn_source'},
+ cn_class => $olddata->{cn_class},
+ cn_item => $olddata->{cn_item},
+ cn_suffix => $olddata->{cn_suff},
+ cn_sort => $cn_sort,
+ totalissues => $olddata->{totalissues},
+ ean => $olddata->{ean},
+ agerestriction => $olddata->{agerestriction},
+ }
+ )->store;
+ Koha::Exceptions::ObjectNotCreated->throw unless $biblioitem;
+ $biblioitemnumber = $biblioitem->biblioitemnumber;