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

--- Comment #1 from ChloĆ© Zermatten <[email protected]> ---
Created attachment 206646
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206646&action=edit
Bug 43500: refactor: extract mark_returned and lift_overdue_restrictions

Add Koha::Checkout->mark_returned, archiving a checkout to old_issues:
sets returndate, reassigns the checkout's accountlines to the archived row,
deletes the issues row, clears items.onloan and records items.last_returned_by.
checkin_library is a parameter rather than a C4::Context->userenv read, so
cronjobs and other callers without a user environment can record the correct
library, or none.

Add Koha::Patron->lift_overdue_restrictions, holding the
AutoRemoveOverduesRestrictions handling logic.
Refactor to include a guard clause to avoid fetching overdues if no overdue
restrictions exists.

Minor: removes the unused my $rv variable declared in MarkIssueReturned

Rewrite MarkIssueReturned from which both were extracted to call both.

Test plan (check for regressions):

1) prove t/db_dependent/Koha/Checkout.t
2) prove t/db_dependent/Koha/Patron.t
3) prove t/db_dependent/Circulation/MarkIssueReturned.t
4) run misc/cronjobs/longoverdue.pl:
   a) Confirm the test patron's category has 'Overdue notice required' set
      to Yes, and set AutoRemoveOverduesRestrictions to
      when_no_overdue_causing_debarment.
   b) At admin/circulation_triggers.pl add a trigger with a letter (ODUE),
      a transport type, a delay of N days and 'Restricts checkouts' = Yes.
      A trigger with no letter never restricts, so the letter matters.
   c) Check out two items to the patron and backdate both due dates to N + 1
      days overdue.
   d) perl misc/cronjobs/overdue_notices.pl -n
      Confirm the patron's Restrictions tab shows an OVERDUES restriction.
   e) perl misc/cronjobs/longoverdue.pl --lost <N>=1 --mark-returned --confirm
-v
      Confirm both checkouts are archived to old_issues, items.onloan is
      cleared, itemlost is set, and the OVERDUES restriction is gone.
   f) Confirm old_issues.checkin_library is NULL for both rows. Koha::Script
      -cron sets a userenv with no branch, so this is unchanged by the patch.

Assisted-by: Claude Opus 5 (Anthropic)
Sponsored-by: Black Hills Library Consortium- http://www.rcgov.org/Library/

-- 
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