From bb0b2fee7c2c9ad6d5925c8381e00299a8e0e164 Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Fri, 20 Oct 2017 09:11:47 -0400 Subject: [PATCH] Bug 19336: (follow-up) Correct DateTime and Koha calls This fixes the 'DateTime does not overload' error. It also fixes the next error, which was that C4::GetIssuingRules is deprecated. Finally it now handles no overduefinescap being define (does nothing). Passes QA test tool Signed-off-by: Alex Buckley --- misc/cronjobs/fines.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 5b24ab3c3d..43b7b8e614 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -38,6 +38,7 @@ use Carp qw( carp croak ); use File::Spec; use Try::Tiny qw( catch try ); +use Koha::IssuingRules; use Koha::Calendar; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patrons; @@ -155,10 +156,15 @@ for my $overdue ( @{$overdues} ) { ++$counted; my ( $amount, $unitcounttotal, $unitcount); - if ( defined($maxfinesdays) && $maxfinesdays <= $datedue->delta_days( $today )) { + if ( defined($maxfinesdays) && $maxfinesdays <= $datedue->delta_days( $today )->in_units( 'days' ) ) { my $itype = $overdue->{itemtype} || $overdue->{itype}; - my $data = C4::Circulation::GetIssuingRule( $borrower->{categorycode}, $itype, $branchcode ); - $amount = $data->{overduefinescap}; + my $data = Koha::IssuingRules->get_effective_issuing_rule( { categorycode => $borrower->{categorycode}, itemtype => $itype, branchcode => $branchcode } ); + if ( defined($data->overduefinescap) ) { + $amount = $data->overduefinescap; + } + else { + print "No overduefinescap defined for {branchcode = $branchcode, itemtype = $itype and categorycode = $borrower->{categorycode}}\n"; + } } if (!$amount) { ( $amount, $unitcounttotal, $unitcount ) = CalcFine( $overdue, $borrower->{categorycode}, $branchcode, $datedue, $today ); -- 2.34.1