Lines 47-52
use C4::Log;
Link Here
|
47 |
use Getopt::Long; |
47 |
use Getopt::Long; |
48 |
use List::MoreUtils qw/none/; |
48 |
use List::MoreUtils qw/none/; |
49 |
use Koha::DateUtils; |
49 |
use Koha::DateUtils; |
|
|
50 |
use Koha::Patrons; |
50 |
|
51 |
|
51 |
my $help = 0; |
52 |
my $help = 0; |
52 |
my $verbose = 0; |
53 |
my $verbose = 0; |
Lines 157-172
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) {
Link Here
|
157 |
print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n"; |
158 |
print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n"; |
158 |
next; # Note: this doesn't solve everything. After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up. |
159 |
next; # Note: this doesn't solve everything. After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up. |
159 |
} |
160 |
} |
160 |
my $borrower = BorType( $data->[$i]->{'borrowernumber'} ); |
161 |
my $patron = Koha::Patrons->find( $data->[$i]->{'borrowernumber'} ); |
161 |
|
162 |
|
162 |
# Skipping borrowers that are not in @categories |
163 |
# Skipping borrowers that are not in @categories |
163 |
$bigdebug and warn "Skipping borrower from category " . $borrower->{categorycode} if none { $borrower->{categorycode} eq $_ } @categories; |
164 |
$bigdebug and warn "Skipping borrower from category " . $patron->categorycode if none { $patron->categorycode eq $_ } @categories; |
164 |
next if none { $borrower->{categorycode} eq $_ } @categories; |
165 |
next if none { $patron->categorycode eq $_ } @categories; |
165 |
|
166 |
|
166 |
my $branchcode = |
167 |
my $branchcode = |
167 |
( $useborrowerlibrary ) ? $borrower->{branchcode} |
168 |
( $useborrowerlibrary ) ? $patron->branchcode |
168 |
: ( $control eq 'ItemHomeLibrary' ) ? $data->[$i]->{homebranch} |
169 |
: ( $control eq 'ItemHomeLibrary' ) ? $data->[$i]->{homebranch} |
169 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
170 |
: ( $control eq 'PatronLibrary' ) ? $patron->branchcode |
170 |
: $data->[$i]->{branchcode}; |
171 |
: $data->[$i]->{branchcode}; |
171 |
# In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). |
172 |
# In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). |
172 |
|
173 |
|
Lines 190-203
for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) {
Link Here
|
190 |
$overdueItemsCounted++; |
191 |
$overdueItemsCounted++; |
191 |
my ( $amount, $unitcounttotal, $unitcount ) = CalcFine( |
192 |
my ( $amount, $unitcounttotal, $unitcount ) = CalcFine( |
192 |
$data->[$i], |
193 |
$data->[$i], |
193 |
$borrower->{'categorycode'}, |
194 |
$patron->categorycode, |
194 |
$branchcode, |
195 |
$branchcode, |
195 |
$datedue, |
196 |
$datedue, |
196 |
$today, |
197 |
$today, |
197 |
); |
198 |
); |
198 |
|
199 |
|
199 |
# Reassign fine's amount if specified in command-line |
200 |
# Reassign fine's amount if specified in command-line |
200 |
$amount = $catamounts{$borrower->{'categorycode'}} if (defined $catamounts{$borrower->{'categorycode'}}); |
201 |
$amount = $catamounts{$patron->categorycode} if (defined $catamounts{$patron->categorycode}); |
201 |
|
202 |
|
202 |
# We check if there is already a fine for the given borrower |
203 |
# We check if there is already a fine for the given borrower |
203 |
my $fine = GetFine(undef, $data->[$i]->{'borrowernumber'}); |
204 |
my $fine = GetFine(undef, $data->[$i]->{'borrowernumber'}); |
204 |
- |
|
|