Lines 45-50
use C4::Biblio;
Link Here
|
45 |
use C4::Debug; # supplying $debug and $cgi_debug |
45 |
use C4::Debug; # supplying $debug and $cgi_debug |
46 |
use Getopt::Long; |
46 |
use Getopt::Long; |
47 |
use List::MoreUtils qw/none/; |
47 |
use List::MoreUtils qw/none/; |
|
|
48 |
use Koha::DateUtils; |
48 |
|
49 |
|
49 |
my $help = 0; |
50 |
my $help = 0; |
50 |
my $verbose = 0; |
51 |
my $verbose = 0; |
Lines 122-133
INIT {
Link Here
|
122 |
"Delimiter: '$delim'\n"; |
123 |
"Delimiter: '$delim'\n"; |
123 |
} |
124 |
} |
124 |
$debug and (defined $borrowernumberlimit) and print "--borrower limitation: borrower $borrowernumberlimit\n"; |
125 |
$debug and (defined $borrowernumberlimit) and print "--borrower limitation: borrower $borrowernumberlimit\n"; |
125 |
my $data = (defined $borrowernumberlimit) ? checkoverdues($borrowernumberlimit) : Getoverdues(); |
126 |
my ($numOverdueItems, $data); |
|
|
127 |
if (defined $borrowernumberlimit) { |
128 |
($numOverdueItems, $data) = checkoverdues($borrowernumberlimit); |
129 |
} else { |
130 |
$data = Getoverdues(); |
131 |
$numOverdueItems = scalar @$data; |
132 |
} |
126 |
my $overdueItemsCounted = 0; |
133 |
my $overdueItemsCounted = 0; |
127 |
my %calendars = (); |
134 |
my %calendars = (); |
128 |
$today = C4::Dates->new(); |
135 |
$today = C4::Dates->new(); |
129 |
$today_iso = $today->output('iso'); |
136 |
$today_iso = $today->output('iso'); |
130 |
$today_days = Date_to_Days( split( /-/, $today_iso ) ); |
137 |
my ($tyear, $tmonth, $tday) = split( /-/, $today_iso ); |
|
|
138 |
$today_days = Date_to_Days( $tyear, $tmonth, $tday ); |
131 |
|
139 |
|
132 |
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { |
140 |
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { |
133 |
my $datedue; |
141 |
my $datedue; |
Lines 167-173
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) {
Link Here
|
167 |
$calendars{$branchcode} = C4::Calendar->new( branchcode => $branchcode ); |
175 |
$calendars{$branchcode} = C4::Calendar->new( branchcode => $branchcode ); |
168 |
} |
176 |
} |
169 |
$calendar = $calendars{$branchcode}; |
177 |
$calendar = $calendars{$branchcode}; |
170 |
my $isHoliday = $calendar->isHoliday( split '/', $today->output('metric') ); |
178 |
my $isHoliday = $calendar->isHoliday( $tday, $tmonth, $tyear ); |
171 |
|
179 |
|
172 |
# Reassing datedue_days if -delay specified in commandline |
180 |
# Reassing datedue_days if -delay specified in commandline |
173 |
$bigdebug and warn "Using commandline supplied delay : $delay" if ($delay); |
181 |
$bigdebug and warn "Using commandline supplied delay : $delay" if ($delay); |
Lines 176-182
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) {
Link Here
|
176 |
( $datedue_days <= $today_days ) or next; # or it's not overdue, right? |
184 |
( $datedue_days <= $today_days ) or next; # or it's not overdue, right? |
177 |
|
185 |
|
178 |
$overdueItemsCounted++; |
186 |
$overdueItemsCounted++; |
179 |
my ( $amount, $type, $unitcounttotal, $unitcount ) = CalcFine( $data->[$i], $borrower->{'categorycode'}, $branchcode, undef, undef, $datedue, $today ); |
187 |
my ( $amount, $type, $unitcounttotal, $unitcount ) = CalcFine( |
|
|
188 |
$data->[$i], |
189 |
$borrower->{'categorycode'}, |
190 |
$branchcode, |
191 |
dt_from_string($datedue->output('iso')), |
192 |
dt_from_string($today->output('iso')), |
193 |
); |
180 |
|
194 |
|
181 |
# Reassign fine's amount if specified in command-line |
195 |
# Reassign fine's amount if specified in command-line |
182 |
$amount = $catamounts{$borrower->{'categorycode'}} if (defined $catamounts{$borrower->{'categorycode'}}); |
196 |
$amount = $catamounts{$borrower->{'categorycode'}} if (defined $catamounts{$borrower->{'categorycode'}}); |
Lines 224-230
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) {
Link Here
|
224 |
} |
238 |
} |
225 |
} |
239 |
} |
226 |
|
240 |
|
227 |
my $numOverdueItems = scalar(@$data); |
|
|
228 |
if ($verbose) { |
241 |
if ($verbose) { |
229 |
print <<EOM; |
242 |
print <<EOM; |
230 |
Fines assessment -- $today_iso |
243 |
Fines assessment -- $today_iso |
231 |
- |
|
|