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

(-)a/Koha/Item.pm (+12 lines)
Lines 1830-1835 that this complicates filtering, but some query trickery could do it in the cont Link Here
1830
1830
1831
sub item_type {
1831
sub item_type {
1832
    return shift->itemtype;
1832
    return shift->itemtype;
1833
=head3 effective_bookable
1834
1835
  my $bookable = $item->effective_bookable;
1836
1837
Returns the effective bookability of the current item, be that item or itemtype level
1838
1839
=cut
1840
1841
sub effective_bookable {
1842
    my ($self) = @_;
1843
1844
    return defined( $self->bookable ) ? $self->bookable : $self->itemtype->bookable;
1833
}
1845
}
1834
1846
1835
=head3 orders
1847
=head3 orders
(-)a/Koha/ItemType.pm (+1 lines)
Lines 234-239 sub to_api_mapping { Link Here
234
        rentalcharge_daily_calendar  => 'daily_rental_charge_calendar',
234
        rentalcharge_daily_calendar  => 'daily_rental_charge_calendar',
235
        rentalcharge_hourly          => 'hourly_rental_charge',
235
        rentalcharge_hourly          => 'hourly_rental_charge',
236
        rentalcharge_hourly_calendar => 'hourly_rental_charge_calendar',
236
        rentalcharge_hourly_calendar => 'hourly_rental_charge_calendar',
237
        bookable_itemtype            => 'bookable_itemtype',
237
    };
238
    };
238
}
239
}
239
240
(-)a/Koha/Items.pm (-2 / +10 lines)
Lines 169-177 Returns a new resultset, containing only those items that are allowed to be book Link Here
169
sub filter_by_bookable {
169
sub filter_by_bookable {
170
    my ($self) = @_;
170
    my ($self) = @_;
171
171
172
    my $params = { bookable => 1 };
172
    my @bookable_itemtypes = Koha::ItemTypes->search( { bookable => 1 } )->get_column('itemtype');
173
173
174
    return $self->search($params);
174
    my ( $where, $attr );
175
    if ( C4::Context->preference("item-level_itypes") ) {
176
        $where = [ { bookable => 1 }, { bookable => undef, itype => { -in => \@bookable_itemtypes } } ];
177
    } else {
178
        $where = [ { bookable => 1 }, { bookable => undef, 'biblioitem.itemtype' => { -in => \@bookable_itemtypes } } ];
179
        $attr  = { join => 'biblioitem' };
180
    }
181
182
    return $self->search( $where, $attr );
175
}
183
}
176
184
177
=head3 move_to_biblio
185
=head3 move_to_biblio
(-)a/Koha/REST/V1/Biblios.pm (+3 lines)
Lines 266-271 sub get_items { Link Here
266
    my $biblio        = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } );
266
    my $biblio        = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } );
267
    my $bookable_only = $c->param('bookable');
267
    my $bookable_only = $c->param('bookable');
268
268
269
    # Deletion of parameter to avoid filtering on the items table in the case of bookings on 'itemtype'
270
    $c->req->params->remove('bookable');
271
269
    return $c->render_resource_not_found("Bibliographic record")
272
    return $c->render_resource_not_found("Bibliographic record")
270
        unless $biblio;
273
        unless $biblio;
271
274
(-)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 $bookable = $input->param('bookable')// 0;
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->bookable($bookable);
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
                bookable   => $bookable,
154
            }
157
            }
155
        );
158
        );
156
        eval {
159
        eval {
(-)a/api/v1/swagger/definitions/item.yaml (-3 / +11 lines)
Lines 24-29 properties: Link Here
24
      - "null"
24
      - "null"
25
    description: Information about the acquisition source (it is not really a vendor id)
25
    description: Information about the acquisition source (it is not really a vendor id)
26
  bookable:
26
  bookable:
27
    type:
28
      - boolean
29
      - "null"
30
    description: Item level bookability override.
31
  effective_bookable:
27
    type: boolean
32
    type: boolean
28
    description: Allow bookings on this item.
33
    description: Allow bookings on this item.
29
  home_library_id:
34
  home_library_id:
Lines 90-96 properties: Link Here
90
      - string
95
      - string
91
      - "null"
96
      - "null"
92
    format: date-time
97
    format: date-time
93
    description: The date and time an item was last marked as withdrawn, NULL if not
98
    description:
99
      The date and time an item was last marked as withdrawn, NULL if not
94
      withdrawn
100
      withdrawn
95
  callnumber:
101
  callnumber:
96
    type:
102
    type:
Lines 155-168 properties: Link Here
155
    type:
161
    type:
156
      - string
162
      - string
157
      - "null"
163
      - "null"
158
    description: Linked to the CART and PROC temporary locations feature, stores the
164
    description:
165
      Linked to the CART and PROC temporary locations feature, stores the
159
      permanent shelving location
166
      permanent shelving location
160
  checked_out_date:
167
  checked_out_date:
161
    type:
168
    type:
162
      - string
169
      - string
163
      - "null"
170
      - "null"
164
    format: date
171
    format: date
165
    description: Defines if item is checked out (NULL for not checked out, and checkout
172
    description:
173
      Defines if item is checked out (NULL for not checked out, and checkout
166
      date for checked out)
174
      date for checked out)
167
  call_number_source:
175
  call_number_source:
168
    type:
176
    type:
(-)a/api/v1/swagger/paths/biblios.yaml (+1 lines)
Lines 450-455 Link Here
450
            - cover_image_ids
450
            - cover_image_ids
451
            - item_group_item.item_group.description
451
            - item_group_item.item_group.description
452
            - serial_item.serial
452
            - serial_item.serial
453
            - effective_bookable
453
        collectionFormat: csv
454
        collectionFormat: csv
454
      - $ref: "../swagger.yaml#/parameters/match"
455
      - $ref: "../swagger.yaml#/parameters/match"
455
      - $ref: "../swagger.yaml#/parameters/order_by"
456
      - $ref: "../swagger.yaml#/parameters/order_by"
(-)a/api/v1/swagger/paths/items.yaml (-1 / +3 lines)
Lines 22-27 Link Here
22
          enum:
22
          enum:
23
            - +strings
23
            - +strings
24
            - biblio
24
            - biblio
25
            - effective_bookable
25
        collectionFormat: csv
26
        collectionFormat: csv
26
      - $ref: "../swagger.yaml#/parameters/match"
27
      - $ref: "../swagger.yaml#/parameters/match"
27
      - $ref: "../swagger.yaml#/parameters/order_by"
28
      - $ref: "../swagger.yaml#/parameters/order_by"
Lines 81-86 Link Here
81
          type: string
82
          type: string
82
          enum:
83
          enum:
83
            - +strings
84
            - +strings
85
            - effective_bookable
84
        collectionFormat: csv
86
        collectionFormat: csv
85
    consumes:
87
    consumes:
86
      - application/json
88
      - application/json
Lines 150-156 Link Here
150
            * linked_analytics: The item has linked analytic records
152
            * linked_analytics: The item has linked analytic records
151
            * not_same_branch: The item is blocked by independent branches
153
            * not_same_branch: The item is blocked by independent branches
152
        schema:
154
        schema:
153
              $ref: "../swagger.yaml#/definitions/error"
155
          $ref: "../swagger.yaml#/definitions/error"
154
      "500":
156
      "500":
155
        description: |
157
        description: |
156
          Internal server error. Possible `error_code` attribute values:
158
          Internal server error. Possible `error_code` attribute values:
(-)a/catalogue/updateitem.pl (-1 / +2 lines)
Lines 39-45 my $itemnotes_nonpublic=$cgi->param('itemnotes_nonpublic'); Link Here
39
my $withdrawn=$cgi->param('withdrawn');
39
my $withdrawn=$cgi->param('withdrawn');
40
my $damaged=$cgi->param('damaged');
40
my $damaged=$cgi->param('damaged');
41
my $exclude_from_local_holds_priority = $cgi->param('exclude_from_local_holds_priority');
41
my $exclude_from_local_holds_priority = $cgi->param('exclude_from_local_holds_priority');
42
my $bookable = $cgi->param('bookable');
42
my $bookable = $cgi->param('bookable') // q{};
43
43
44
my $confirm=$cgi->param('confirm');
44
my $confirm=$cgi->param('confirm');
45
my $dbh = C4::Context->dbh;
45
my $dbh = C4::Context->dbh;
Lines 77-82 elsif ( $op eq "cud-set_public_note" ) { # i.e., itemnotes parameter passed from Link Here
77
    $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority);
77
    $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority);
78
    $messages = "updated_exclude_from_local_holds_priority=$exclude_from_local_holds_priority&";
78
    $messages = "updated_exclude_from_local_holds_priority=$exclude_from_local_holds_priority&";
79
} elsif ( $op eq "cud-set_bookable" && $bookable ne $item_data_hashref->{'bookable'} ) {
79
} elsif ( $op eq "cud-set_bookable" && $bookable ne $item_data_hashref->{'bookable'} ) {
80
    undef($bookable) if $bookable eq "";
80
    $item->bookable($bookable);
81
    $item->bookable($bookable);
81
} elsif ( $op eq "cud-set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
82
} elsif ( $op eq "cud-set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
82
    $item->damaged($damaged);
83
    $item->damaged($damaged);
(-)a/installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl (+35 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "35906",
5
    description => "Add bookable column on 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 ADD IF NOT EXISTS bookable INT(1) DEFAULT 0
13
        }
14
        );
15
16
        say $out "Added column 'itemtypes.bookable'";
17
18
        $dbh->do(
19
            q{
20
            ALTER TABLE items MODIFY COLUMN bookable tinyint(1) DEFAULT NULL COMMENT 'nullable boolean value defining whether this this item is available for bookings or not'
21
        }
22
        );
23
24
        say $out "Updated column 'items.bookable' allow nullable";
25
26
        $dbh->do(
27
            q{
28
            ALTER TABLE deleteditems MODIFY COLUMN bookable tinyint(1) DEFAULT NULL COMMENT 'nullable boolean value defining whether this this item is available for bookings or not'
29
        }
30
        );
31
32
        say $out "Updated column 'deleteditems.bookable' allow nullable";
33
34
    },
35
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +3 lines)
Lines 2750-2756 CREATE TABLE `deleteditems` ( Link Here
2750
  `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
2750
  `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
2751
  `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
2751
  `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
2752
  `barcode` varchar(20) DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
2752
  `barcode` varchar(20) DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
2753
  `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean value defining whether this this item is available for bookings or not',
2753
  `bookable` tinyint(1) DEFAULT NULL COMMENT 'nullable boolean value defining whether this this item is available for bookings or not',
2754
  `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
2754
  `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
2755
  `booksellerid` longtext DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
2755
  `booksellerid` longtext DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
2756
  `homebranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that owns this item (MARC21 952$a)',
2756
  `homebranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that owns this item (MARC21 952$a)',
Lines 4008-4014 CREATE TABLE `items` ( Link Here
4008
  `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
4008
  `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
4009
  `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
4009
  `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
4010
  `barcode` varchar(20) DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
4010
  `barcode` varchar(20) DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
4011
  `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean value defining whether this this item is available for bookings or not',
4011
  `bookable` tinyint(1) DEFAULT NULL COMMENT 'nullable boolean value defining whether this this item is available for bookings or not',
4012
  `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
4012
  `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
4013
  `booksellerid` longtext DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
4013
  `booksellerid` longtext DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
4014
  `homebranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that owns this item (MARC21 952$a)',
4014
  `homebranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that owns this item (MARC21 952$a)',
Lines 4137-4142 CREATE TABLE `itemtypes` ( Link Here
4137
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4137
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4138
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4138
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4139
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4139
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4140
  `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Activate bookable feature for items related to this item type',
4140
  PRIMARY KEY (`itemtype`),
4141
  PRIMARY KEY (`itemtype`),
4141
  UNIQUE KEY `itemtype` (`itemtype`),
4142
  UNIQUE KEY `itemtype` (`itemtype`),
4142
  KEY `itemtypes_ibfk_1` (`parent_type`),
4143
  KEY `itemtypes_ibfk_1` (`parent_type`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+9 lines)
Lines 258-263 Link Here
258
                        [% END %]
258
                        [% END %]
259
                        <span class="hint">If checked, items will be automatically checked in once they've reached their due date. This feature requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.</span>
259
                        <span class="hint">If checked, items will be automatically checked in once they've reached their due date. This feature requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.</span>
260
                </li>
260
                </li>
261
                <li>
262
                    <label for="bookable">Bookable: </label>
263
                        [% IF itemtype.bookable %]
264
                            <input type="checkbox" id="bookable" name="bookable" checked="checked" value="1" />
265
                        [% ELSE %]
266
                            <input type="checkbox" id="bookable" name="bookable" value="1" />
267
                        [% END %]
268
                        <span class="hint">If checked, all items of this type will be enabled for future bookings unless overridden at the item level.</span>
269
                </li>
261
                <li>
270
                <li>
262
                    <label for="rentalcharge">Rental charge: </label>
271
                    <label for="rentalcharge">Rental charge: </label>
263
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" />
272
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-5 / +14 lines)
Lines 350-356 Link Here
350
                                            </form>
350
                                            </form>
351
                                        </li>
351
                                        </li>
352
                                        <li>
352
                                        <li>
353
                                            <span class="label">Bookable:</span>
353
                                            <span class="label">
354
                                                Bookable:
355
                                            </span>
354
                                            [% IF ( CAN_user_circulate ) %]
356
                                            [% IF ( CAN_user_circulate ) %]
355
                                                <form action="updateitem.pl" method="post">
357
                                                <form action="updateitem.pl" method="post">
356
                                                    [% INCLUDE 'csrf-token.inc' %]
358
                                                    [% INCLUDE 'csrf-token.inc' %]
Lines 358-377 Link Here
358
                                                    <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" />
360
                                                    <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" />
359
                                                    <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
361
                                                    <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
360
                                                    <select name="bookable">
362
                                                    <select name="bookable">
361
                                                        [% IF ITEM_DAT.bookable == 1 %]
363
                                                    [% IF ITEM_DAT.bookable == 1 %]
364
                                                        <option value="">Follow item type</option>
362
                                                        <option value="1" selected="selected">Yes</option>
365
                                                        <option value="1" selected="selected">Yes</option>
363
                                                        <option value="0">No</option>
366
                                                        <option value="0">No</option>
364
                                                        [% ELSE %]
367
                                                    [% ELSIF ITEM_DAT.bookable == 0 %]
368
                                                        <option value="">Follow item type</option>
365
                                                        <option value="1">Yes</option>
369
                                                        <option value="1">Yes</option>
366
                                                        <option value="0" selected="selected">No</option>
370
                                                        <option value="0" selected="selected">No</option>
367
                                                        [% END %]
371
                                                    [% ELSE %]
372
                                                        <option value="" selected="selected">Follow item type</option>
373
                                                        <option value="1">Yes</option>
374
                                                        <option value="0">No</option>
375
                                                    [% END %]
368
                                                    </select>
376
                                                    </select>
369
                                                    <input type="hidden" name="op" value="cud-set_bookable" />
377
                                                    <input type="hidden" name="op" value="cud-set_bookable" />
370
                                                    <input type="submit" name="submit" class="btn btn-primary btn-xs" value="Update" />
378
                                                    <input type="submit" name="submit" class="btn btn-primary btn-xs" value="Update" />
371
                                                </form>
379
                                                </form>
372
                                            [% ELSE %]
380
                                            [% ELSE %]
373
                                                [% IF ITEM_DAT.bookable == 1 %] Yes [% ELSE %] No [% END %]
381
                                                [% IF ITEM_DAT.bookable == 1 %] Yes [% ELSIF ITEM_DAT.bookable == 0 %] No [% ELSE %] Follow item type [% END %]
374
                                            [% END %]
382
                                            [% END %]
383
                                            <span class="hint"> Item type bookable: [% IF ITEM_DAT.effective_itemtype.bookable == 1 %]Yes[% ELSE %]No[% END %]</span>
375
                                        </li>
384
                                        </li>
376
385
377
                                    </ol> <!-- /.bibliodetails -->
386
                                    </ol> <!-- /.bibliodetails -->
(-)a/t/db_dependent/Koha/Items.t (-7 / +20 lines)
Lines 2078-2101 subtest 'filter_by_for_hold' => sub { Link Here
2078
};
2078
};
2079
2079
2080
subtest 'filter_by_bookable' => sub {
2080
subtest 'filter_by_bookable' => sub {
2081
    plan tests => 2;
2081
    plan tests => 4;
2082
2082
2083
    $schema->storage->txn_begin;
2083
    $schema->storage->txn_begin;
2084
2084
2085
    my $biblio = $builder->build_sample_biblio;
2085
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
2086
2087
    my $bookable_item_type = $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 1 } } );
2088
    my $non_bookable_item_type = $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 0 } } );
2089
    my $biblio = $builder->build_sample_biblio({ itemtype => $bookable_item_type->itemtype });
2086
2090
2087
    # bookable items
2091
    # bookable items
2088
    my $bookable_item1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 1 } );
2092
    my $bookable_item1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $bookable_item_type->itemtype, bookable => 1 } );
2089
2093
2090
    # not bookable items
2094
    # not bookable items
2091
    my $non_bookable_item1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 0 } );
2095
    my $non_bookable_item1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $non_bookable_item_type->itemtype, bookable => 0 } );
2092
    my $non_bookable_item2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 0 } );
2096
    my $non_bookable_item2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $non_bookable_item_type->itemtype, bookable => 0 } );
2093
2097
2094
    is( $biblio->items->filter_by_bookable->count, 1, "filter_by_bookable returns the correct number of items" );
2098
    is( $biblio->items->filter_by_bookable->count, 1, "filter_by_bookable returns the correct number of items set at item level" );
2095
    is(
2099
    is(
2096
        $biblio->items->filter_by_bookable->next->itemnumber, $bookable_item1->itemnumber,
2100
        $biblio->items->filter_by_bookable->next->itemnumber, $bookable_item1->itemnumber,
2097
        "the correct item is returned from filter_by_bookable"
2101
        "the correct item is returned from filter_by_bookable at the item level"
2098
    );
2102
    );
2099
2103
2104
    $bookable_item1->bookable(undef)->store();
2105
    $non_bookable_item1->bookable(undef)->store();
2106
    $non_bookable_item2->bookable(undef)->store();
2107
    $biblio->get_from_storage;
2108
    is( $biblio->items->filter_by_bookable->count, 3, "filter_by_bookable returns the correct number of items when not set at item level and using biblio level itemtypes" );
2109
2110
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
2111
    is( $biblio->items->filter_by_bookable->count, 1, "filter_by_bookable returns the correct number of items when not set at item level and using item level itemtypes" );
2112
2100
    $schema->storage->txn_rollback;
2113
    $schema->storage->txn_rollback;
2101
};
2114
};
(-)a/t/lib/TestBuilder.pm (-1 / +1 lines)
Lines 638-643 sub _gen_default_values { Link Here
638
            defaultreplacecost => 0,
638
            defaultreplacecost => 0,
639
            processfee => 0,
639
            processfee => 0,
640
            notforloan => 0,
640
            notforloan => 0,
641
            bookable => 0,
641
        },
642
        },
642
        Aqbookseller => {
643
        Aqbookseller => {
643
            tax_rate => 0,
644
            tax_rate => 0,
644
- 

Return to bug 35906