use C4::SIP::ILS::Transaction;
use C4::Circulation;
-use C4::Reserves qw( ModReserveAffect );
-use C4::Items qw( ModItemTransfer );
use C4::Debug;
+use C4::Items qw( ModItemTransfer );
+use C4::Reserves qw( ModReserveAffect );
+use Koha::DateUtils qw( dt_from_string );
use parent qw(C4::SIP::ILS::Transaction);
my $self = shift;
my $branch = shift;
my $return_date = shift;
+ my $cv_triggers_alert = shift;
+ my $checked_in_ok = shift;
+
if (!$branch) {
$branch = 'SIP2';
}
. substr( $return_date, 16, 2 );
$debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
- my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
- $self->alert(!$return);
- # ignoring messages: NotIssued, WasLost, WasTransfered
+ my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, dt_from_string($return_date));
+
+ if ( $checked_in_ok ) {
+ delete $messages->{NotIssued};
+ delete $messages->{LocalUse};
+ $return = 1 unless keys %$messages;
+ }
# biblionumber, biblioitemnumber, itemnumber
# borrowernumber, reservedate, branchcode
if ($messages->{withdrawn}) {
$self->alert_type('99');
}
+ if ($messages->{ReturnOfLostItemBlocked}) {
+ $self->alert_type('99');
+ }
if ($messages->{Wrongbranch}) {
$self->{item}->destination_loc($messages->{Wrongbranch}->{Rightbranch});
$self->alert_type('04'); # send to other branch
$self->{item}->hold_patron_id( $messages->{ResFound}->{borrowernumber} );
$self->{item}->destination_loc( $messages->{ResFound}->{branchcode} );
}
- $self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
+ # ignoring messages: NotIssued, WasLost, WasTransfered
+
+ if ($cv_triggers_alert) {
+ $self->alert( defined $self->alert_type ); # Overwrites existing alert value, should set to 0 if there is no alert type
+ }
+ else {
+ $self->alert( !$return || defined $self->alert_type );
+ }
+
$self->ok($return);
+
+ return { messages => $messages };
}
sub resensitize {