From c0ec5f0c7dde617abc0e0f732694b0e4aa51fb3b Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Mon, 18 Sep 2017 13:24:13 -0400 Subject: [PATCH] Bug 19336: Add --maxfinesday option to fines.pl This is a functionality we have for some of our clients we want to push to the community. Adds the --maxfinesday argument to fines.pl which creates or updates a fine with the maximum amount set in the circulation rules after the delay has passed. e.g.: ./fines.pl --maxfinesdays 30 All item over 30 days late will have the maximal fine applied. Here is a test plan I followed based on above. Test plan: 1. Create circulation rule with Overdue fines cap set 2. Set finesMode systempreference to 'Calculate and charge' 3. Check out an item with the due date set 30 days ago 4. In Koha shell run ./fines.pl --maxfinesdays 30 5. There should now be a new fine in the accountlines table of the amount set in overdue fines cap Followed test plan, patch worked as intended Signed-off-by: Alex Buckley --- misc/cronjobs/fines.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index a32562ad3a..5b24ab3c3d 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -49,6 +49,7 @@ my $output_dir; my $log; my $maxdays; my $verify_issue; +my $maxfinesdays; my $command_line_options = join(" ",@ARGV); @@ -59,6 +60,7 @@ GetOptions( 'o|out:s' => \$output_dir, 'm|maxdays:i' => \$maxdays, 'i|verifyissue' => \$verify_issue, + 'maxfinesdays=i' => \$maxfinesdays ); my $usage = << 'ENDUSAGE'; @@ -75,6 +77,7 @@ This script has the following parameters : -m --maxdays: how many days back of overdues to process -i --verifyissue: verify the issue before updating the fine in case the item is returned while the fines job is running + --maxfinesdays: number of days after which normal fine amount should jump to maximal amount ENDUSAGE @@ -151,9 +154,16 @@ for my $overdue ( @{$overdues} ) { } ++$counted; - my ( $amount, $unitcounttotal, $unitcount ) = - CalcFine( $overdue, $patron->categorycode, - $branchcode, $datedue, $today ); + my ( $amount, $unitcounttotal, $unitcount); + if ( defined($maxfinesdays) && $maxfinesdays <= $datedue->delta_days( $today )) { + my $itype = $overdue->{itemtype} || $overdue->{itype}; + my $data = C4::Circulation::GetIssuingRule( $borrower->{categorycode}, $itype, $branchcode ); + $amount = $data->{overduefinescap}; + } + if (!$amount) { + ( $amount, $unitcounttotal, $unitcount ) = CalcFine( $overdue, $borrower->{categorycode}, $branchcode, $datedue, $today ); + } + # Don't update the fine if today is a holiday. # This ensures that dropbox mode will remove the correct amount of fine. -- 2.34.1