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

(-)a/Koha/Exceptions/Item/Bundle.pm (+4 lines)
Lines 31-36 use Exception::Class ( Link Here
31
        isa         => 'Koha::Exceptions::Item::Bundle',
31
        isa         => 'Koha::Exceptions::Item::Bundle',
32
        description => 'Someone tried to add a checked out item to a bundle',
32
        description => 'Someone tried to add a checked out item to a bundle',
33
    },
33
    },
34
    'Koha::Exceptions::Item::Bundle::ItemHasHolds' => {
35
        isa         => 'Koha::Exceptions::Item::Bundle',
36
        description => 'Someone tried to add a reserved item to a bundle',
37
    },
34
);
38
);
35
39
36
=head1 NAME
40
=head1 NAME
(-)a/Koha/Item.pm (+7 lines)
Lines 1734-1739 sub add_to_bundle { Link Here
1734
                    }
1734
                    }
1735
                }
1735
                }
1736
1736
1737
                my $holds = $bundle_item->current_holds;
1738
                if ($holds->count) {
1739
                    unless ($options->{ignore_holds}) {
1740
                        Koha::Exceptions::Item::Bundle::ItemHasHolds->throw();
1741
                    }
1742
                }
1743
1737
                $self->_result->add_to_item_bundles_hosts(
1744
                $self->_result->add_to_item_bundles_hosts(
1738
                    { item => $bundle_item->itemnumber } );
1745
                    { item => $bundle_item->itemnumber } );
1739
1746
(-)a/Koha/REST/V1/Items.pm (-2 / +16 lines)
Lines 277-284 sub add_to_bundle { Link Here
277
    }
277
    }
278
278
279
    return try {
279
    return try {
280
        my $force_checkin = $c->validation->param('body')->{'force_checkin'};
280
        my $body = $c->validation->param('body');
281
        my $link = $item->add_to_bundle($bundle_item, { force_checkin => $force_checkin });
281
        my $options = {
282
            force_checkin => $body->{force_checkin},
283
            ignore_holds => $body->{ignore_holds},
284
        };
285
286
        my $link = $item->add_to_bundle($bundle_item, $options);
282
        return $c->render(
287
        return $c->render(
283
            status  => 201,
288
            status  => 201,
284
            openapi => $bundle_item
289
            openapi => $bundle_item
Lines 314-319 sub add_to_bundle { Link Here
314
                }
319
                }
315
            );
320
            );
316
        }
321
        }
322
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemHasHolds' ) {
323
            return $c->render(
324
                status  => 409,
325
                openapi => {
326
                    error      => 'Item is reserved',
327
                    error_code => 'reserved'
328
                }
329
            );
330
        }
317
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
331
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
318
            return $c->render(
332
            return $c->render(
319
                status  => 400,
333
                status  => 400,
(-)a/api/v1/swagger/definitions/bundle_link.yaml (+4 lines)
Lines 15-18 properties: Link Here
15
    type:
15
    type:
16
      - boolean
16
      - boolean
17
      - "null"
17
      - "null"
18
  ignore_holds:
19
    type:
20
      - boolean
21
      - "null"
18
additionalProperties: false
22
additionalProperties: false
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +12 lines)
Lines 1803-1808 Note that permanent location is a code, and location may be an authval. Link Here
1803
                                .empty()
1803
                                .empty()
1804
                                .attr('class', 'alert alert-danger')
1804
                                .attr('class', 'alert alert-danger')
1805
                                .append(__x('Failure: Item {barcode} cannot be checked in', { barcode }))
1805
                                .append(__x('Failure: Item {barcode} cannot be checked in', { barcode }))
1806
                          } else if (response.error_code === 'reserved') {
1807
                              const button = $('<button type="button">')
1808
                                .addClass('btn btn-xs')
1809
                                .text(__('Ignore holds and add to bundle'))
1810
                                .on('click', function () {
1811
                                    addToBundle(url, { external_id: barcode, ignore_holds: true });
1812
                                });
1813
                              $('#addResult')
1814
                                .empty()
1815
                                .attr('class', 'alert alert-warning')
1816
                                .append(__x('Warning: Item {barcode} is reserved', { barcode }))
1817
                                .append(' ', button);
1806
                          } else {
1818
                          } else {
1807
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
1819
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
1808
                          }
1820
                          }
1809
- 

Return to bug 33021