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

(-)a/C4/SIP/ILS/Transaction/Checkout.pm (-4 / +5 lines)
Lines 50-56 sub do_checkout { Link Here
50
    my $overridden_duedate;    # usually passed as undef to AddIssue
50
    my $overridden_duedate;    # usually passed as undef to AddIssue
51
    my $prevcheckout_block_checkout         = $account->{prevcheckout_block_checkout};
51
    my $prevcheckout_block_checkout         = $account->{prevcheckout_block_checkout};
52
    my $allow_additional_materials_checkout = $account->{allow_additional_materials_checkout};
52
    my $allow_additional_materials_checkout = $account->{allow_additional_materials_checkout};
53
    my ( $issuingimpossible, $needsconfirmation, $messages ) = _can_we_issue( $patron, $barcode, 0 );
53
    my @syspref_vals                        = split /,/, C4::Context->preference("AllowItemsOnHoldCheckoutSIP");
54
    my %ignore_reserves                     = map { $_ => 1 } @syspref_vals;
55
56
    my ( $issuingimpossible, $needsconfirmation, $messages ) = _can_we_issue( $patron, $barcode, \%ignore_reserves );
54
57
55
    if ($no_block_due_date) {
58
    if ($no_block_due_date) {
56
        my $year   = substr( $no_block_due_date, 0,  4 );
59
        my $year   = substr( $no_block_due_date, 0,  4 );
Lines 77-87 sub do_checkout { Link Here
77
        foreach my $confirmation ( keys %{$needsconfirmation} ) {
80
        foreach my $confirmation ( keys %{$needsconfirmation} ) {
78
            if ( $confirmation eq 'RENEW_ISSUE' ) {
81
            if ( $confirmation eq 'RENEW_ISSUE' ) {
79
                $self->screen_msg("Item already checked out to you: renewing item.");
82
                $self->screen_msg("Item already checked out to you: renewing item.");
80
            } elsif ( $confirmation eq 'RESERVED' and !C4::Context->preference("AllowItemsOnHoldCheckoutSIP") ) {
83
            } elsif ( $confirmation eq 'RESERVED' ) {
81
                $self->screen_msg("Item is reserved for another patron upon return.");
84
                $self->screen_msg("Item is reserved for another patron upon return.");
82
                $noerror = 0;
85
                $noerror = 0;
83
            } elsif ( $confirmation eq 'RESERVED' and C4::Context->preference("AllowItemsOnHoldCheckoutSIP") ) {
84
                next;
85
            } elsif ( $confirmation eq 'RESERVE_WAITING'
86
            } elsif ( $confirmation eq 'RESERVE_WAITING'
86
                or $confirmation eq 'TRANSFERRED'
87
                or $confirmation eq 'TRANSFERRED'
87
                or $confirmation eq 'PROCESSING' )
88
                or $confirmation eq 'PROCESSING' )
(-)a/opac/sco/sco-main.pl (-4 / +6 lines)
Lines 190-204 if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { Link Here
190
    my @failed_checkouts;
190
    my @failed_checkouts;
191
    my @confirm_checkouts;
191
    my @confirm_checkouts;
192
    foreach my $barcode (@$barcodes) {
192
    foreach my $barcode (@$barcodes) {
193
        my $item        = Koha::Items->find( { barcode => $barcode } );
193
        my $item            = Koha::Items->find( { barcode => $barcode } );
194
        my $impossible  = {};
194
        my $impossible      = {};
195
        my $needconfirm = {};
195
        my $needconfirm     = {};
196
        my @syspref_vals    = split /,/, C4::Context->preference("AllowItemsOnHoldCheckoutSCO");
197
        my %ignore_reserves = map { $_ => 1 } @syspref_vals;
196
        ( $impossible, $needconfirm ) = CanBookBeIssued(
198
        ( $impossible, $needconfirm ) = CanBookBeIssued(
197
            $patron,
199
            $patron,
198
            $barcode,
200
            $barcode,
199
            undef,
201
            undef,
200
            0,
202
            0,
201
            C4::Context->preference("AllowItemsOnHoldCheckoutSCO")
203
            \%ignore_reserves,
202
        );
204
        );
203
        my $issue_error;
205
        my $issue_error;
204
        if ( $confirm_required = scalar keys %$needconfirm ) {
206
        if ( $confirm_required = scalar keys %$needconfirm ) {
(-)a/t/db_dependent/SIP/Transaction.t (-12 / +45 lines)
Lines 22-28 use C4::SIP::ILS::Transaction::Hold; Link Here
22
use C4::SIP::ILS::Transaction::Checkout;
22
use C4::SIP::ILS::Transaction::Checkout;
23
use C4::SIP::ILS::Transaction::Checkin;
23
use C4::SIP::ILS::Transaction::Checkin;
24
24
25
use C4::Reserves qw( AddReserve ModReserve ModReserveAffect );
25
use C4::Reserves    qw( AddReserve ModReserve ModReserveAffect );
26
use C4::Circulation qw( AddReturn );
26
use Koha::CirculationRules;
27
use Koha::CirculationRules;
27
use Koha::Item::Transfer;
28
use Koha::Item::Transfer;
28
use Koha::DateUtils qw( dt_from_string output_pref );
29
use Koha::DateUtils qw( dt_from_string output_pref );
Lines 1138-1144 subtest do_checkout_with_noblock => sub { Link Here
1138
};
1139
};
1139
1140
1140
subtest do_checkout_with_holds => sub {
1141
subtest do_checkout_with_holds => sub {
1141
    plan tests => 7;
1142
    plan tests => 10;
1142
1143
1143
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1144
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1144
    my $patron  = $builder->build_object(
1145
    my $patron  = $builder->build_object(
Lines 1186-1215 subtest do_checkout_with_holds => sub { Link Here
1186
        $sip_item, "Item assigned to transaction"
1187
        $sip_item, "Item assigned to transaction"
1187
    );
1188
    );
1188
1189
1189
    # Test attached holds
1190
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '' );
1191
1192
    # Test attached holds with no hold statuses allowed to check out
1190
    ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve );    # Mark waiting (W)
1193
    ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve );    # Mark waiting (W)
1191
    my $hold = Koha::Holds->find($reserve);
1194
    my $hold = Koha::Holds->find($reserve);
1192
    $co_transaction->do_checkout();
1195
    $co_transaction->do_checkout();
1193
    is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)' );
1196
    is(
1197
        $patron->checkouts->count, 0,
1198
        'Checkout was not done due to attached hold (W) and AllowItemsOnHoldCheckoutSIP'
1199
    );
1194
1200
1195
    $hold->set_transfer;
1201
    $hold->set_transfer;
1196
    $co_transaction->do_checkout();
1202
    $co_transaction->do_checkout();
1197
    is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)' );
1203
    is(
1204
        $patron->checkouts->count, 0,
1205
        'Checkout was not done due to attached hold (T) and AllowItemsOnHoldCheckoutSIP'
1206
    );
1198
1207
1199
    $hold->set_processing;
1208
    $hold->set_processing;
1200
    $co_transaction->do_checkout();
1209
    $co_transaction->do_checkout();
1201
    is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)' );
1210
    is(
1211
        $patron->checkouts->count, 0,
1212
        'Checkout was not done due to attached hold (P) and AllowItemsOnHoldCheckoutSIP'
1213
    );
1202
1214
1203
    # Test non-attached holds
1215
    # Test non-attached holds
1204
    $hold->set_waiting();
1205
    $hold->revert_found();
1216
    $hold->revert_found();
1206
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '0' );
1217
1207
    $co_transaction->do_checkout();
1218
    $co_transaction->do_checkout();
1208
    is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP' );
1219
    is(
1220
        $patron->checkouts->count, 0,
1221
        'Checkout with non-attached hold refused due to hold and AllowItemsOnHoldCheckoutSIP'
1222
    );
1223
1224
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', 'pending,processing,transferred,waiting' );
1209
1225
1210
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '1' );
1211
    $co_transaction->do_checkout();
1226
    $co_transaction->do_checkout();
1212
    is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP' );
1227
    is(
1228
        $patron->checkouts->count, 1,
1229
        'Checkout with non-attached hold allowed due to hold and AllowItemsOnHoldCheckoutSIP'
1230
    );
1231
1232
    # Test attached holds with all hold statuses allowed to check out
1233
    AddReturn( $item->barcode, $library->branchcode );
1234
    ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve );    # Mark waiting (W)
1235
    $co_transaction->do_checkout();
1236
    is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (W) due to AllowItemsOnHoldCheckoutSIP' );
1237
1238
    AddReturn( $item->barcode, $library->branchcode );
1239
    $hold->set_transfer;
1240
    $co_transaction->do_checkout();
1241
    is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (T) due to AllowItemsOnHoldCheckoutSIP' );
1242
1243
    AddReturn( $item->barcode, $library->branchcode );
1244
    $hold->set_processing;
1245
    $co_transaction->do_checkout();
1246
    is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (P) due to AllowItemsOnHoldCheckoutSIP' );
1213
};
1247
};
1214
1248
1215
subtest checkin_lost => sub {
1249
subtest checkin_lost => sub {
1216
- 

Return to bug 21572