From 40c62453d9aa69d3bc508658ad6a5d2227cf467a 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. --- misc/cronjobs/fines.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 6c3f830..361f37e 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -44,12 +44,14 @@ my $help; my $verbose; my $output_dir; my $log; +my $maxfinesdays; GetOptions( 'h|help' => \$help, 'v|verbose' => \$verbose, 'l|log' => \$log, - 'o|out:s' => \$output_dir, + 'o|out=s' => \$output_dir, + 'maxfinesdays=i' => \$maxfinesdays ); my $usage = << 'ENDUSAGE'; @@ -63,6 +65,7 @@ This script has the following parameters : -l --log: log the output to a file (optional if the -o parameter is given) -o --out: ouput directory for logs (defaults to env or /tmp if !exist) -v --verbose + --maxfinesdays: number of days after which normal fine amount should jump to maximal amount ENDUSAGE @@ -122,9 +125,16 @@ for my $overdue ( @{$overdues} ) { } ++$counted; - my ( $amount, $type, $unitcounttotal ) = - CalcFine( $overdue, $borrower->{categorycode}, - $branchcode, $datedue, $today ); + my ( $amount, $type, $unitcounttotal ); + 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, $type, $unitcounttotal ) = CalcFine( $overdue, $borrower->{categorycode}, $branchcode, $datedue, $today ); + } + $type ||= q{}; # Don't update the fine if today is a holiday. -- 2.7.4