Bug 37942

Summary: Problematic calculation of overdue recall fine (overrides regular overdue fine)
Product: Koha Reporter: Janusz Kaczmarek <januszop>
Component: Fines and feesAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low    
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 19532    
Bug Blocks:    

Description Janusz Kaczmarek 2024-09-17 12:14:02 UTC
There is an issue with calculating fines when two conditions occur simultaneously: a regular overdue and a overdue recall.  Overdue recall fine always replaces the regular overdue fine which can lead to significant reduce or increase of previously calculated fine. 

To see the problem:

1. Set finesMode to 'Calculate and charge' and UseRecalls to 'Use'.
2. In 'Circulation and fine rules' set: 
   'Fine amount' = 1
   'Fine charging interval' = 1
   'Recalls allowed (total)' = 1
   'Recalls per record (count)' = 1
   'Recall due date interval (day)' = 7
   'Recall overdue fine amount' = 0.10
3. Checkout an item to a patron.
4. Manually, in the database, shift the due date to one year ago to create 'heavy' overdue (i.e. update issues set date_due = 'YYYY-MM-DD 23:59:00' where issue_id = N).
5. Execute the ./misc/cronjobs/fines.pl script; note the fine amount in the patron's account.  It should be about $365. 
6. From another patron's account make a recall on the issued item.
7. Manually, in the database, shift the created_date to a month ago (i.e. update recalls set created_date = 'YYYY-MM-DD HH:MM:SS' where recall_id = N).
8. Execute the ./misc/cronjobs/recalls/overdue_recalls.pl script.
9. Execute the ./misc/cronjobs/fines.pl script. Note that the fine amount in the first patron's account has decreased substantially.  It will be now about $36.50. 
(10. With 'Recall overdue fine amount' = 10 the new fine would be about $3,650 !).

This seems to be an unintended consequence of the changes C4::Overdues::CalcFine made by bug 19532 and quite a serious bug.