Bug 7329

Summary: The "undo import into catalog" command deletes items onloan without checking
Product: Koha Reporter: Christophe Croullebois <christophe.croullebois>
Component: MARC Bibliographic record staging/importAssignee: Christophe Croullebois <christophe.croullebois>
Status: CLOSED FIXED QA Contact: Ian Walls <koha.sekjal>
Severity: critical    
Priority: P3 CC: chris, christophe.croullebois, katrin.fischer, magnus, paul.poulain, sophie.meynieux
Version: 3.8   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 8149    
Attachments: new proposed patch
screenshot after step 1)
Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted beacause on loan.
Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted because they are issued.
[SIGNED-OFF] Bug 7329: Items onloan are deleted when undoing import into catalog
[SIGNED-OFF] Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted beacause on loan.
[SIGNED-OFF] Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted because they are issued.

Description Christophe Croullebois 2011-12-07 10:47:43 UTC
To test, stage MARC records and import with items created.
Next, check out one or more items.
Then undo import into catalog, and you'll see that record and item(s) will be deleted.
I have made a patch that checks the "on loan" status before deleting item, and do noting in this case, so the record can't be deleted due to existing item.
Comment 1 Christophe Croullebois 2011-12-07 11:08:43 UTC Comment hidden (obsolete)
Comment 2 Katrin Fischer 2011-12-16 07:23:12 UTC
I noticed 2 some problems for this patch:

1) I had one item checked out and 1 available item with missing home and holding branch (not sure that was the reason). Both were not removed from the catalog.

2) After 'undoing' the import the bib# for the 2 records remaining in the catalog due to errors were gone from the list. 

3) I reimported and the bib# were still missing.

4) I undid the import again and now it reports to have removed all records. My 2 problematic records show up in the list as reverted, but they are still available in my catalog.

I think 3) and 4) are perhaps side effects of 2)?
Comment 3 Katrin Fischer 2011-12-16 07:23:37 UTC
Created attachment 6829 [details]
screenshot after step 1)
Comment 4 Sophie MEYNIEUX 2012-06-10 10:29:36 UTC Comment hidden (obsolete)
Comment 5 Sophie MEYNIEUX 2012-06-10 10:33:16 UTC
First patch was ok but uncomplete. This follow-up keep tracks in import tool itself, that some biblios remain in the catalog because corresponding items are issued and can't be deleted.
Comment 6 Sophie MEYNIEUX 2012-06-10 15:06:43 UTC Comment hidden (obsolete)
Comment 7 Sophie MEYNIEUX 2012-06-10 15:08:04 UTC
Followup corrected to take care of biblios with several items
Comment 8 Katrin Fischer 2012-06-11 08:56:30 UTC
I am ready to sign-off on the first three patches, but there is a small thing I have to note.

If you have a record with more than one item and one of the items is checked out, undoing the import will delete all items except for the checked out one. So this is perfectly correct.

However, if you repeat the import after that, the additional items do not get readded to the record. 

I think this is only a very small issue and the import works a lot nicer with the patches. so signing off.
Comment 9 Katrin Fischer 2012-06-11 08:58:12 UTC
Created attachment 10155 [details] [review]
[SIGNED-OFF] Bug 7329: Items onloan are deleted when undoing import into catalog

this patch checks the "on loan" and "reserved" status before deleting item, and
do noting in this case, so the record can't be deleted due to existing item.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 10 Katrin Fischer 2012-06-11 08:58:19 UTC
Created attachment 10156 [details] [review]
[SIGNED-OFF] Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted beacause on loan.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 11 Katrin Fischer 2012-06-11 08:58:26 UTC
Created attachment 10157 [details] [review]
[SIGNED-OFF] Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted because they are issued.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 12 Sophie MEYNIEUX 2012-06-11 09:55:08 UTC
Katrin ; the problem is that the record is not totally reverted (one item left) and not totally imported (some items have been deleted). Should we add a status for this situation ("partially reverted" or "partially imported" ) ?
Comment 13 Katrin Fischer 2012-06-11 10:51:31 UTC
I think it would be nice, but perhaps could be a different bug and enhancement :)
Comment 14 Ian Walls 2012-06-15 17:40:51 UTC
Patch 1:  uses DelItemCheck instead of DelItem, with logic to handle when an item cannot be deleted.  Good use of existing subroutine.  Passed QA.

Patch 2 + 3:  Work together to prevent the biblio from being NULLifed if the item isn't deleted.  SQL only change, with a comment, marking Passed QA.
Comment 15 Chris Cormack 2012-06-20 09:02:13 UTC
No string changes, pushed to 3.8.x will be in 3.8.2