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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 474-480 sub TooMany { Link Here
474
        my $max_checkouts_allowed = $issuing_rule->maxissueqty;
474
        my $max_checkouts_allowed = $issuing_rule->maxissueqty;
475
        my $max_onsite_checkouts_allowed = $issuing_rule->maxonsiteissueqty;
475
        my $max_onsite_checkouts_allowed = $issuing_rule->maxonsiteissueqty;
476
476
477
        if ( $onsite_checkout ) {
477
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
478
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
478
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
479
                return {
479
                return {
480
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
480
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
Lines 528-534 sub TooMany { Link Here
528
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{maxissueqty};
528
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{maxissueqty};
529
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{maxonsiteissueqty};
529
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{maxonsiteissueqty};
530
530
531
        if ( $onsite_checkout ) {
531
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
532
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
532
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
533
                return {
533
                return {
534
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
534
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
(-)a/t/db_dependent/Circulation/TooMany.t (-2 / +54 lines)
Lines 15-21 Link Here
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
use Test::More tests => 6;
18
use Test::More tests => 7;
19
use C4::Context;
19
use C4::Context;
20
20
21
use C4::Biblio;
21
use C4::Biblio;
Lines 159-164 subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { Link Here
159
    teardown();
159
    teardown();
160
};
160
};
161
161
162
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
163
    plan tests => 4;
164
    my $issuingrule = $builder->build({
165
        source => 'Issuingrule',
166
        value => {
167
            branchcode         => $branch->{branchcode},
168
            categorycode       => $category->{categorycode},
169
            itemtype           => '*',
170
            maxissueqty        => 1,
171
            maxonsiteissueqty  => undef,
172
        },
173
    });
174
    my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string() );
175
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
176
    is_deeply(
177
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
178
        {
179
            reason => 'TOO_MANY_CHECKOUTS',
180
            count => 1,
181
            max_allowed => 1,
182
        },
183
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
184
    );
185
    is(
186
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
187
        undef,
188
        'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
189
    );
190
191
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
192
    is_deeply(
193
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
194
        {
195
            reason => 'TOO_MANY_CHECKOUTS',
196
            count => 1,
197
            max_allowed => 1,
198
        },
199
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
200
    );
201
    is_deeply(
202
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
203
        {
204
            reason => 'TOO_MANY_CHECKOUTS',
205
            count => 1,
206
            max_allowed => 1,
207
        },
208
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
209
    );
210
211
    teardown();
212
};
213
214
162
subtest '1 Issuingrule exist 1 1: issue is allowed' => sub {
215
subtest '1 Issuingrule exist 1 1: issue is allowed' => sub {
163
    plan tests => 4;
216
    plan tests => 4;
164
    my $issuingrule = $builder->build({
217
    my $issuingrule = $builder->build({
165
- 

Return to bug 18357