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

(-)a/C4/Circulation.pm (-16 / +2 lines)
Lines 3652-3673 This function validate the line of brachtransfer but with the wrong destination Link Here
3652
sub updateWrongTransfer {
3652
sub updateWrongTransfer {
3653
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3653
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3654
3654
3655
    # first step: cancel the original transfer
3655
    my $transfer = Koha::Items->find($itemNumber)->get_transfer;
3656
    my $item = Koha::Items->find($itemNumber);
3656
    my $new_transfer = $transfer->remedy();
3657
    my $transfer = $item->get_transfer;
3658
    $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store();
3659
3660
    # second step: create a new transfer to the right location
3661
    my $new_transfer = $item->request_transfer(
3662
        {
3663
            to            => $transfer->to_library,
3664
            reason        => $transfer->reason,
3665
            comment       => $transfer->comments,
3666
            ignore_limits => 1,
3667
            enqueue       => 1
3668
        }
3669
    );
3670
3671
    return $new_transfer;
3657
    return $new_transfer;
3672
}
3658
}
3673
3659
(-)a/Koha/Item/Transfer.pm (-1 / +46 lines)
Lines 171-176 sub cancel { Link Here
171
    return $self;
171
    return $self;
172
}
172
}
173
173
174
=head3 remedy
175
176
  my $new_transfer = $transfer->remedy(
177
    {
178
        to     => $to_library,
179
        reason => $reason,
180
        [ ignore_limits => 0, force => 0 ]
181
    }
182
  );
183
184
Used when a transfer has arrived at the wrong destination. Replaces this transfer by
185
cancelling it with the 'WrongTransfer' reason and sets up a new transfer.
186
187
FIXME: remedy or rectify
188
189
=cut
190
191
sub remedy {
192
    my ( $self, $params ) = @_;
193
194
    # FIXME: Should we remedy a transfer if it's just gone back to the originating branch, or just leave it in transit as is.
195
196
    # Cancel the existing wrong transfer
197
    $self->set(
198
        {
199
            datecancelled       => dt_from_string,
200
            cancellation_reason => 'WrongTransfer'
201
        }
202
    )->store();
203
204
    # Add a new transfer and immediately set to in transit (ignoring limits)
205
    my $new_transfer = Koha::Item::Transfer->new(
206
        {
207
            itemnumber    => $self->itemnumber,
208
            daterequested => dt_from_string,
209
            datesent      => undef,
210
            frombranch    => $self->item->holdingbranch,
211
            tobranch      => $self->tobranch,
212
            reason        => $self->reason,
213
            comments      => $self->comments
214
        }
215
    )->store();
216
217
    return $new_transfer;
218
}
219
174
=head3 type
220
=head3 type
175
221
176
=cut
222
=cut
177
- 

Return to bug 28294