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

(-)a/C4/Circulation.pm (-16 / +2 lines)
Lines 3817-3838 This function validate the line of brachtransfer but with the wrong destination Link Here
3817
sub updateWrongTransfer {
3817
sub updateWrongTransfer {
3818
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3818
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3819
3819
3820
    # first step: cancel the original transfer
3820
    my $transfer = Koha::Items->find($itemNumber)->get_transfer;
3821
    my $item = Koha::Items->find($itemNumber);
3821
    my $new_transfer = $transfer->remedy();
3822
    my $transfer = $item->get_transfer;
3823
    $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store();
3824
3825
    # second step: create a new transfer to the right location
3826
    my $new_transfer = $item->request_transfer(
3827
        {
3828
            to            => $transfer->to_library,
3829
            reason        => $transfer->reason,
3830
            comment       => $transfer->comments,
3831
            ignore_limits => 1,
3832
            enqueue       => 1
3833
        }
3834
    );
3835
3836
    return $new_transfer;
3822
    return $new_transfer;
3837
}
3823
}
3838
3824
(-)a/Koha/Item/Transfer.pm (-1 / +46 lines)
Lines 176-181 sub cancel { Link Here
176
    return $self;
176
    return $self;
177
}
177
}
178
178
179
=head3 remedy
180
181
  my $new_transfer = $transfer->remedy(
182
    {
183
        to     => $to_library,
184
        reason => $reason,
185
        [ ignore_limits => 0, force => 0 ]
186
    }
187
  );
188
189
Used when a transfer has arrived at the wrong destination. Replaces this transfer by
190
cancelling it with the 'WrongTransfer' reason and sets up a new transfer.
191
192
FIXME: remedy or rectify
193
194
=cut
195
196
sub remedy {
197
    my ( $self, $params ) = @_;
198
199
    # FIXME: Should we remedy a transfer if it's just gone back to the originating branch, or just leave it in transit as is.
200
201
    # Cancel the existing wrong transfer
202
    $self->set(
203
        {
204
            datecancelled       => dt_from_string,
205
            cancellation_reason => 'WrongTransfer'
206
        }
207
    )->store();
208
209
    # Add a new transfer and immediately set to in transit (ignoring limits)
210
    my $new_transfer = Koha::Item::Transfer->new(
211
        {
212
            itemnumber    => $self->itemnumber,
213
            daterequested => dt_from_string,
214
            datesent      => undef,
215
            frombranch    => $self->item->holdingbranch,
216
            tobranch      => $self->tobranch,
217
            reason        => $self->reason,
218
            comments      => $self->comments
219
        }
220
    )->store();
221
222
    return $new_transfer;
223
}
224
179
=head3 type
225
=head3 type
180
226
181
=cut
227
=cut
182
- 

Return to bug 28294