=head2 CanBookBeIssued
- ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower,
+ ( $issuingimpossible, $needsconfirmation, [ $alerts ] ) = CanBookBeIssued( $borrower,
$barcode, $duedate, $inprocess, $ignore_reserves, $params );
Check if a book can be issued.
if the borrower borrows to much things
+=head3 NB
+
+The assumption by users of the routine is that causes blocking
+the issue are keyed by uppercase labels and other returned
+data is keyed in lower case
+
=cut
sub CanBookBeIssued {
$debug and warn "do_checkout: patron (" . $patron_barcode . ")";
my $borrower = $self->{patron}->getmemberdetails_object();
$debug and warn "do_checkout borrower: . " . Dumper $borrower;
- my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued(
- $borrower,
- $barcode,
- undef,
- 0,
+ my ($issuingimpossible, $needsconfirmation) = _can_we_issue($borrower, $barcode,
C4::Context->preference("AllowItemsOnHoldCheckout")
);
- my $noerror=1;
- if (scalar keys %$issuingimpossible) {
- foreach (keys %$issuingimpossible) {
+
+ my $noerror=1; # If set to zero we block the issue
+ if (keys %{$issuingimpossible}) {
+ foreach (keys %{$issuingimpossible}) {
# do something here so we pass these errors
- $self->screen_msg($_ . ': ' . $issuingimpossible->{$_});
+ $self->screen_msg("Issue failed : $_");
$noerror = 0;
+ last;
}
} else {
foreach my $confirmation (keys %{$needsconfirmation}) {
$self->screen_msg("Item was reserved for you.");
} else {
$self->screen_msg("Item is reserved for another patron upon return.");
- # $noerror = 0;
+ $noerror = 0;
}
} elsif ($confirmation eq 'ISSUED_TO_ANOTHER') {
$self->screen_msg("Item already checked out to another patron. Please return item for check-in.");
$noerror = 0;
+ last;
} elsif ($confirmation eq 'DEBT') {
$self->screen_msg('Outstanding Fines block issue');
$noerror = 0;
+ last;
} elsif ($confirmation eq 'HIGHHOLDS') {
$overridden_duedate = $needsconfirmation->{$confirmation}->{returndate};
$self->screen_msg('Loan period reduced for high-demand item');
} elsif ($confirmation eq 'RENTALCHARGE') {
if ($self->{fee_ack} ne 'Y') {
$noerror = 0;
+ last;
}
} else {
- $self->screen_msg($needsconfirmation->{$confirmation});
+ # We've been returned a case other than those above
+ $self->screen_msg("Item cannot be issued: $confirmation");
$noerror = 0;
syslog('LOG_DEBUG', "Blocking checkout Reason:$confirmation");
+ last;
}
}
}
return $self;
}
+sub _can_we_issue {
+ my ( $borrower, $barcode, $pref ) = @_;
+
+ my ( $issuingimpossible, $needsconfirmation, $alerts ) =
+ CanBookBeIssued( $borrower, $barcode, undef, 0, $pref );
+ for my $href ( $issuingimpossible, $needsconfirmation ) {
+
+ # some data is returned using lc keys we only
+ foreach my $key ( keys %{$href} ) {
+ if ( $key =~ m/[^A-Z_]/ ) {
+ delete $href->{$key};
+ }
+ }
+ }
+ return ( $issuingimpossible, $needsconfirmation );
+}
+
1;
__END__