Bug 32471 - MARC imports can fail on replacing items when an itemnumber exists in the incoming file, but not in Koha
Summary: MARC imports can fail on replacing items when an itemnumber exists in the in...
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-14 21:08 UTC by Nick Clemens (kidclamp)
Modified: 2023-06-10 21:51 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2022-12-14 21:08:39 UTC
The 'replace' option for items checks whether the item can be found for barcodes - it does not do so for itemnumbers:

sub _batchCommitItems {
...
        my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} });
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
...
        if ( $action eq "replace" && $duplicate_itemnumber ) {
            # Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying
            ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber}, { skip_record_index => 1 } );

The call to ModItemFromMarc fails when the item isn't there - this can happen for orders when importing final records form the vendor, but a cop has been removed etc.

To recreate:
1 - Export a record containing items as MARCXML
2 - Edit an item record and add/update the 952$9 to a number not in the db 1234567890
2 - Stage the record for import, matching on kohabiblio and replacing items
3 - Import the batch
4 - It fails