Hello. In testing Koha 3.0 alpha, I have a user who has checked out a book which is now overdue by 3 weeks. According to the overdue/fine rules, he should be getting charged $0.25/day in overdue fines, but when he logs into his account it shows the overdue book in red but displays "No" in the fines column. Looking for some documentation, I stumbled across a mention of a cron job to calculate fines, at least back in Koha 2.2.x . Assuming it's still done that way, I hunted around the Koha tree and found these likely candidates: <koharoot>/bin/fines.pl <koharoot>/bin/fines2.pl <koharoot>/bin/cronjobs/fines2.pl <koharoot>/bin/cronjobs/fines-sanop.pl My questions are: 1) All 4 of these scripts say "This script is meant to be run nightly out of cron". Which of these should I actually setup to run nightly? 2) Why is a cronjob even necessary? i.e. why can't Koha look at today's date and the books' due dates, then calculate on the fly what the overdue fines are whenever the patron or librarian pulls up a record within the OPAC? Thanks.
2) Why is a cronjob even necessary? i.e. why can't Koha look at today's date and the books' due dates, then calculate on the fly what the overdue fines are whenever the patron or librarian pulls up a record within the OPAC?
You may want to check out the fines script I wrote for our library. It calculates fines for items as they are checked in. http://koha-tools.svn.sourceforge.net/viewvc/koha-tools/finesScripts/trunk/ Kyle -- http://www.kylehall.info Information Technology Crawford County Federated Library System ( http://www.ccfls.org )
Kyle, thanks for the reply. I'll look into that script, although there'd be some value in patrons (and staff) knowing what their fines are going to be before the books are checked in (say, if they're checking their account info from home). But at this point I'll take anything that works. Can I infer from your message that none of the 4 scripts I mentioned are working under Koha 3? I tried all four, but got error messages along the lines of this: > export PERL5LIB=/usr/share/koha/lib > export KOHA_CONF=/etc/koha/koha-conf.xml > /usr/share/koha/bin/fines2.pl Can't locate object method "preference" via package "C4::context" (perhaps you forgot to load "C4::context"?) at /usr/share/koha/lib/C4/Overdues.pm line 116. How is everyone else running Koha calculating fines? Thanks again.
Date: Tue, 26 Feb 2008 15:37:23 -0500 From: kyle.m.hall@gmail.com To: g_adams27@hotmail.com Subject: Re: [Koha] Calculating fines? CC: koha@lists.katipo.co.nz
2) Why is a cronjob even necessary? i.e. why can't Koha look at today's date and the books' due dates, then calculate on the fly what the overdue fines are whenever the patron or librarian pulls up a record within the OPAC?
You may want to check out the fines script I wrote for our library. It calculates fines for items as they are checked in. http://koha-tools.svn.sourceforge.net/viewvc/koha-tools/finesScripts/trunk/
Kyle -- http://www.kylehall.info Information Technology Crawford County Federated Library System ( http://www.ccfls.org )
_________________________________________________________________ Need to know the score, the latest news, or you need your Hotmail®-get your "fix". http://www.msnmobilefix.com/Default.aspx
On Tue, Feb 26, 2008 at 4:39 PM, George Adams <g_adams27@hotmail.com> wrote:
Kyle, thanks for the reply. I'll look into that script, although there'd be some value in patrons (and staff) knowing what their fines are going to be before the books are checked in (say, if they're checking their account info from home). But at this point I'll take anything that works.
Can I infer from your message that none of the 4 scripts I mentioned are working under Koha 3? I tried all four, but got error messages along the lines of this:
> export PERL5LIB=/usr/share/koha/lib > export KOHA_CONF=/etc/koha/koha-conf.xml > /usr/share/koha/bin/fines2.pl Can't locate object method "preference" via package "C4::context" (perhaps you forgot to load "C4::context"?) at /usr/share/koha/lib/C4/Overdues.pm line 116.
This is a bug due to a misspelling of 'context' Line 116 in Overdues.pm should read "C4::Context" rather than "C4::context" I have submitted a patch to correct this so you will either have to grab a copy of the patched Overdues.pm or make the change manually on your installation. Regards, Chris -- Chris Nighswonger Faculty Member Network & Systems Director Foundations Bible College & Seminary www.foundations.edu www.fbcradio.org
On Tue, Feb 26, 2008 at 11:54 AM, George Adams <g_adams27@hotmail.com> wrote:
1) All 4 of these scripts say "This script is meant to be run nightly out of cron". Which of these should I actually setup to run nightly?
Probably you want cronjobs/fines2.pl Schedule only one of these scripts nightly, of course. Running multiple scripts will trigger multiple fines.
2) Why is a cronjob even necessary? i.e. why can't Koha look at today's date and the books' due dates, then calculate on the fly what the overdue fines are whenever the patron or librarian pulls up a record within the OPAC?
The performance of such an implementation would be at a disadvantage. The fines rules can be somewhat complex with inheritance of defaults based on item category. You would need to recalculate possible fines for each of a patron's checked out items on each of their subsequent transactions. You wouldn't know whether a patron was able to check out anything until you completed this computation. How would you handle an arbitrary fine (for usage, new library card, services, etc.)? or the overdue fine after the item is returned? Clearly you would need a populate fine table anyway, but it isn't authoritative. On each of your transactions, you'd already be doing the fines query that Koha normally does, and then going on to compute "on the fly" for each of the checked out items. Both the logic and the performance of fines accounting are compromised in this model. Then what would a library do if they wanted to send notices about overdue fines? They would have to pick a time to process all the checked out items, determine the amount of fines, combine them with the partial fines table, send or print messages, etc. You can see that the nightly fines cron task functions as a subset of this. As for Koha's logic, the nightly cron job preserves the authoritative nature of the fines table. --joe atzberger
Thanks again to everyone who helped with the overdue fine processing, both with code help and explanatory help for why it works the way it does. Chris, thanks for the bugfix for cronjobs/fines2.pl - changing "C4::context" to "C4::Context" did indeed fix that problem. cronjobs/fines2.pl still died with the following error: Can't use string ("0") as a HASH ref while "strict refs" in use at /usr/share/koha/lib/C4/Overdues.pm line 511. Poring through the code, it appears that this command caused the error: &logaction( C4::Context->userenv->{'number'}, "FINES", $type, $borrowernumber, "due=".$due." amount=".$amount." itemnumber=".$itemnum ) if C4::Context->preference("FinesLog"); I changed it to this, which seemed to fix the problem: &logaction( "", "FINES", $type, $borrowernumber, "due=".$due." amount=".$amount." itemnumber=".$itemnum ) if C4::Context->preference("FinesLog"); I'm not sure what C4::Context->userenv->{'number'} was supposed to be, but I was guessing that it would normally be assigned a value if the script was running in a web environment but not in a cron environment. Since blanking it out didn't seem to hurt anything, I decided it was a Good Enough fix for me. Just in case anyone else needs to know. _________________________________________________________________ Connect and share in new ways with Windows Live. http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008
participants (4)
-
Chris Nighswonger -
George Adams -
Joe Atzberger -
Kyle Hall