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 (-11 / +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 RevertWaitingStatus );
25
use C4::Reserves    qw( AddReserve ModReserve ModReserveAffect RevertWaitingStatus );
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 1055-1061 subtest do_checkout_with_noblock => sub { Link Here
1055
};
1056
};
1056
1057
1057
subtest do_checkout_with_holds => sub {
1058
subtest do_checkout_with_holds => sub {
1058
    plan tests => 7;
1059
    plan tests => 10;
1059
1060
1060
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1061
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1061
    my $patron  = $builder->build_object(
1062
    my $patron  = $builder->build_object(
Lines 1103-1131 subtest do_checkout_with_holds => sub { Link Here
1103
        $sip_item, "Item assigned to transaction"
1104
        $sip_item, "Item assigned to transaction"
1104
    );
1105
    );
1105
1106
1106
    # Test attached holds
1107
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '' );
1108
1109
    # Test attached holds with no hold statuses allowed to check out
1107
    ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve );    # Mark waiting (W)
1110
    ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve );    # Mark waiting (W)
1108
    my $hold = Koha::Holds->find($reserve);
1111
    my $hold = Koha::Holds->find($reserve);
1109
    $co_transaction->do_checkout();
1112
    $co_transaction->do_checkout();
1110
    is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)' );
1113
    is(
1114
        $patron->checkouts->count, 0,
1115
        'Checkout was not done due to attached hold (W) and AllowItemsOnHoldCheckoutSIP'
1116
    );
1111
1117
1112
    $hold->set_transfer;
1118
    $hold->set_transfer;
1113
    $co_transaction->do_checkout();
1119
    $co_transaction->do_checkout();
1114
    is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)' );
1120
    is(
1121
        $patron->checkouts->count, 0,
1122
        'Checkout was not done due to attached hold (T) and AllowItemsOnHoldCheckoutSIP'
1123
    );
1115
1124
1116
    $hold->set_processing;
1125
    $hold->set_processing;
1117
    $co_transaction->do_checkout();
1126
    $co_transaction->do_checkout();
1118
    is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)' );
1127
    is(
1128
        $patron->checkouts->count, 0,
1129
        'Checkout was not done due to attached hold (P) and AllowItemsOnHoldCheckoutSIP'
1130
    );
1119
1131
1120
    # Test non-attached holds
1132
    # Test non-attached holds
1121
    C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } );
1133
    C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } );
1122
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '0' );
1134
1135
    $co_transaction->do_checkout();
1136
    is(
1137
        $patron->checkouts->count, 0,
1138
        'Checkout with non-attached hold refused due to hold and AllowItemsOnHoldCheckoutSIP'
1139
    );
1140
1141
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', 'pending,processing,transferred,waiting' );
1142
1123
    $co_transaction->do_checkout();
1143
    $co_transaction->do_checkout();
1124
    is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP' );
1144
    is(
1145
        $patron->checkouts->count, 1,
1146
        'Checkout with non-attached hold allowed due to hold and AllowItemsOnHoldCheckoutSIP'
1147
    );
1125
1148
1126
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '1' );
1149
    # Test attached holds with all hold statuses allowed to check out
1150
    AddReturn( $item->barcode, $library->branchcode );
1151
    $hold->set_waiting;
1152
    $co_transaction->do_checkout();
1153
    is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (W) due to AllowItemsOnHoldCheckoutSIP' );
1154
1155
    AddReturn( $item->barcode, $library->branchcode );
1156
    $hold->set_transfer;
1157
    $co_transaction->do_checkout();
1158
    is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (T) due to AllowItemsOnHoldCheckoutSIP' );
1159
1160
    AddReturn( $item->barcode, $library->branchcode );
1161
    $hold->set_processing;
1127
    $co_transaction->do_checkout();
1162
    $co_transaction->do_checkout();
1128
    is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP' );
1163
    is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (P) due to AllowItemsOnHoldCheckoutSIP' );
1129
};
1164
};
1130
1165
1131
subtest checkin_lost => sub {
1166
subtest checkin_lost => sub {
1132
- 

Return to bug 21572