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

(-)a/C4/Circulation.pm (-2 / +5 lines)
Lines 1036-1043 sub CanBookBeIssued { Link Here
1036
    #
1036
    #
1037
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
1037
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
1038
    #
1038
    #
1039
    $patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed
1039
    $patron = Koha::Patrons->find( $patron->borrowernumber )
1040
    if ( $patron->wants_check_for_previous_checkout && $patron->do_check_for_previous_checkout($item_unblessed) ) {
1040
        ;    # FIXME Refetch just in case, to avoid regressions. But must not be needed
1041
    if (   $patron->wants_check_for_previous_checkout($item_object)
1042
        && $patron->do_check_for_previous_checkout($item_unblessed) )
1043
    {
1041
        $needsconfirmation{PREVISSUE} = 1;
1044
        $needsconfirmation{PREVISSUE} = 1;
1042
    }
1045
    }
1043
1046
(-)a/Koha/Patron.pm (-8 / +13 lines)
Lines 44-49 use Koha::Encryption; Link Here
44
use Koha::Exceptions;
44
use Koha::Exceptions;
45
use Koha::Exceptions::Password;
45
use Koha::Exceptions::Password;
46
use Koha::Holds;
46
use Koha::Holds;
47
use Koha::ItemTypes;
47
use Koha::Old::Checkouts;
48
use Koha::Old::Checkouts;
48
use Koha::OverdueRules;
49
use Koha::OverdueRules;
49
use Koha::Patron::Attributes;
50
use Koha::Patron::Attributes;
Lines 753-780 Return 1 if Koha needs to perform PrevIssue checking, else 0. Link Here
753
=cut
754
=cut
754
755
755
sub wants_check_for_previous_checkout {
756
sub wants_check_for_previous_checkout {
756
    my ( $self ) = @_;
757
    my ( $self, $item ) = @_;
757
    my $syspref = C4::Context->preference("checkPrevCheckout");
758
    my $syspref = C4::Context->preference("checkPrevCheckout");
758
759
759
    # Simple cases
760
    # Simple cases
760
    ## Hard syspref trumps all
761
    ## Hard syspref trumps all
761
    return 1 if ($syspref eq 'hardyes');
762
    return 1 if ($syspref eq 'hardyes');
762
    return 0 if ($syspref eq 'hardno');
763
    return 0 if ($syspref eq 'hardno');
763
    ## Now, patron pref trumps all
764
765
    # Now, item pref trumps all
766
    if ($item) {
767
        my $itype = Koha::ItemTypes->find( $item->effective_itemtype );
768
        return 1 if ($itype->checkprevcheckout eq 'yes');
769
        return 0 if ($itype->checkprevcheckout eq 'no');
770
    }
771
772
    # Now, item type inherits -> determine patron preference
764
    return 1 if ($self->checkprevcheckout eq 'yes');
773
    return 1 if ($self->checkprevcheckout eq 'yes');
765
    return 0 if ($self->checkprevcheckout eq 'no');
774
    return 0 if ($self->checkprevcheckout eq 'no');
766
775
767
    # More complex: patron inherits -> determine category preference
776
    # More complex: item type inherit and patron inherits -> determine category preference
768
    my $checkPrevCheckoutByCat = $self->category->checkprevcheckout;
777
    my $checkPrevCheckoutByCat = $self->category->checkprevcheckout;
769
    return 1 if ($checkPrevCheckoutByCat eq 'yes');
778
    return 1 if ($checkPrevCheckoutByCat eq 'yes');
770
    return 0 if ($checkPrevCheckoutByCat eq 'no');
779
    return 0 if ($checkPrevCheckoutByCat eq 'no');
771
780
772
    # Finally: category preference is inherit, default to 0
781
    # Finally: category preference is inherit, default to 0
773
    if ($syspref eq 'softyes') {
782
    return $syspref eq 'softyes' ? 1 : 0;
774
        return 1;
775
    } else {
776
        return 0;
777
    }
778
}
783
}
779
784
780
=head3 do_check_for_previous_checkout
785
=head3 do_check_for_previous_checkout
(-)a/admin/itemtypes.pl (+3 lines)
Lines 98-103 if ( $op eq 'add_form' ) { Link Here
98
    my $rentalcharge_daily_calendar  = $input->param('rentalcharge_daily_calendar') // 0;
98
    my $rentalcharge_daily_calendar  = $input->param('rentalcharge_daily_calendar') // 0;
99
    my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
99
    my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
100
    my $automatic_checkin = $input->param('automatic_checkin') // 0;
100
    my $automatic_checkin = $input->param('automatic_checkin') // 0;
101
    my $checkprevcheckout            = $input->param('checkprevcheckout');
101
102
102
    if ( $itemtype and $is_a_modif ) {    # it's a modification
103
    if ( $itemtype and $is_a_modif ) {    # it's a modification
103
        $itemtype->description($description);
104
        $itemtype->description($description);
Lines 118-123 if ( $op eq 'add_form' ) { Link Here
118
        $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
119
        $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
119
        $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
120
        $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
120
        $itemtype->automatic_checkin($automatic_checkin);
121
        $itemtype->automatic_checkin($automatic_checkin);
122
        $itemtype->checkprevcheckout($checkprevcheckout);
121
123
122
        eval {
124
        eval {
123
          $itemtype->store;
125
          $itemtype->store;
Lines 151-156 if ( $op eq 'add_form' ) { Link Here
151
                rentalcharge_daily_calendar  => $rentalcharge_daily_calendar,
153
                rentalcharge_daily_calendar  => $rentalcharge_daily_calendar,
152
                rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
154
                rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
153
                automatic_checkin   => $automatic_checkin,
155
                automatic_checkin   => $automatic_checkin,
156
                checkprevcheckout            => $checkprevcheckout,
154
            }
157
            }
155
        );
158
        );
156
        eval {
159
        eval {
(-)a/installer/data/mysql/atomicupdate/bug_20644-add_checkprevcheckout_to_items.pl (+20 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "20644",
5
    description => "Add the column checkprevcheckout to itemtypes table",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(
11
            q{
12
            ALTER TABLE itemtypes
13
            ADD IF NOT EXISTS checkprevcheckout varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for a patron if a item of this type has previously been checked out to the same patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.'
14
            AFTER automatic_checkin;
15
        }
16
        );
17
18
        say $out "Added column 'itemtypes.checkprevcheckout'";
19
    },
20
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 4123-4128 CREATE TABLE `itemtypes` ( Link Here
4123
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4123
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4124
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4124
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4125
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4125
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4126
  `checkprevcheckout` varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for a patron if a item of this type has previously been checked out to the same patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.',
4126
  PRIMARY KEY (`itemtype`),
4127
  PRIMARY KEY (`itemtype`),
4127
  UNIQUE KEY `itemtype` (`itemtype`),
4128
  UNIQUE KEY `itemtype` (`itemtype`),
4128
  KEY `itemtypes_ibfk_1` (`parent_type`),
4129
  KEY `itemtypes_ibfk_1` (`parent_type`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+20 lines)
Lines 344-349 Link Here
344
                    <div class="hint">Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </div>
344
                    <div class="hint">Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </div>
345
                    <div class="hint"><strong>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</strong> will show the link just below the title</div>
345
                    <div class="hint"><strong>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</strong> will show the link just below the title</div>
346
                </li>
346
                </li>
347
                [% IF Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' %]
348
                    <li>
349
                        <label for="checkprevcheckout">Check for previous checkouts: </label>
350
                        <select name="checkprevcheckout" id="checkprevcheckout">
351
                            [% IF itemtype.checkprevcheckout == 'yes' %]
352
                            <option value="yes" selected="selected">Yes and try to override system preferences</option>
353
                            <option value="no">No and try to override system preferences</option>
354
                            <option value="inherit">Inherit from system preferences</option>
355
                            [% ELSIF itemtype.checkprevcheckout == 'no' %]
356
                            <option value="yes">Yes and try to override system preferences</option>
357
                            <option value="no" selected="selected">No and try to override system preferences</option>
358
                            <option value="inherit">Inherit from system preferences</option>
359
                            [% ELSE %]
360
                            <option value="yes">Yes and try to override system preferences</option>
361
                            <option value="no">No and try to override system preferences</option>
362
                            <option value="inherit" selected="selected">Inherit from system preferences</option>
363
                            [% END %]
364
                        </select>
365
                    </li>
366
                [% END %]
347
            </ol>
367
            </ol>
348
        </fieldset>
368
        </fieldset>
349
369
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-2 / +2 lines)
Lines 5-12 Patrons: Link Here
5
           default: no
5
           default: no
6
           choices:
6
           choices:
7
               hardyes: "Do"
7
               hardyes: "Do"
8
               softyes: "Unless overridden by patron category, do"
8
               softyes: "Unless overridden by patron category or by item type, do"
9
               softno: "Unless overridden by patron category, do not"
9
               softno: "Unless overridden by patron category or by item type, do not"
10
               hardno: "Do not"
10
               hardno: "Do not"
11
         - " check borrower checkout history to see if the current item has been checked out before."
11
         - " check borrower checkout history to see if the current item has been checked out before."
12
     -
12
     -
(-)a/t/db_dependent/Koha/ItemTypes.t (-3 / +33 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 15;
22
use Test::More tests => 18;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 41-47 my $schema = $database->schema(); Link Here
41
$schema->txn_begin;
41
$schema->txn_begin;
42
42
43
my $builder     = t::lib::TestBuilder->new;
43
my $builder     = t::lib::TestBuilder->new;
44
my $initial_count = Koha::ItemTypes->search->count;
44
my $initial_count1 = Koha::ItemTypes->search->count;
45
45
46
my $parent1 = $builder->build_object({ class => 'Koha::ItemTypes', value => { description => 'description' } });
46
my $parent1 = $builder->build_object({ class => 'Koha::ItemTypes', value => { description => 'description' } });
47
my $child1  = $builder->build_object({
47
my $child1  = $builder->build_object({
Lines 103-109 is_deeply( $type->unblessed, $child2->unblessed, "We got back the same object" ) Link Here
103
t::lib::Mocks::mock_preference('language', 'en');
103
t::lib::Mocks::mock_preference('language', 'en');
104
t::lib::Mocks::mock_preference('OPACLanguages', 'en');
104
t::lib::Mocks::mock_preference('OPACLanguages', 'en');
105
my $itemtypes = Koha::ItemTypes->search_with_localization;
105
my $itemtypes = Koha::ItemTypes->search_with_localization;
106
is( $itemtypes->count, $initial_count + 4, 'We added 4 item types' );
106
is( $itemtypes->count, $initial_count1 + 4, 'We added 4 item types' );
107
my $first_itemtype = $itemtypes->next;
107
my $first_itemtype = $itemtypes->next;
108
is(
108
is(
109
    $first_itemtype->translated_description,
109
    $first_itemtype->translated_description,
Lines 150-153 subtest 'image_location' => sub { Link Here
150
    );
150
    );
151
};
151
};
152
152
153
# test for checkprevcheckout
154
my $initial_count2 = Koha::ItemTypes->search->count;
155
156
my @itypes = (
157
    Koha::ItemType->new(
158
        {
159
            itemtype => 'ITYPE1',
160
        }
161
    )->store,
162
    Koha::ItemType->new(
163
        {
164
            itemtype          => 'ITYPE2',
165
            checkprevcheckout => undef,
166
        }
167
    )->store,
168
);
169
170
for my $itype (@itypes) {
171
    my $retrived_itype = Koha::ItemTypes->find( $itype->itemtype );
172
    is(
173
        $retrived_itype->checkprevcheckout, 'inherit',
174
        'Koha::ItemType->store should default checkprevcheckout to inherit'
175
    );
176
}
177
178
is(
179
    Koha::ItemTypes->search->count, $initial_count2 + 2,
180
    'Two item types with \'checkprevcheckout\' set to \'undef\' have been added'
181
);
182
153
$schema->txn_rollback;
183
$schema->txn_rollback;
(-)a/t/db_dependent/Patron/Borrower_PrevCheckout.t (-2 / +490 lines)
Lines 7-13 use Koha::Database; Link Here
7
use Koha::DateUtils qw( dt_from_string );
7
use Koha::DateUtils qw( dt_from_string );
8
use Koha::Patrons;
8
use Koha::Patrons;
9
9
10
use Test::More tests => 61;
10
use Test::More tests => 169;
11
11
12
use_ok('Koha::Patron');
12
use_ok('Koha::Patron');
13
13
Lines 42-47 my $inheritCatCode = $builder->build({ Link Here
42
    },
42
    },
43
});
43
});
44
44
45
my $yesItypeCode = $builder->build(
46
    {
47
        source => 'Itemtype',
48
        value  => {
49
            itemtype          => 'YESIT',
50
            checkprevcheckout => 'yes',
51
        },
52
    }
53
);
54
55
my $noItypeCode = $builder->build(
56
    {
57
        source => 'Itemtype',
58
        value  => {
59
            itemtype          => 'NOIT',
60
            checkprevcheckout => 'no',
61
        },
62
    }
63
);
64
65
my $inheritItypeCode = $builder->build(
66
    {
67
        source => 'Itemtype',
68
        value  => {
69
            itemtype          => 'INHERITIT',
70
            checkprevcheckout => 'inherit',
71
        },
72
    }
73
);
74
45
# Create context for some tests late on in the file.
75
# Create context for some tests late on in the file.
46
my $library = $builder->build({ source => 'Branch' });
76
my $library = $builder->build({ source => 'Branch' });
47
my $staff = $builder->build({source => 'Borrower'});
77
my $staff = $builder->build({source => 'Borrower'});
Lines 50-55 t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); Link Here
50
80
51
# wants_check_for_previous_checkout
81
# wants_check_for_previous_checkout
52
82
83
# We want to test the subroutine without passing the $item parameter
53
# We expect the following result matrix:
84
# We expect the following result matrix:
54
#
85
#
55
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we
86
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we
Lines 205-210 map { Link Here
205
    } @{$_->{categories}};
236
    } @{$_->{categories}};
206
} @{$mappings};
237
} @{$mappings};
207
238
239
240
# wants_check_for_previous_checkout
241
242
# We want to test the subroutine by passing the $item parameter
243
# We expect the following result matrix:
244
#
245
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we
246
# should check whether the item was previously issued)
247
#
248
# | System Preference | hardyes                                                                                                   |
249
# |-------------------+-----------------------------------------------------------------------------------------------------------|
250
# | Item Type Setting | yes                               | no                                | inherit                           |
251
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
252
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
253
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
254
# | Patron Setting    | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i |
255
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
256
# | Expected Result   | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
257
#
258
#
259
# | System Preference | softyes                                                                                                   |
260
# |-------------------+-----------------------------------------------------------------------------------------------------------|
261
# | Item Type Setting | yes                               | no                                | inherit                           |
262
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
263
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
264
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
265
# | Patron Setting    | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i |
266
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
267
# | Expected Result   | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 |
268
#
269
#
270
# | System Preference | softno                                                                                                    |
271
# |-------------------+-----------------------------------------------------------------------------------------------------------|
272
# | Item Type Setting | yes                               | no                                | inherit                           |
273
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
274
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
275
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
276
# | Patron Setting    | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i |
277
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
278
# | Expected Result   | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
279
#
280
#
281
# | System Preference | hardno                                                                                                    |
282
# |-------------------+-----------------------------------------------------------------------------------------------------------|
283
# | Item Type Setting | yes                               | no                                | inherit                           |
284
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
285
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
286
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
287
# | Patron Setting    | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i |
288
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
289
# | Expected Result   | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
290
291
my $itemMappings = [
292
    {
293
        syspref => 'hardyes',
294
        itypes  => [
295
            {
296
                setting    => 'yes',
297
                categories => [
298
                    {
299
                        setting => 'yes',
300
                        patrons => [
301
                            { setting => 'yes',     result => 1 },
302
                            { setting => 'no',      result => 1 },
303
                            { setting => 'inherit', result => 1 },
304
                        ],
305
                    },
306
                    {
307
                        setting => 'no',
308
                        patrons => [
309
                            { setting => 'yes',     result => 1 },
310
                            { setting => 'no',      result => 1 },
311
                            { setting => 'inherit', result => 1 },
312
                        ],
313
                    },
314
                    {
315
                        setting => 'inherit',
316
                        patrons => [
317
                            { setting => 'yes',     result => 1 },
318
                            { setting => 'no',      result => 1 },
319
                            { setting => 'inherit', result => 1 },
320
                        ],
321
                    },
322
                ],
323
            },
324
            {
325
                setting    => 'no',
326
                categories => [
327
                    {
328
                        setting => 'yes',
329
                        patrons => [
330
                            { setting => 'yes',     result => 1 },
331
                            { setting => 'no',      result => 1 },
332
                            { setting => 'inherit', result => 1 },
333
                        ],
334
                    },
335
                    {
336
                        setting => 'no',
337
                        patrons => [
338
                            { setting => 'yes',     result => 1 },
339
                            { setting => 'no',      result => 1 },
340
                            { setting => 'inherit', result => 1 },
341
                        ],
342
                    },
343
                    {
344
                        setting => 'inherit',
345
                        patrons => [
346
                            { setting => 'yes',     result => 1 },
347
                            { setting => 'no',      result => 1 },
348
                            { setting => 'inherit', result => 1 },
349
                        ],
350
                    },
351
                ],
352
            },
353
            {
354
                setting    => 'inherit',
355
                categories => [
356
                    {
357
                        setting => 'yes',
358
                        patrons => [
359
                            { setting => 'yes',     result => 1 },
360
                            { setting => 'no',      result => 1 },
361
                            { setting => 'inherit', result => 1 },
362
                        ],
363
                    },
364
                    {
365
                        setting => 'no',
366
                        patrons => [
367
                            { setting => 'yes',     result => 1 },
368
                            { setting => 'no',      result => 1 },
369
                            { setting => 'inherit', result => 1 },
370
                        ],
371
                    },
372
                    {
373
                        setting => 'inherit',
374
                        patrons => [
375
                            { setting => 'yes',     result => 1 },
376
                            { setting => 'no',      result => 1 },
377
                            { setting => 'inherit', result => 1 },
378
                        ],
379
                    },
380
                ],
381
            },
382
        ],
383
    },
384
    {
385
        syspref => 'softyes',
386
        itypes  => [
387
            {
388
                setting    => 'yes',
389
                categories => [
390
                    {
391
                        setting => 'yes',
392
                        patrons => [
393
                            { setting => 'yes',     result => 1 },
394
                            { setting => 'no',      result => 1 },
395
                            { setting => 'inherit', result => 1 },
396
                        ],
397
                    },
398
                    {
399
                        setting => 'no',
400
                        patrons => [
401
                            { setting => 'yes',     result => 1 },
402
                            { setting => 'no',      result => 1 },
403
                            { setting => 'inherit', result => 1 },
404
                        ],
405
                    },
406
                    {
407
                        setting => 'inherit',
408
                        patrons => [
409
                            { setting => 'yes',     result => 1 },
410
                            { setting => 'no',      result => 1 },
411
                            { setting => 'inherit', result => 1 },
412
                        ],
413
                    },
414
                ],
415
            },
416
            {
417
                setting    => 'no',
418
                categories => [
419
                    {
420
                        setting => 'yes',
421
                        patrons => [
422
                            { setting => 'yes',     result => 0 },
423
                            { setting => 'no',      result => 0 },
424
                            { setting => 'inherit', result => 0 },
425
                        ],
426
                    },
427
                    {
428
                        setting => 'no',
429
                        patrons => [
430
                            { setting => 'yes',     result => 0 },
431
                            { setting => 'no',      result => 0 },
432
                            { setting => 'inherit', result => 0 },
433
                        ],
434
                    },
435
                    {
436
                        setting => 'inherit',
437
                        patrons => [
438
                            { setting => 'yes',     result => 0 },
439
                            { setting => 'no',      result => 0 },
440
                            { setting => 'inherit', result => 0 },
441
                        ],
442
                    },
443
                ],
444
            },
445
            {
446
                setting    => 'inherit',
447
                categories => [
448
                    {
449
                        setting => 'yes',
450
                        patrons => [
451
                            { setting => 'yes',     result => 1 },
452
                            { setting => 'no',      result => 0 },
453
                            { setting => 'inherit', result => 1 },
454
                        ],
455
                    },
456
                    {
457
                        setting => 'no',
458
                        patrons => [
459
                            { setting => 'yes',     result => 1 },
460
                            { setting => 'no',      result => 0 },
461
                            { setting => 'inherit', result => 0 },
462
                        ],
463
                    },
464
                    {
465
                        setting => 'inherit',
466
                        patrons => [
467
                            { setting => 'yes',     result => 1 },
468
                            { setting => 'no',      result => 0 },
469
                            { setting => 'inherit', result => 1 },
470
                        ],
471
                    },
472
                ],
473
            },
474
        ],
475
    },
476
    {
477
        syspref => 'softno',
478
        itypes  => [
479
            {
480
                setting    => 'yes',
481
                categories => [
482
                    {
483
                        setting => 'yes',
484
                        patrons => [
485
                            { setting => 'yes',     result => 1 },
486
                            { setting => 'no',      result => 1 },
487
                            { setting => 'inherit', result => 1 },
488
                        ],
489
                    },
490
                    {
491
                        setting => 'no',
492
                        patrons => [
493
                            { setting => 'yes',     result => 1 },
494
                            { setting => 'no',      result => 1 },
495
                            { setting => 'inherit', result => 1 },
496
                        ],
497
                    },
498
                    {
499
                        setting => 'inherit',
500
                        patrons => [
501
                            { setting => 'yes',     result => 1 },
502
                            { setting => 'no',      result => 1 },
503
                            { setting => 'inherit', result => 1 },
504
                        ],
505
                    },
506
                ],
507
            },
508
            {
509
                setting    => 'no',
510
                categories => [
511
                    {
512
                        setting => 'yes',
513
                        patrons => [
514
                            { setting => 'yes',     result => 0 },
515
                            { setting => 'no',      result => 0 },
516
                            { setting => 'inherit', result => 0 },
517
                        ],
518
                    },
519
                    {
520
                        setting => 'no',
521
                        patrons => [
522
                            { setting => 'yes',     result => 0 },
523
                            { setting => 'no',      result => 0 },
524
                            { setting => 'inherit', result => 0 },
525
                        ],
526
                    },
527
                    {
528
                        setting => 'inherit',
529
                        patrons => [
530
                            { setting => 'yes',     result => 0 },
531
                            { setting => 'no',      result => 0 },
532
                            { setting => 'inherit', result => 0 },
533
                        ],
534
                    },
535
                ],
536
            },
537
            {
538
                setting    => 'inherit',
539
                categories => [
540
                    {
541
                        setting => 'yes',
542
                        patrons => [
543
                            { setting => 'yes',     result => 1 },
544
                            { setting => 'no',      result => 0 },
545
                            { setting => 'inherit', result => 1 },
546
                        ],
547
                    },
548
                    {
549
                        setting => 'no',
550
                        patrons => [
551
                            { setting => 'yes',     result => 1 },
552
                            { setting => 'no',      result => 0 },
553
                            { setting => 'inherit', result => 0 },
554
                        ],
555
                    },
556
                    {
557
                        setting => 'inherit',
558
                        patrons => [
559
                            { setting => 'yes',     result => 1 },
560
                            { setting => 'no',      result => 0 },
561
                            { setting => 'inherit', result => 0 },
562
                        ],
563
                    },
564
                ],
565
            },
566
        ],
567
    },
568
    {
569
        syspref => 'hardno',
570
        itypes  => [
571
            {
572
                setting    => 'yes',
573
                categories => [
574
                    {
575
                        setting => 'yes',
576
                        patrons => [
577
                            { setting => 'yes',     result => 0 },
578
                            { setting => 'no',      result => 0 },
579
                            { setting => 'inherit', result => 0 },
580
                        ],
581
                    },
582
                    {
583
                        setting => 'no',
584
                        patrons => [
585
                            { setting => 'yes',     result => 0 },
586
                            { setting => 'no',      result => 0 },
587
                            { setting => 'inherit', result => 0 },
588
                        ],
589
                    },
590
                    {
591
                        setting => 'inherit',
592
                        patrons => [
593
                            { setting => 'yes',     result => 0 },
594
                            { setting => 'no',      result => 0 },
595
                            { setting => 'inherit', result => 0 },
596
                        ],
597
                    },
598
                ],
599
            },
600
            {
601
                setting    => 'no',
602
                categories => [
603
                    {
604
                        setting => 'yes',
605
                        patrons => [
606
                            { setting => 'yes',     result => 0 },
607
                            { setting => 'no',      result => 0 },
608
                            { setting => 'inherit', result => 0 },
609
                        ],
610
                    },
611
                    {
612
                        setting => 'no',
613
                        patrons => [
614
                            { setting => 'yes',     result => 0 },
615
                            { setting => 'no',      result => 0 },
616
                            { setting => 'inherit', result => 0 },
617
                        ],
618
                    },
619
                    {
620
                        setting => 'inherit',
621
                        patrons => [
622
                            { setting => 'yes',     result => 0 },
623
                            { setting => 'no',      result => 0 },
624
                            { setting => 'inherit', result => 0 },
625
                        ],
626
                    },
627
                ],
628
            },
629
            {
630
                setting    => 'inherit',
631
                categories => [
632
                    {
633
                        setting => 'yes',
634
                        patrons => [
635
                            { setting => 'yes',     result => 0 },
636
                            { setting => 'no',      result => 0 },
637
                            { setting => 'inherit', result => 0 },
638
                        ],
639
                    },
640
                    {
641
                        setting => 'no',
642
                        patrons => [
643
                            { setting => 'yes',     result => 0 },
644
                            { setting => 'no',      result => 0 },
645
                            { setting => 'inherit', result => 0 },
646
                        ],
647
                    },
648
                    {
649
                        setting => 'inherit',
650
                        patrons => [
651
                            { setting => 'yes',     result => 0 },
652
                            { setting => 'no',      result => 0 },
653
                            { setting => 'inherit', result => 0 },
654
                        ],
655
                    },
656
                ],
657
            },
658
        ],
659
    }
660
];
661
662
map {
663
    my $syspref = $_->{syspref};
664
    t::lib::Mocks::mock_preference( 'checkprevcheckout', $syspref );
665
    map {
666
        my $itypeCode = uc( $_->{setting} ) . 'IT';
667
        my $item      = $builder->build_sample_item( { itype => $itypeCode } );
668
        map {
669
            my $catCode = $_->{setting} . 'Cat';
670
            map {
671
                my $kpatron = $builder->build(
672
                    {
673
                        source => 'Borrower',
674
                        value  => {
675
                            checkprevcheckout => $_->{setting},
676
                            categorycode      => $catCode,
677
                        },
678
                    }
679
                );
680
                my $patron = Koha::Patrons->find( $kpatron->{borrowernumber} );
681
                is(
682
                    $patron->wants_check_for_previous_checkout($item), $_->{result},
683
                    "Predicate with syspref "
684
                        . $syspref
685
                        . ", cat "
686
                        . $catCode
687
                        . ", patron "
688
                        . $_->{setting}
689
                        . ", item type "
690
                        . $itypeCode
691
                );
692
            } @{ $_->{patrons} };
693
        } @{ $_->{categories} };
694
    } @{ $_->{itypes} };
695
} @{$itemMappings};
696
208
# do_check_for_previous_checkout
697
# do_check_for_previous_checkout
209
698
210
# We want to test:
699
# We want to test:
211
- 

Return to bug 20644