View | Details | Raw Unified | Return to bug 25541
Collapse All | Expand All

(-)a/C4/SIP/ILS.pm (-2 / +10 lines)
Lines 197-203 sub test_cardnumber_compare { Link Here
197
}
197
}
198
198
199
sub checkin {
199
sub checkin {
200
    my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $checked_in_ok, $cv_triggers_alert ) = @_;
200
    my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $account ) = @_;
201
202
    my $checked_in_ok     = $account->{checked_in_ok};
203
    my $cv_triggers_alert = $account->{cv_triggers_alert};
204
    my $no_holds_checkin  = $account->{no_holds_checkin};
205
201
    my ( $patron, $item, $circ );
206
    my ( $patron, $item, $circ );
202
207
203
    $circ = C4::SIP::ILS::Transaction::Checkin->new();
208
    $circ = C4::SIP::ILS::Transaction::Checkin->new();
Lines 207-213 sub checkin { Link Here
207
212
208
    my $data;
213
    my $data;
209
    if ($item) {
214
    if ($item) {
210
        $data = $circ->do_checkin( $current_loc, $return_date, $cv_triggers_alert, $checked_in_ok );
215
        $data = $circ->do_checkin( $current_loc, $return_date, $account );
211
    }
216
    }
212
    else {
217
    else {
213
        $circ->alert(1);
218
        $circ->alert(1);
Lines 220-225 sub checkin { Link Here
220
    if ( !$circ->ok && $circ->alert_type && $circ->alert_type == 98 ) { # data corruption
225
    if ( !$circ->ok && $circ->alert_type && $circ->alert_type == 98 ) { # data corruption
221
        $circ->screen_msg("Checkin failed: data problem");
226
        $circ->screen_msg("Checkin failed: data problem");
222
        siplog( "LOG_WARNING", "Problem with issue_id in issues and old_issues; check the about page" );
227
        siplog( "LOG_WARNING", "Problem with issue_id in issues and old_issues; check the about page" );
228
    } elsif ( $data->{messages}->{ResFound} && !$circ->ok && $no_holds_checkin ) {
229
        $circ->screen_msg("Item is on hold, please return to circulation desk");
230
        siplog ("LOG_DEBUG", "C4::SIP::ILS::Checkin - item withdrawn");
223
    } elsif ( $data->{messages}->{withdrawn} && !$circ->ok && C4::Context->preference("BlockReturnOfWithdrawnItems") ) {
231
    } elsif ( $data->{messages}->{withdrawn} && !$circ->ok && C4::Context->preference("BlockReturnOfWithdrawnItems") ) {
224
            $circ->screen_msg("Item withdrawn, return not allowed");
232
            $circ->screen_msg("Item withdrawn, return not allowed");
225
            siplog ("LOG_DEBUG", "C4::SIP::ILS::Checkin - item withdrawn");
233
            siplog ("LOG_DEBUG", "C4::SIP::ILS::Checkin - item withdrawn");
(-)a/C4/SIP/ILS/Transaction/Checkin.pm (-4 / +11 lines)
Lines 48-55 sub do_checkin { Link Here
48
    my $self = shift;
48
    my $self = shift;
49
    my $branch = shift;
49
    my $branch = shift;
50
    my $return_date = shift;
50
    my $return_date = shift;
51
    my $cv_triggers_alert = shift;
51
    my $account = shift;
52
    my $checked_in_ok = shift;
52
53
    my $checked_in_ok     = $account->{checked_in_ok};
54
    my $cv_triggers_alert = $account->{cv_triggers_alert};
55
    my $no_holds_checkin  = $account->{no_holds_checkin};
53
56
54
    if (!$branch) {
57
    if (!$branch) {
55
        $branch = 'SIP2';
58
        $branch = 'SIP2';
Lines 113-125 sub do_checkin { Link Here
113
        $self->alert_type('04');            # send to other branch
116
        $self->alert_type('04');            # send to other branch
114
    }
117
    }
115
    if ($messages->{ResFound}) {
118
    if ($messages->{ResFound}) {
116
        $self->hold($messages->{ResFound});
119
        if ($no_holds_checkin) {
117
        if ($branch eq $messages->{ResFound}->{branchcode}) {
120
            $self->alert_type('99');
121
            $return = 0;
122
        } elsif ($branch eq $messages->{ResFound}->{branchcode}) {
123
            $self->hold($messages->{ResFound});
118
            $self->alert_type('01');
124
            $self->alert_type('01');
119
            ModReserveAffect( $messages->{ResFound}->{itemnumber},
125
            ModReserveAffect( $messages->{ResFound}->{itemnumber},
120
                $messages->{ResFound}->{borrowernumber}, 0, $messages->{ResFound}->{reserve_id});
126
                $messages->{ResFound}->{borrowernumber}, 0, $messages->{ResFound}->{reserve_id});
121
127
122
        } else {
128
        } else {
129
            $self->hold($messages->{ResFound});
123
            $self->alert_type('02');
130
            $self->alert_type('02');
124
            ModReserveAffect( $messages->{ResFound}->{itemnumber},
131
            ModReserveAffect( $messages->{ResFound}->{itemnumber},
125
                $messages->{ResFound}->{borrowernumber}, 1, $messages->{ResFound}->{reserve_id});
132
                $messages->{ResFound}->{borrowernumber}, 1, $messages->{ResFound}->{reserve_id});
(-)a/C4/SIP/Sip/MsgType.pm (-1 / +1 lines)
Lines 658-664 sub handle_checkin { Link Here
658
        siplog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
658
        siplog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
659
        $status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
659
        $status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
660
    } else {
660
    } else {
661
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok}, $account->{cv_triggers_alert} );
661
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account );
662
    }
662
    }
663
663
664
    $patron = $status->patron;
664
    $patron = $status->patron;
(-)a/etc/SIPconfig.xml (-1 / +2 lines)
Lines 59-65 Link Here
59
             da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
59
             da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
60
             av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"
60
             av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"
61
             hide_fields="BD,BE,BF,PB"
61
             hide_fields="BD,BE,BF,PB"
62
             register_id=''>
62
             register_id=''
63
             no_holds_checkin="1">
63
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
64
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
64
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
65
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
65
          <patron_attribute field="XY" code="CODE" />
66
          <patron_attribute field="XY" code="CODE" />
(-)a/t/db_dependent/SIP/Message.t (-2 / +24 lines)
Lines 29-34 use Test::Warn; Link Here
29
use t::lib::Mocks;
29
use t::lib::Mocks;
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
31
32
use C4::Reserves qw(AddReserve);
32
use Koha::Database;
33
use Koha::Database;
33
use Koha::AuthUtils qw(hash_password);
34
use Koha::AuthUtils qw(hash_password);
34
use Koha::DateUtils;
35
use Koha::DateUtils;
Lines 36-41 use Koha::Items; Link Here
36
use Koha::Checkouts;
37
use Koha::Checkouts;
37
use Koha::Old::Checkouts;
38
use Koha::Old::Checkouts;
38
use Koha::Patrons;
39
use Koha::Patrons;
40
use Koha::Holds;
39
41
40
use C4::SIP::ILS;
42
use C4::SIP::ILS;
41
use C4::SIP::ILS::Patron;
43
use C4::SIP::ILS::Patron;
Lines 67-73 subtest 'Testing Patron Info Request V2' => sub { Link Here
67
subtest 'Checkin V2' => sub {
69
subtest 'Checkin V2' => sub {
68
    my $schema = Koha::Database->new->schema;
70
    my $schema = Koha::Database->new->schema;
69
    $schema->storage->txn_begin;
71
    $schema->storage->txn_begin;
70
    plan tests => 29;
72
    plan tests => 33;
71
    $C4::SIP::Sip::protocol_version = 2;
73
    $C4::SIP::Sip::protocol_version = 2;
72
    test_checkin_v2();
74
    test_checkin_v2();
73
    $schema->storage->txn_rollback;
75
    $schema->storage->txn_rollback;
Lines 542-547 sub test_checkin_v2 { Link Here
542
    is( substr($response,5,1), 'N', 'Alert flag is not set' );
544
    is( substr($response,5,1), 'N', 'Alert flag is not set' );
543
    is( Koha::Checkouts->find( $issue->issue_id ), undef,
545
    is( Koha::Checkouts->find( $issue->issue_id ), undef,
544
        'Issue record is gone now' );
546
        'Issue record is gone now' );
547
548
    # Test account option no_holds_check that prevents items on hold from being checked in via SIP
549
    Koha::Old::Checkouts->search({ issue_id => $issue->issue_id })->delete;
550
    $server->{account}->{no_holds_checkin} = 1;
551
    my $reserve_id = AddReserve({
552
        branchcode     => $branchcode,
553
        borrowernumber => $patron1->{borrowernumber},
554
        biblionumber   => $item_object->biblionumber,
555
        priority       => 1,
556
    });
557
    my $hold = Koha::Holds->find( $reserve_id );
558
    is( $hold->id, $reserve_id, "Hold was created successfully" );
559
    undef $response;
560
    $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
561
    $msg->handle_checkin( $server );
562
    is( substr($response,2,1), '0', 'OK flag is false when we check in an item on hold and we do not allow it' );
563
    is( substr($response,5,1), 'Y', 'Alert flag is set' );
564
    check_field( $respcode, $response, FID_SCREEN_MSG, 'Item is on hold, please return to circulation desk', 'Screen message is correct' );
565
    $hold->delete();
566
    $server->{account}->{no_holds_checkin} = 0;
567
545
}
568
}
546
569
547
sub test_hold_patron_bcode {
570
sub test_hold_patron_bcode {
548
- 

Return to bug 25541