# An object to handle checkin status
#
-package ILS::Transaction::Checkin;
+package C4::SIP::ILS::Transaction::Checkin;
use warnings;
use strict;
# use POSIX qw(strftime);
-use ILS;
-use ILS::Transaction;
+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(ILS::Transaction);
+use parent qw(C4::SIP::ILS::Transaction);
my %fields = (
magnetic => 0,
my $self = shift;
my $branch = shift;
my $return_date = shift;
+ my $cv_triggers_alert = shift;
+
if (!$branch) {
$branch = 'SIP2';
}
. substr( $return_date, 16, 2 );
$debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
- my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
+ my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, dt_from_string($return_date));
$self->alert(!$return);
- # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered
+ # ignoring messages: NotIssued, WasLost, WasTransfered
# biblionumber, biblioitemnumber, itemnumber
# borrowernumber, reservedate, branchcode
# cancellationdate, found, reservenotes, priority, timestamp
-
+ if( $messages->{DataCorrupted} ) {
+ $self->alert_type('98');
+ }
if ($messages->{BadBarcode}) {
$self->alert_type('99');
}
$self->alert_type('99');
}
if ($messages->{Wrongbranch}) {
- $self->destination_loc($messages->{Wrongbranch}->{Rightbranch});
+ $self->{item}->destination_loc($messages->{Wrongbranch}->{Rightbranch});
$self->alert_type('04'); # send to other branch
}
if ($messages->{WrongTransfer}) {
- $self->destination_loc($messages->{WrongTransfer});
+ $self->{item}->destination_loc($messages->{WrongTransfer});
$self->alert_type('04'); # send to other branch
}
if ($messages->{NeedsTransfer}) {
- $self->destination_loc($iteminformation->{homebranch});
+ $self->{item}->destination_loc($messages->{NeedsTransfer});
+ $self->alert_type('04'); # send to other branch
+ }
+ if ($messages->{WasTransfered}) { # set into transit so tell unit
+ $self->{item}->destination_loc($issue->item->homebranch);
$self->alert_type('04'); # send to other branch
}
if ($messages->{ResFound}) {
if ($branch eq $messages->{ResFound}->{branchcode}) {
$self->alert_type('01');
ModReserveAffect( $messages->{ResFound}->{itemnumber},
- $messages->{ResFound}->{borrowernumber}, 0);
+ $messages->{ResFound}->{borrowernumber}, 0, $messages->{ResFound}->{reserve_id});
} else {
$self->alert_type('02');
ModReserveAffect( $messages->{ResFound}->{itemnumber},
- $messages->{ResFound}->{borrowernumber}, 1);
+ $messages->{ResFound}->{borrowernumber}, 1, $messages->{ResFound}->{reserve_id});
ModItemTransfer( $messages->{ResFound}->{itemnumber},
$branch,
$messages->{ResFound}->{branchcode}
$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
+
+ my $alert = defined $self->alert_type;
+ if ( $cv_triggers_alert ) {
+ $self->alert($alert); # Overwrites existing alert value, should set to 0 if there is no alert type
+ } else {
+ $self->alert($alert) if $alert; # Doesn't affect alert value unless an alert type is set
+ }
+
$self->ok($return);
}