&parse_overdues_letter
);
- # subs to remove
- push @EXPORT, qw(
- &BorType
- );
-
- # check that an equivalent don't exist already before moving
-
# subs to move to Circulation.pm
push @EXPORT, qw(
&GetIssuesIteminfo
}
}
-=head2 BorType
-
- $borrower = &BorType($borrowernumber);
-
-Looks up a patron by borrower number.
-
-C<$borrower> is a reference-to-hash whose keys are all of the fields
-from the borrowers and categories tables of the Koha database. Thus,
-C<$borrower> contains all information about both the borrower and
-category they belong to.
-
-=cut
-
-sub BorType {
- my ($borrowernumber) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
- "SELECT * from borrowers
- LEFT JOIN categories ON borrowers.categorycode=categories.categorycode
- WHERE borrowernumber=?"
- );
- $sth->execute($borrowernumber);
- return $sth->fetchrow_hashref;
-}
-
=head2 GetFine
$data->{'sum(amountoutstanding)'} = &GetFine($itemnum,$borrowernumber);
use Modern::Perl;
use C4::Context;
-use C4::Overdues qw/CalcFine BorType/;
+use C4::Overdues qw/CalcFine/;
use C4::Log qw/logaction/;
use Koha::DateUtils;
+use Koha::Patrons;
use Getopt::Long;
my ($help, $verbose, $confirm, $log, $stdout_log);
my $overdue = $overdues->[0];
### last if $overdue->{itemlost}; ## arguable
- my $borrower = BorType( $overdue->{borrowernumber} );
+ my $patron = Koha::Patron->find( $overdue->{borrowernumber} );
my $branchcode =
( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch}
- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode}
+ : ( $control eq 'PatronLibrary' ) ? $patron->branchcode
: $overdue->{branchcode};
- my ($amount) = CalcFine( $overdue, $borrower->{categorycode}, $branchcode, $datedue, $today );
+ my ($amount) = CalcFine( $overdue, $patron->categorycode, $branchcode, $datedue, $today );
### Warn("CalcFine() returned '$amount'");
last if ($amount > 0); ## accruing fine, skip closing
use Koha::Calendar;
use Koha::DateUtils;
+use Koha::Patrons;
use C4::Log;
my $help;
"ERROR in Getoverdues : issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n";
next;
}
- my $borrower = BorType( $overdue->{borrowernumber} );
+ my $patron = Koha::Patrons->find( $overdue->{borrowernumber} );
my $branchcode =
( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch}
- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode}
+ : ( $control eq 'PatronLibrary' ) ? $patron->branchcode
: $overdue->{branchcode};
# In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here).
++$counted;
my ( $amount, $unitcounttotal, $unitcount ) =
- CalcFine( $overdue, $borrower->{categorycode},
+ CalcFine( $overdue, $patron->categorycode,
$branchcode, $datedue, $today );
# Don't update the fine if today is a holiday.
);
}
}
+ my $borrower = $patron->unblessed;
if ($filename) {
my @cells;
push @cells,
use Getopt::Long;
use List::MoreUtils qw/none/;
use Koha::DateUtils;
+use Koha::Patrons;
my $help = 0;
my $verbose = 0;
print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n";
next; # Note: this doesn't solve everything. After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up.
}
- my $borrower = BorType( $data->[$i]->{'borrowernumber'} );
+ my $patron = Koha::Patrons->find( $data->[$i]->{'borrowernumber'} );
# Skipping borrowers that are not in @categories
- $bigdebug and warn "Skipping borrower from category " . $borrower->{categorycode} if none { $borrower->{categorycode} eq $_ } @categories;
- next if none { $borrower->{categorycode} eq $_ } @categories;
+ $bigdebug and warn "Skipping borrower from category " . $patron->categorycode if none { $patron->categorycode eq $_ } @categories;
+ next if none { $patron->categorycode eq $_ } @categories;
my $branchcode =
- ( $useborrowerlibrary ) ? $borrower->{branchcode}
+ ( $useborrowerlibrary ) ? $patron->branchcode
: ( $control eq 'ItemHomeLibrary' ) ? $data->[$i]->{homebranch}
- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode}
+ : ( $control eq 'PatronLibrary' ) ? $patron->branchcode
: $data->[$i]->{branchcode};
# In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here).
$overdueItemsCounted++;
my ( $amount, $unitcounttotal, $unitcount ) = CalcFine(
$data->[$i],
- $borrower->{'categorycode'},
+ $patron->categorycode,
$branchcode,
$datedue,
$today,
);
# Reassign fine's amount if specified in command-line
- $amount = $catamounts{$borrower->{'categorycode'}} if (defined $catamounts{$borrower->{'categorycode'}});
+ $amount = $catamounts{$patron->categorycode} if (defined $catamounts{$patron->categorycode});
# We check if there is already a fine for the given borrower
my $fine = GetFine(undef, $data->[$i]->{'borrowernumber'});