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

(-)a/C4/SIP/ILS.pm (-4 / +9 lines)
Lines 123-143 sub offline_ok { Link Here
123
sub checkout {
123
sub checkout {
124
    my ( $self, $patron_id, $item_id, $sc_renew, $fee_ack, $account ) = @_;
124
    my ( $self, $patron_id, $item_id, $sc_renew, $fee_ack, $account ) = @_;
125
    my ( $patron, $item, $circ );
125
    my ( $patron, $item, $circ );
126
127
    $circ = C4::SIP::ILS::Transaction::Checkout->new();
126
    $circ = C4::SIP::ILS::Transaction::Checkout->new();
128
129
    # BEGIN TRANSACTION
127
    # BEGIN TRANSACTION
130
    $circ->patron( $patron = C4::SIP::ILS::Patron->new($patron_id) );
128
    $circ->patron( $patron = C4::SIP::ILS::Patron->new($patron_id) );
131
    $circ->item( $item     = C4::SIP::ILS::Item->new($item_id) );
129
    $circ->item( $item     = C4::SIP::ILS::Item->new($item_id) );
132
    if ($fee_ack) {
130
    if ($fee_ack) {
133
        $circ->fee_ack($fee_ack);
131
        $circ->fee_ack($fee_ack);
134
    }
132
    }
135
136
    if ( !$patron ) {
133
    if ( !$patron ) {
137
        $circ->screen_msg("Invalid Patron");
134
        $circ->screen_msg("Invalid Patron");
138
    }
135
    }
139
    elsif ( !$patron->charge_ok ) {
136
    elsif ( !$patron->charge_ok ) {
140
        $circ->screen_msg("Patron Blocked");
137
        if ($patron->debarred) {
138
            $circ->screen_msg("Patron debarred");
139
        } elsif ($patron->expired) {
140
            $circ->screen_msg("Patron expired");
141
        } elsif ($patron->fine_blocked) {
142
            $circ->screen_msg("Patron has fines");
143
        } else {
144
            $circ->screen_msg("Patron blocked");
145
        }
141
    }
146
    }
142
    elsif ( !$item ) {
147
    elsif ( !$item ) {
143
        $circ->screen_msg("Invalid Item");
148
        $circ->screen_msg("Invalid Item");
(-)a/C4/SIP/ILS/Patron.pm (+4 lines)
Lines 126-132 sub new { Link Here
126
        recall_items    => [],
126
        recall_items    => [],
127
        unavail_holds   => [],
127
        unavail_holds   => [],
128
        inet            => ( !$debarred && !$expired ),
128
        inet            => ( !$debarred && !$expired ),
129
        debarred        => $debarred,
129
        expired         => $expired,
130
        expired         => $expired,
131
        fine_blocked    => $fine_blocked,
130
        fee_limit       => $fee_limit,
132
        fee_limit       => $fee_limit,
131
        userid          => $kp->{userid},
133
        userid          => $kp->{userid},
132
    );
134
    );
Lines 181-186 my %fields = ( Link Here
181
    birthdate_iso           => 0,
183
    birthdate_iso           => 0,
182
    dateexpiry              => 0,
184
    dateexpiry              => 0,
183
    dateexpiry_iso          => 0,
185
    dateexpiry_iso          => 0,
186
    debarred                => 0,
187
    fine_blocked            => 0,
184
    ptype                   => 0,
188
    ptype                   => 0,
185
    charge_ok               => 0,   # for patron_status[0] (inverted)
189
    charge_ok               => 0,   # for patron_status[0] (inverted)
186
    renew_ok                => 0,   # for patron_status[1] (inverted)
190
    renew_ok                => 0,   # for patron_status[1] (inverted)
(-)a/t/db_dependent/SIP/Transaction.t (-2 / +91 lines)
Lines 4-10 Link Here
4
# Current state is very rudimentary. Please help to extend it!
4
# Current state is very rudimentary. Please help to extend it!
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::More tests => 13;
7
use Test::More tests => 14;
8
8
9
use Koha::Database;
9
use Koha::Database;
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
Lines 377-382 subtest do_checkin => sub { Link Here
377
    };
377
    };
378
};
378
};
379
379
380
subtest do_checkout_with_patron_blocked => sub {
381
    plan tests => 4;
382
383
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
384
    my $institution = {
385
        id             => $library->id,
386
        implementation => "ILS",
387
        policy         => {
388
            checkin  => "true",
389
            renewal  => "true",
390
            checkout => "true",
391
            timeout  => 100,
392
            retries  => 5,
393
        }
394
    };
395
    my $ils = C4::SIP::ILS->new($institution);
396
    my $item = $builder->build_sample_item(
397
        {
398
            library => $library->branchcode,
399
        }
400
    );
401
402
    my $expired_patron = $builder->build_object(
403
        {
404
            class => 'Koha::Patrons',
405
            value => {
406
                branchcode => $library->branchcode,
407
                dateexpiry => '2020/01/01',
408
            }
409
        }
410
    );
411
    my $circ = $ils->checkout($expired_patron->cardnumber, $item->barcode);
412
    is( $circ->{screen_msg}, 'Patron expired', "Got correct expired screen message" );
413
414
    my $fines_patron = $builder->build_object(
415
        {
416
            class => 'Koha::Patrons',
417
            value => {
418
                branchcode => $library->branchcode,
419
            }
420
        }
421
    );
422
    my $fee1 = $builder->build(
423
        {
424
            source => 'Accountline',
425
            value  => {
426
                borrowernumber => $fines_patron->borrowernumber,
427
                amountoutstanding => 10,
428
            }
429
        }
430
    );
431
432
    my $fines_sip_patron  = C4::SIP::ILS::Patron->new( $fines_patron->cardnumber );
433
    $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode);
434
    is( $circ->{screen_msg}, 'Patron has fines', "Got correct fines screen message" );
435
436
    my $debarred_patron = $builder->build_object(
437
        {
438
            class => 'Koha::Patrons',
439
            value => {
440
                branchcode => $library->branchcode,
441
                debarred => '9999/01/01',
442
            }
443
        }
444
    );
445
    my $debarred_sip_patron  = C4::SIP::ILS::Patron->new( $debarred_patron->cardnumber );
446
    $circ = $ils->checkout($debarred_patron->cardnumber, $item->barcode);
447
    is( $circ->{screen_msg}, 'Patron debarred', "Got correct debarred screen message" );
448
449
    my $overdue_patron = $builder->build_object(
450
        {
451
            class => 'Koha::Patrons',
452
            value => {
453
                branchcode => $library->branchcode,
454
            }
455
        }
456
    );
457
458
    my $odue = $builder->build({ source => 'Issue', value => {
459
            borrowernumber => $overdue_patron->borrowernumber,
460
            date_due => '2017-01-01',
461
        }
462
    });
463
    t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' );
464
    my $overdue_sip_patron  = C4::SIP::ILS::Patron->new( $overdue_patron->cardnumber );
465
    $circ = $ils->checkout($overdue_patron->cardnumber, $item->barcode);
466
    is( $circ->{screen_msg}, 'Patron blocked', "Got correct blocked screen message" );
467
468
};
469
380
subtest do_checkout_with_holds => sub {
470
subtest do_checkout_with_holds => sub {
381
    plan tests => 7;
471
    plan tests => 7;
382
472
383
- 

Return to bug 25815