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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 1037-1043 sub CanBookBeIssued { Link Here
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 ); # FIXME Refetch just in case, to avoid regressions. But must not be needed
1040
    if ( $patron->wants_check_for_previous_checkout && $patron->do_check_for_previous_checkout($item_unblessed) ) {
1040
    if ( $patron->wants_check_for_previous_checkout($item_unblessed) && $patron->do_check_for_previous_checkout($item_unblessed) ) {
1041
        $needsconfirmation{PREVISSUE} = 1;
1041
        $needsconfirmation{PREVISSUE} = 1;
1042
    }
1042
    }
1043
1043
(-)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->{itype});
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 (+18 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(q{
11
            ALTER TABLE itemtypes
12
            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''.'
13
            AFTER automatic_checkin;
14
        });
15
16
        say $out "Added column 'itemtypes.checkprevcheckout'";
17
    },
18
};
(-)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 / +23 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
        itemtype          => 'ITYPE1',
159
    })->store,
160
    Koha::ItemType->new({
161
        itemtype          => 'ITYPE2',
162
        checkprevcheckout => undef,
163
    })->store,
164
);
165
166
for my $itype (@itypes) {
167
    my $retrived_itype = Koha::ItemTypes->find( $itype->itemtype );
168
    is( $retrived_itype->checkprevcheckout, 'inherit', 'Koha::ItemType->store should default checkprevcheckout to inherit' );
169
}
170
171
is( Koha::ItemTypes->search->count, $initial_count2 + 2, 'Two item types with \'checkprevcheckout\' set to \'undef\' have been added');
172
153
$schema->txn_rollback;
173
$schema->txn_rollback;
(-)a/t/db_dependent/Patron/Borrower_PrevCheckout.t (-2 / +476 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
    source => 'Itemtype',
47
    value  => {
48
        itemtype          => 'YESIT',
49
        checkprevcheckout => 'yes',
50
    },
51
});
52
53
my $noItypeCode = $builder->build({
54
    source => 'Itemtype',
55
    value  => {
56
        itemtype          => 'NOIT',
57
        checkprevcheckout => 'no',
58
    },
59
});
60
61
my $inheritItypeCode = $builder->build({
62
    source => 'Itemtype',
63
    value  => {
64
        itemtype          => 'INHERITIT',
65
        checkprevcheckout => 'inherit',
66
    },
67
});
68
45
# Create context for some tests late on in the file.
69
# Create context for some tests late on in the file.
46
my $library = $builder->build({ source => 'Branch' });
70
my $library = $builder->build({ source => 'Branch' });
47
my $staff = $builder->build({source => 'Borrower'});
71
my $staff = $builder->build({source => 'Borrower'});
Lines 50-55 t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); Link Here
50
74
51
# wants_check_for_previous_checkout
75
# wants_check_for_previous_checkout
52
76
77
# We want to test the subroutine without passing the $item parameter
53
# We expect the following result matrix:
78
# We expect the following result matrix:
54
#
79
#
55
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we
80
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we
Lines 205-210 map { Link Here
205
    } @{$_->{categories}};
230
    } @{$_->{categories}};
206
} @{$mappings};
231
} @{$mappings};
207
232
233
234
# wants_check_for_previous_checkout
235
236
# We want to test the subroutine by passing the $item parameter
237
# We expect the following result matrix:
238
#
239
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we
240
# should check whether the item was previously issued)
241
#
242
# | System Preference | hardyes                                                                                                   |
243
# |-------------------+-----------------------------------------------------------------------------------------------------------|
244
# | Item Type Setting | yes                               | no                                | inherit                           |
245
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
246
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
247
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
248
# | 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 |
249
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
250
# | 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 |
251
#
252
#
253
# | System Preference | softyes                                                                                                   |
254
# |-------------------+-----------------------------------------------------------------------------------------------------------|
255
# | Item Type Setting | yes                               | no                                | inherit                           |
256
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
257
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
258
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
259
# | 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 |
260
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
261
# | 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 |
262
#
263
#
264
# | System Preference | softno                                                                                                    |
265
# |-------------------+-----------------------------------------------------------------------------------------------------------|
266
# | Item Type Setting | yes                               | no                                | inherit                           |
267
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
268
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
269
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
270
# | 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 |
271
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
272
# | 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 |
273
#
274
#
275
# | System Preference | hardno                                                                                                    |
276
# |-------------------+-----------------------------------------------------------------------------------------------------------|
277
# | Item Type Setting | yes                               | no                                | inherit                           |
278
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------|
279
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
280
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
281
# | 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 |
282
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
283
# | 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 |
284
285
my $itemMappings = [
286
    {
287
        syspref => 'hardyes',
288
        itypes  => [
289
            {
290
                setting    => 'yes',
291
                categories => [
292
                    {
293
                        setting => 'yes',
294
                        patrons => [
295
                            {setting => 'yes',     result => 1},
296
                            {setting => 'no',      result => 1},
297
                            {setting => 'inherit', result => 1},
298
                        ],
299
                    },
300
                    {
301
                        setting => 'no',
302
                        patrons => [
303
                            {setting => 'yes',     result => 1},
304
                            {setting => 'no',      result => 1},
305
                            {setting => 'inherit', result => 1},
306
                        ],
307
                    },
308
                    {
309
                        setting => 'inherit',
310
                        patrons => [
311
                            {setting => 'yes',     result => 1},
312
                            {setting => 'no',      result => 1},
313
                            {setting => 'inherit', result => 1},
314
                        ],
315
                    },
316
                ],
317
            },
318
            {
319
                setting    => 'no',
320
                categories => [
321
                    {
322
                        setting => 'yes',
323
                        patrons => [
324
                            {setting => 'yes',     result => 1},
325
                            {setting => 'no',      result => 1},
326
                            {setting => 'inherit', result => 1},
327
                        ],
328
                    },
329
                    {
330
                        setting => 'no',
331
                        patrons => [
332
                            {setting => 'yes',     result => 1},
333
                            {setting => 'no',      result => 1},
334
                            {setting => 'inherit', result => 1},
335
                        ],
336
                    },
337
                    {
338
                        setting => 'inherit',
339
                        patrons => [
340
                            {setting => 'yes',     result => 1},
341
                            {setting => 'no',      result => 1},
342
                            {setting => 'inherit', result => 1},
343
                        ],
344
                    },
345
                ],
346
            },
347
            {
348
                setting    => 'inherit',
349
                categories => [
350
                    {
351
                        setting => 'yes',
352
                        patrons => [
353
                            {setting => 'yes',     result => 1},
354
                            {setting => 'no',      result => 1},
355
                            {setting => 'inherit', result => 1},
356
                        ],
357
                    },
358
                    {
359
                        setting => 'no',
360
                        patrons => [
361
                            {setting => 'yes',     result => 1},
362
                            {setting => 'no',      result => 1},
363
                            {setting => 'inherit', result => 1},
364
                        ],
365
                    },
366
                    {
367
                        setting => 'inherit',
368
                        patrons => [
369
                            {setting => 'yes',     result => 1},
370
                            {setting => 'no',      result => 1},
371
                            {setting => 'inherit', result => 1},
372
                        ],
373
                    },
374
                ],
375
            },
376
        ],
377
    },
378
    {
379
        syspref => 'softyes',
380
        itypes  => [
381
            {
382
                setting    => 'yes',
383
                categories => [
384
                    {
385
                        setting => 'yes',
386
                        patrons => [
387
                            {setting => 'yes',     result => 1},
388
                            {setting => 'no',      result => 1},
389
                            {setting => 'inherit', result => 1},
390
                        ],
391
                    },
392
                    {
393
                        setting => 'no',
394
                        patrons => [
395
                            {setting => 'yes',     result => 1},
396
                            {setting => 'no',      result => 1},
397
                            {setting => 'inherit', result => 1},
398
                        ],
399
                    },
400
                    {
401
                        setting => 'inherit',
402
                        patrons => [
403
                            {setting => 'yes',     result => 1},
404
                            {setting => 'no',      result => 1},
405
                            {setting => 'inherit', result => 1},
406
                        ],
407
                    },
408
                ],
409
            },
410
            {
411
                setting    => 'no',
412
                categories => [
413
                    {
414
                        setting => 'yes',
415
                        patrons => [
416
                            {setting => 'yes',     result => 0},
417
                            {setting => 'no',      result => 0},
418
                            {setting => 'inherit', result => 0},
419
                        ],
420
                    },
421
                    {
422
                        setting => 'no',
423
                        patrons => [
424
                            {setting => 'yes',     result => 0},
425
                            {setting => 'no',      result => 0},
426
                            {setting => 'inherit', result => 0},
427
                        ],
428
                    },
429
                    {
430
                        setting => 'inherit',
431
                        patrons => [
432
                            {setting => 'yes',     result => 0},
433
                            {setting => 'no',      result => 0},
434
                            {setting => 'inherit', result => 0},
435
                        ],
436
                    },
437
                ],
438
            },
439
            {
440
                setting    => 'inherit',
441
                categories => [
442
                    {
443
                        setting => 'yes',
444
                        patrons => [
445
                            {setting => 'yes',     result => 1},
446
                            {setting => 'no',      result => 0},
447
                            {setting => 'inherit', result => 1},
448
                        ],
449
                    },
450
                    {
451
                        setting => 'no',
452
                        patrons => [
453
                            {setting => 'yes',     result => 1},
454
                            {setting => 'no',      result => 0},
455
                            {setting => 'inherit', result => 0},
456
                        ],
457
                    },
458
                    {
459
                        setting => 'inherit',
460
                        patrons => [
461
                            {setting => 'yes',     result => 1},
462
                            {setting => 'no',      result => 0},
463
                            {setting => 'inherit', result => 1},
464
                        ],
465
                    },
466
                ],
467
            },
468
        ],
469
    },
470
    {
471
        syspref => 'softno',
472
        itypes  => [
473
            {
474
                setting    => 'yes',
475
                categories => [
476
                    {
477
                        setting => 'yes',
478
                        patrons => [
479
                            {setting => 'yes',     result => 1},
480
                            {setting => 'no',      result => 1},
481
                            {setting => 'inherit', result => 1},
482
                        ],
483
                    },
484
                    {
485
                        setting => 'no',
486
                        patrons => [
487
                            {setting => 'yes',     result => 1},
488
                            {setting => 'no',      result => 1},
489
                            {setting => 'inherit', result => 1},
490
                        ],
491
                    },
492
                    {
493
                        setting => 'inherit',
494
                        patrons => [
495
                            {setting => 'yes',     result => 1},
496
                            {setting => 'no',      result => 1},
497
                            {setting => 'inherit', result => 1},
498
                        ],
499
                    },
500
                ],
501
            },
502
            {
503
                setting    => 'no',
504
                categories => [
505
                    {
506
                        setting => 'yes',
507
                        patrons => [
508
                            {setting => 'yes',     result => 0},
509
                            {setting => 'no',      result => 0},
510
                            {setting => 'inherit', result => 0},
511
                        ],
512
                    },
513
                    {
514
                        setting => 'no',
515
                        patrons => [
516
                            {setting => 'yes',     result => 0},
517
                            {setting => 'no',      result => 0},
518
                            {setting => 'inherit', result => 0},
519
                        ],
520
                    },
521
                    {
522
                        setting => 'inherit',
523
                        patrons => [
524
                            {setting => 'yes',     result => 0},
525
                            {setting => 'no',      result => 0},
526
                            {setting => 'inherit', result => 0},
527
                        ],
528
                    },
529
                ],
530
            },
531
            {
532
                setting    => 'inherit',
533
                categories => [
534
                    {
535
                        setting => 'yes',
536
                        patrons => [
537
                            {setting => 'yes',     result => 1},
538
                            {setting => 'no',      result => 0},
539
                            {setting => 'inherit', result => 1},
540
                        ],
541
                    },
542
                    {
543
                        setting => 'no',
544
                        patrons => [
545
                            {setting => 'yes',     result => 1},
546
                            {setting => 'no',      result => 0},
547
                            {setting => 'inherit', result => 0},
548
                        ],
549
                    },
550
                    {
551
                        setting => 'inherit',
552
                        patrons => [
553
                            {setting => 'yes',     result => 1},
554
                            {setting => 'no',      result => 0},
555
                            {setting => 'inherit', result => 0},
556
                        ],
557
                    },
558
                ],
559
            },
560
        ],
561
    },
562
    {
563
        syspref => 'hardno',
564
        itypes  => [
565
            {
566
                setting    => 'yes',
567
                categories => [
568
                    {
569
                        setting => 'yes',
570
                        patrons => [
571
                            {setting => 'yes',     result => 0},
572
                            {setting => 'no',      result => 0},
573
                            {setting => 'inherit', result => 0},
574
                        ],
575
                    },
576
                    {
577
                        setting => 'no',
578
                        patrons => [
579
                            {setting => 'yes',     result => 0},
580
                            {setting => 'no',      result => 0},
581
                            {setting => 'inherit', result => 0},
582
                        ],
583
                    },
584
                    {
585
                        setting => 'inherit',
586
                        patrons => [
587
                            {setting => 'yes',     result => 0},
588
                            {setting => 'no',      result => 0},
589
                            {setting => 'inherit', result => 0},
590
                        ],
591
                    },
592
                ],
593
            },
594
            {
595
                setting    => 'no',
596
                categories => [
597
                    {
598
                        setting => 'yes',
599
                        patrons => [
600
                            {setting => 'yes',     result => 0},
601
                            {setting => 'no',      result => 0},
602
                            {setting => 'inherit', result => 0},
603
                        ],
604
                    },
605
                    {
606
                        setting => 'no',
607
                        patrons => [
608
                            {setting => 'yes',     result => 0},
609
                            {setting => 'no',      result => 0},
610
                            {setting => 'inherit', result => 0},
611
                        ],
612
                    },
613
                    {
614
                        setting => 'inherit',
615
                        patrons => [
616
                            {setting => 'yes',     result => 0},
617
                            {setting => 'no',      result => 0},
618
                            {setting => 'inherit', result => 0},
619
                        ],
620
                    },
621
                ],
622
            },
623
            {
624
                setting    => 'inherit',
625
                categories => [
626
                    {
627
                        setting => 'yes',
628
                        patrons => [
629
                            {setting => 'yes',     result => 0},
630
                            {setting => 'no',      result => 0},
631
                            {setting => 'inherit', result => 0},
632
                        ],
633
                    },
634
                    {
635
                        setting => 'no',
636
                        patrons => [
637
                            {setting => 'yes',     result => 0},
638
                            {setting => 'no',      result => 0},
639
                            {setting => 'inherit', result => 0},
640
                        ],
641
                    },
642
                    {
643
                        setting => 'inherit',
644
                        patrons => [
645
                            {setting => 'yes',     result => 0},
646
                            {setting => 'no',      result => 0},
647
                            {setting => 'inherit', result => 0},
648
                        ],
649
                    },
650
                ],
651
            },
652
        ],
653
    }
654
];
655
656
map {
657
    my $syspref = $_->{syspref};
658
    t::lib::Mocks::mock_preference('checkprevcheckout', $syspref);
659
    map {
660
        my $itypeCode = uc($_->{setting}) . 'IT';
661
        my $item = $builder->build_sample_item({itype => $itypeCode})->unblessed;
662
        map {
663
            my $catCode = $_->{setting} . 'Cat';
664
            map {
665
                my $kpatron = $builder->build({
666
                    source => 'Borrower',
667
                    value  => {
668
                        checkprevcheckout => $_->{setting},
669
                        categorycode => $catCode,
670
                    },
671
                });
672
                my $patron = Koha::Patrons->find($kpatron->{borrowernumber});
673
                is(
674
                    $patron->wants_check_for_previous_checkout($item), $_->{result},
675
                    "Predicate with syspref " . $syspref . ", cat " . $catCode
676
                        . ", patron " . $_->{setting} . ", item type " . $itypeCode
677
                );
678
            } @{$_->{patrons}};
679
        } @{$_->{categories}};
680
    } @{$_->{itypes}};
681
} @{$itemMappings};
682
208
# do_check_for_previous_checkout
683
# do_check_for_previous_checkout
209
684
210
# We want to test:
685
# We want to test:
211
- 

Return to bug 20644