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

(-)a/C4/Circulation.pm (-10 / +4 lines)
Lines 3591-3609 This function validate the line of brachtransfer but with the wrong destination Link Here
3591
sub updateWrongTransfer {
3591
sub updateWrongTransfer {
3592
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3592
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3593
3593
3594
    # first step: cancel the original transfer
3594
    my $transfer = Koha::Items->find($itemNumber)->get_transfer;
3595
    my $item = Koha::Items->find($itemNumber);
3595
    my $new_transfer = $transfer->replace(
3596
    my $transfer = $item->get_transfer;
3597
    $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store();
3598
3599
    # second step: create a new transfer to the right location
3600
    my $new_transfer = $item->request_transfer(
3601
        {
3596
        {
3602
            to            => $transfer->to_library,
3597
            to            => $transfer->to_library,
3603
            reason        => $transfer->reason,
3598
            reason        => 'WrongTransfer',
3604
            comment       => $transfer->comments,
3605
            ignore_limits => 1,
3599
            ignore_limits => 1,
3606
            enqueue       => 1
3600
            force         => 1
3607
        }
3601
        }
3608
    );
3602
    );
3609
3603
(-)a/Koha/Item/Transfer.pm (-1 / +39 lines)
Lines 186-191 sub cancel { Link Here
186
    return $self;
186
    return $self;
187
}
187
}
188
188
189
=head3 replace
190
191
  my $new_transfer = $transfer->replace(
192
    {
193
        to     => $to_library,
194
        reason => $reason,
195
        [ ignore_limits => 0, force => 0 ]
196
    }
197
  );
198
199
Replace this transfer by cancelling it and setting up a new transfer request.
200
201
=cut
202
203
sub replace {
204
    my ( $self, $params ) = @_;
205
206
    Koha::Exceptions::MissingParameter->throw(
207
        error => "The 'reason' parameter is mandatory" )
208
      unless defined($params->{reason});
209
210
    my $in_transit = $self->in_transit;
211
212
    # Throw exception if item is in transit already
213
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $in_transit );
214
215
    my $new_transfer = $self->item->request_transfer(
216
        {
217
            to            => $self->to_library,
218
            reason        => $params->{'reason'},
219
            ignore_limits => $params->{'ignore_limits'},
220
            force         => $params->{'force'},
221
            replace       => 1
222
        }
223
    );
224
225
    return $new_transfer;
226
}
227
189
=head3 type
228
=head3 type
190
229
191
=cut
230
=cut
192
- 

Return to bug 28294