[Koha-bugs] [Bug 29457] Fee Cancellation records the wrong manager_id

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Dec 3 10:56:13 CET 2021


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

--- Comment #31 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
NOTE: This comment is referred to from the db revision of this report !

If you come here since a Koha upgrade referred you to this place, you have two
options: (1) try to correct the incorrect manager_id's or (2) clear the
incorrect manager_id's.
A suggestion beforehand: Make a SQL dump before running the SQL updates below
on your (production) data.

OPTION 1 CORRECT
In the more exceptional case that your records contain a numeric manager_id
which actually is a USERID (read: user code) and NOT a borrowernumber, you may
want to run this sql statement:
UPDATE accountlines
LEFT JOIN borrowers ON CAST(borrowers.userid AS INT) = accountlines.manager_id
SET manager_id = borrowers.borrowernumber 
WHERE manager_id IS NOT NULL AND userid RLIKE "^[0-9]+$"  AND
borrowers.borrowernumber IS NOT NULL AND credit_type_code = 'CANCELLATION'

OPTION 2 CLEAR
Use this SQL statement to correct records with a wrong wrong manager_id,
setting them to NULL:
UPDATE accountlines SET manager_id = NULL WHERE manager_id IS NOT NULL AND
credit_type_code = 'CANCELLATION'

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list