Bug 7901 - Add option to delete_borrowers.pl for using a file with cardnumbers
Summary: Add option to delete_borrowers.pl for using a file with cardnumbers
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall
QA Contact: Ian Walls
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-05 12:59 UTC by Kyle M Hall
Modified: 2023-01-08 00:35 UTC (History)
4 users (show)

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


Attachments
Bug 7901 - Add batch delete borrowers script (3.20 KB, patch)
2012-04-05 13:00 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 7901 - Add batch delete borrowers script (3.41 KB, patch)
2012-07-23 20:45 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2012-04-05 12:59:22 UTC
Add simple script to batch delete borrowers via a list of cardnumbers.
Comment 1 Kyle M Hall 2012-04-05 13:00:06 UTC Comment hidden (obsolete)
Comment 2 delaye 2012-06-21 08:52:23 UTC
why i can't load the cardnumber file in koha it will be more easy for the users...

i have this message

perl batch_delete_borrowers.pl --f file_test -c
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at /home/koha/src/C4/Members.pm line 1679, <FILE> line 1.
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at /home/koha/src/C4/Members.pm line 1679, <FILE> line 2.
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at /home/koha/src/C4/Members.pm line 1679, <FILE> line 3.
Comment 3 Owen Leonard 2012-07-20 19:22:06 UTC
I tried loading a file which included one patron with checkouts, one without. The patron with no checkouts was deleted without error, the one with checkouts prompted this:

Working on cardnumber 0093698 
DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at /home/oleonard/kohaclone/C4/Members.pm line 1708, <FILE> line 2.
Deleting borrower John Smith ( 0093698 ) ... deleted.

Sounds like the script tries its best to delete and it's the error that prevents it? I would think that unless there is an explicit plan for how to handle checkouts the script should skip these accounts and report it.

After that I tried loading the same file again (including the patron record which had already been deleted) and got this error:

Working on cardnumber 0049138 
Use of uninitialized value in concatenation (.) or string at batch_delete_borrowers.pl line 80, <FILE> line 1.
Use of uninitialized value in concatenation (.) or string at batch_delete_borrowers.pl line 80, <FILE> line 1.
Use of uninitialized value in concatenation (.) or string at batch_delete_borrowers.pl line 80, <FILE> line 1.
Deleting borrower   (  ) ... deleted.

It would be nice to handle that situation gracefully.
Comment 4 Owen Leonard 2012-07-20 19:28:51 UTC
Looks like the script deletes holds which were on a deleted patron's account but doesn't move them to old_reserves? I assume it should, since deleting a hold via reserve/request.pl does so.
Comment 5 Kyle M Hall (khall) 2012-07-23 20:45:52 UTC
Created attachment 11090 [details] [review]
Bug 7901 - Add batch delete borrowers script

Simple script that takes a file of borrower
cardnumbers and deletes those borrowers.
Comment 6 Owen Leonard 2012-07-30 16:26:10 UTC
This revision seems to address the problem with handling patron barcodes which don't exist but doesn't fix the problem deleting patrons with checkouts and still doesn't move holds to old_reserves.
Comment 7 Kyle M Hall (khall) 2012-07-30 16:59:52 UTC
(In reply to comment #6)
> This revision seems to address the problem with handling patron barcodes
> which don't exist but doesn't fix the problem deleting patrons with
> checkouts and still doesn't move holds to old_reserves.

I was under the assumption that MoveMemberToDeleted took care of this. Is there a sub call the script should be making that it doesn't?
Comment 8 Katrin Fischer 2014-04-09 09:51:11 UTC
I wonder if those options should be added to the delete_borrowers.pl script that already is in Koha. If we have 2 scripts, we should make clear where the differences are and they should both delete patrons the same way, taking fines, holds etc. into account.
Comment 9 Marc Véron 2016-10-03 15:46:22 UTC
Still valid?
Comment 10 BASE Library Consortium 2017-12-07 16:23:53 UTC
Still valid (16.05), the only way to do this is batch add patrons into a category and use cleanborrowers.pl to delete the category.
Comment 11 Katrin Fischer 2017-12-10 21:41:44 UTC
Just a little update on this, there is another way to batch delete patrons from the GUI with 17.11:

1) Add patrons to a list
2) Go to the patron lists summary page
3) Actions > Batch delete patrons

Maybe adding an option to add to patron list by cardnumber list/input would help? Similar to the batch edit/delete item tools.
Comment 12 Katrin Fischer 2023-01-08 00:35:37 UTC
(In reply to Katrin Fischer from comment #8)
> I wonder if those options should be added to the delete_borrowers.pl script
> that already is in Koha. If we have 2 scripts, we should make clear where
> the differences are and they should both delete patrons the same way, taking
> fines, holds etc. into account.

I see that delete_borrowers.pl already has a --file option that works with a list of borrowernumber. I really think it would make most sense now to extend the existing script now so that we only have one script dealing with patron deletes from CLI.

    --file
        Delete patrons whose borrower numbers are in this file. If other
        criteria are defined it will only delete those in the file that
        match those criteria.