Bug 39631

Summary: longoverdue.pl does not consider OverdueNoticeCalendar when calculating overdue days
Product: Koha Reporter: Hammat wele <hammat.wele>
Component: CirculationAssignee: Hammat wele <hammat.wele>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, gmcharlt, kyle.m.hall, philippe.blouin
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17015
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 39631: longoverdue.pl does not consider OverdueNoticeCalendar when calculating overdue days
Bug 39631: longoverdue.pl does not consider OverdueNoticeCalendar when calculating overdue days
Bug 39631: (follow-up) Fix No branchcode argument passed

Description Hammat wele 2025-04-14 18:02:47 UTC
When the system preference OverdueNoticeCalendar is activated, the script longoverdue.pl continues to calculate overdue duration using calendar days instead of working days.
This creates a discrepancy with overdue_notices.pl, which correctly uses working days for triggering overdue notices when OverdueNoticeCalendar is enabled.
As a result, items may be marked as lost by longoverdue.pl before the final configured overdue notice (e.g., ODUE3) has a chance to be sent.

To test

1. Set the system preference OverdueNoticeCalendar to « ignore calendar »
2. Set the following preferences:
    DefaultLongOverdueLostValue = Long Overdue
    DefaultLongOverdueDays = 15
3. Define days when the library is closed
    3.1. Go to Tools > Calendar
    3.2. Click on a Saturday (e.g., 2025-04-12) Fill Description = Saturdays, Click on "Holiday repeated every same day of the week." and Click on Copy to all libraries and submit
    3.3. Repeat step 3.2. by clicking on Sundays (e.g., 2025-04-13) similarly.
4. Checkout an item to a patron of category type Board, and set due date to 2025-03-29 (15 days before today).
    4.1. Click on "Show checkouts", click the barcode, and note the itemnumber.
5. Run: ./misc/cronjobs/longoverdue.pl
    --> The item should be flagged as overdue (e.g., item 378 appears in the output).
6. Now Enable the system preference OverdueNoticeCalendar.
7. Run longoverdue.pl again: 
    --> The item is still detected as overdue, even though it should not be (due to holidays).
Comment 1 Hammat wele 2025-04-14 18:08:01 UTC Comment hidden (obsolete)
Comment 2 Hammat wele 2025-04-14 19:43:12 UTC
Created attachment 180933 [details] [review]
Bug 39631: longoverdue.pl does not consider OverdueNoticeCalendar when calculating overdue days

When the system preference OverdueNoticeCalendar is activated, the script longoverdue.pl continues to calculate overdue duration using calendar days instead of working days.
This creates a discrepancy with overdue_notices.pl, which correctly uses working days for triggering overdue notices when OverdueNoticeCalendar is enabled.
As a result, items may be marked as lost by longoverdue.pl before the final configured overdue notice (e.g., ODUE3) has a chance to be sent.

To test

1. Set the system preference OverdueNoticeCalendar to « ignore calendar »
2. Set the following preferences:
    DefaultLongOverdueLostValue = Long Overdue
    DefaultLongOverdueDays = 15
3. Define days when the library is closed
    3.1. Go to Tools > Calendar
    3.2. Click on a Saturday (e.g., 2025-04-12) Fill Description = Saturdays, Click on "Holiday repeated every same day of the week." and Click on Copy to all libraries and submit
    3.3. Repeat step 3.2. by clicking on Sundays (e.g., 2025-04-13) similarly.
4. Checkout an item to a patron of category type Board, and set due date to 2025-03-29 (15 days before today).
    4.1. Click on "Show checkouts", click the barcode, and note the itemnumber.
5. Run: ./misc/cronjobs/longoverdue.pl
    --> The item should be flagged as overdue (e.g., item 378 appears in the output).
6. Now Enable the system preference OverdueNoticeCalendar.
7. Run longoverdue.pl again:
    --> The item is still detected as overdue, even though it should not be (due to holidays).
8. Apply the patch
9. Repeat step 7:
    --> Now, the item is not detected as overdue — correct behavior.
10. Change DefaultLongOverdueDays to 10.
11. Repeat step 7:
    -->Now, the item is detected as overdue, correctly considering holidays.
Comment 3 Hammat wele 2025-04-24 15:39:52 UTC
Created attachment 181465 [details] [review]
Bug 39631: (follow-up) Fix No branchcode argument passed