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

(-)a/Koha/Hold.pm (-3 / +17 lines)
Lines 47-53 Koha::Hold - Koha Hold object class Link Here
47
47
48
=head1 API
48
=head1 API
49
49
50
=head2 Class Methods
50
=head2 Class methods
51
51
52
=cut
52
=cut
53
53
Lines 254-264 sub is_pickup_location_valid { Link Here
254
254
255
=head3 set_pickup_location
255
=head3 set_pickup_location
256
256
257
    $hold->set_pickup_location({ library_id => $library->id });
257
    $hold->set_pickup_location(
258
        {
259
            library_id => $library->id,
260
          [ override   => 0|1 ]
261
        }
262
    );
258
263
259
Updates the hold pickup location. It throws a I<Koha::Exceptions::Hold::InvalidPickupLocation> if
264
Updates the hold pickup location. It throws a I<Koha::Exceptions::Hold::InvalidPickupLocation> if
260
the passed pickup location is not valid.
265
the passed pickup location is not valid.
261
266
267
Note: It is up to the caller to verify if I<AllowHoldPolicyOverride> is set when setting the
268
B<override> parameter.
269
262
=cut
270
=cut
263
271
264
sub set_pickup_location {
272
sub set_pickup_location {
Lines 267-273 sub set_pickup_location { Link Here
267
    Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory')
275
    Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory')
268
        unless $params->{library_id};
276
        unless $params->{library_id};
269
277
270
    if ( $self->is_pickup_location_valid({ library_id => $params->{library_id} }) ) {
278
    if (
279
        $params->{override}
280
        || $self->is_pickup_location_valid(
281
            { library_id => $params->{library_id} }
282
        )
283
      )
284
    {
271
        # all good, set the new pickup location
285
        # all good, set the new pickup location
272
        $self->branchcode( $params->{library_id} )->store;
286
        $self->branchcode( $params->{library_id} )->store;
273
    }
287
    }
(-)a/t/db_dependent/Koha/Hold.t (-2 / +5 lines)
Lines 56-62 subtest 'patron() tests' => sub { Link Here
56
56
57
subtest 'set_pickup_location() tests' => sub {
57
subtest 'set_pickup_location() tests' => sub {
58
58
59
    plan tests => 10;
59
    plan tests => 11;
60
60
61
    $schema->storage->txn_begin;
61
    $schema->storage->txn_begin;
62
62
Lines 125-130 subtest 'set_pickup_location() tests' => sub { Link Here
125
    $item_hold->discard_changes;
125
    $item_hold->discard_changes;
126
    is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' );
126
    is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' );
127
127
128
    $item_hold->set_pickup_location({ library_id => $library_1->branchcode, override => 1 });
129
    $item_hold->discard_changes;
130
    is( $item_hold->branchcode, $library_1->branchcode, 'branchcode changed because of \'override\'' );
131
128
    $ret = $item_hold->set_pickup_location({ library_id => $library_2->id });
132
    $ret = $item_hold->set_pickup_location({ library_id => $library_2->id });
129
    is( ref($ret), 'Koha::Hold', 'self is returned' );
133
    is( ref($ret), 'Koha::Hold', 'self is returned' );
130
134
131
- 

Return to bug 28254