https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43907

--- Comment #1 from Adolfo Rodríguez Taboada <[email protected]> ---
Created attachment 208987
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208987&action=edit
Bug 43907: Do not delete the items replaced by an import when reverting it

When a staged MARC import replaced existing items, import_items marked
them as 'imported', like the items created by the import. Reverting the
batch deletes the 'imported' items, so it deleted items that existed
before the import, if they had been matched by itemnumber (952$9). When
they had been matched by barcode, the itemnumber stored was the one of
the incoming file, usually empty, instead of the replaced item.

This patch:
- adds the 'replaced' status to import_items.status
- stores the replaced items with that status and their real itemnumber,
  whether they are matched by itemnumber or by barcode
- makes BatchRevertItems only delete the items created by the import
  ('imported'): the replaced items are kept. As before, reverting does
  not restore their previous data, as Koha does not keep it.

Steps to follow:
1. Make sure the background jobs worker is running.
2. Choose an item of any record (record A), and another record B with
   an ISBN.
3. Create a MARC file with a record that has the ISBN of record B in
   020$a, and a 952 with the itemnumber of the item of record A in
   952$9 (and 952$a, $b, $p and $y).
4. Cataloging > Stage records for import: stage the file with:
   - Record matching rule: ISBN
   - Action if matching record found: Ignore incoming record
   - Action if no match is found: Ignore incoming record
   - How to process items: Replace items if matching bib was found
5. Cataloging > Manage staged records: import the batch (1 item is
   replaced), then undo the import. The item of record A is deleted.
6. Apply the patches, run the database update
   (perl installer/data/mysql/updatedatabase.pl) and restart_all.
7. Restore an item in record A (or choose another one), update the
   952$9 of the file and repeat steps 4 and 5: the item is not deleted.
   In the database, its import_items row has the status 'replaced' and
   its itemnumber:
   SELECT status, itemnumber FROM import_items ORDER BY import_items_id DESC
LIMIT 1;
8. Repeat with a 952 without 952$9 and with the barcode of an existing
   item: import_items has its itemnumber, and undoing the import does
   not delete it.
9. prove t/db_dependent/ImportBatch.t

Signed-off-by: Adolfo Rodríguez <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to