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

(-)a/C4/Circulation.pm (-5 / +13 lines)
Lines 251-262 sub decode { Link Here
251
251
252
=head2 transferbook
252
=head2 transferbook
253
253
254
  ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, 
254
  ($dotransfer, $messages, $iteminformation) = &transferbook({
255
                                            $barcode, $ignore_reserves);
255
                                                   from_branch => $frombranch
256
                                                   to_branch => $tobranch,
257
                                                   barcode => $barcode,
258
                                                   ignore_reserves => $ignore_reserves
259
                                                });
256
260
257
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
261
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
258
262
259
C<$newbranch> is the code for the branch to which the item should be transferred.
263
C<$fbr> is the code for the branch initiating the transfer.
264
C<$tbr> is the code for the branch to which the item should be transferred.
260
265
261
C<$barcode> is the barcode of the item to be transferred.
266
C<$barcode> is the barcode of the item to be transferred.
262
267
Lines 304-310 The item was eligible to be transferred. Barring problems communicating with the Link Here
304
=cut
309
=cut
305
310
306
sub transferbook {
311
sub transferbook {
307
    my ( $tbr, $barcode, $ignoreRs ) = @_;
312
    my $params = shift;
313
    my $tbr      = $params->{to_branch};
314
    my $fbr      = $params->{from_branch};
315
    my $ignoreRs = $params->{ignore_reserves};
316
    my $barcode  = $params->{barcode};
308
    my $messages;
317
    my $messages;
309
    my $dotransfer      = 1;
318
    my $dotransfer      = 1;
310
    my $item = Koha::Items->find( { barcode => $barcode } );
319
    my $item = Koha::Items->find( { barcode => $barcode } );
Lines 319-325 sub transferbook { Link Here
319
    my $itemnumber = $item->itemnumber;
328
    my $itemnumber = $item->itemnumber;
320
    # get branches of book...
329
    # get branches of book...
321
    my $hbr = $item->homebranch;
330
    my $hbr = $item->homebranch;
322
    my $fbr = $item->holdingbranch;
323
331
324
    # if using Branch Transfer Limits
332
    # if using Branch Transfer Limits
325
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
333
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
(-)a/C4/RotatingCollections.pm (-1 / +6 lines)
Lines 446-452 sub TransferCollection { Link Here
446
    while ( my $item = $sth->fetchrow_hashref ) {
446
    while ( my $item = $sth->fetchrow_hashref ) {
447
        my ($status) = CheckReserves( $item->{itemnumber} );
447
        my ($status) = CheckReserves( $item->{itemnumber} );
448
        my @transfers = C4::Circulation::GetTransfers( $item->{itemnumber} );
448
        my @transfers = C4::Circulation::GetTransfers( $item->{itemnumber} );
449
        C4::Circulation::transferbook( $colBranchcode, $item->{barcode}, my $ignore_reserves = 1 ) unless ( $status eq 'Waiting' || @transfers );
449
        C4::Circulation::transferbook({
450
            from_branch => $item->holdingbranch,
451
            to_branch => $colBranchcode,
452
            barcode => $item->{barcode},
453
            ignore_reserves => 1
454
        }) unless ( $status eq 'Waiting' || @transfers );
450
    }
455
    }
451
456
452
    return 1;
457
    return 1;
(-)a/circ/branchtransfers.pl (-1 / +6 lines)
Lines 127-133 defined $barcode and $barcode =~ s/^\s*|\s*$//g; # FIXME: barcodeInputFilter Link Here
127
if ($barcode) {
127
if ($barcode) {
128
128
129
    ( $transferred, $messages ) =
129
    ( $transferred, $messages ) =
130
      transferbook( $tobranchcd, $barcode, $ignoreRs );
130
        transferbook({
131
            from_branch => C4::Context->userenv->{'branch'},
132
            to_branch => $tobranchcd,
133
            barcode => $barcode,
134
            ignore_reserves => $ignoreRs
135
        });
131
    my $item = Koha::Items->find({ barcode => $barcode });
136
    my $item = Koha::Items->find({ barcode => $barcode });
132
    $found = $messages->{'ResFound'};
137
    $found = $messages->{'ResFound'};
133
    if ($transferred) {
138
    if ($transferred) {
(-)a/t/db_dependent/Circulation.t (-4 / +9 lines)
Lines 2966-2972 subtest 'Set waiting flag' => sub { Link Here
2966
};
2966
};
2967
2967
2968
subtest 'Cancel transfers on lost items' => sub {
2968
subtest 'Cancel transfers on lost items' => sub {
2969
    plan tests => 5;
2969
    plan tests => 6;
2970
    my $library_1 = $builder->build( { source => 'Branch' } );
2970
    my $library_1 = $builder->build( { source => 'Branch' } );
2971
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2971
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2972
    my $library_2 = $builder->build( { source => 'Branch' } );
2972
    my $library_2 = $builder->build( { source => 'Branch' } );
Lines 2993-3007 subtest 'Cancel transfers on lost items' => sub { Link Here
2993
    my $do_transfer = 1;
2993
    my $do_transfer = 1;
2994
    my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} );
2994
    my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} );
2995
    ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );
2995
    ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );
2996
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode );
2996
    C4::Circulation::transferbook({
2997
        from_branch => $library_1->{branchcode},
2998
        to_branch => $library_2->{branchcode},
2999
        barcode   => $item->barcode,
3000
    });
2997
    my $hold = Koha::Holds->find( $reserve_id );
3001
    my $hold = Koha::Holds->find( $reserve_id );
2998
    is( $hold->found, 'T', 'Hold is in transit' );
3002
    is( $hold->found, 'T', 'Hold is in transit' );
2999
3003
3000
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
3004
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
3001
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber);
3005
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber);
3002
    is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table');
3006
    is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library');
3007
    is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library');
3003
    my $itemcheck = Koha::Items->find($item->itemnumber);
3008
    my $itemcheck = Koha::Items->find($item->itemnumber);
3004
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origin branch before it is marked as lost' );
3009
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' );
3005
3010
3006
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
3011
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
3007
    ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber );
3012
    ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber );
(-)a/t/db_dependent/Koha/Items.t (-2 / +5 lines)
Lines 69-75 subtest 'get_transfer' => sub { Link Here
69
69
70
    my $library_to = $builder->build( { source => 'Branch' } );
70
    my $library_to = $builder->build( { source => 'Branch' } );
71
71
72
    C4::Circulation::transferbook( $library_to->{branchcode}, $new_item_1->barcode );
72
    C4::Circulation::transferbook({
73
        from_branch => $new_item_1->holdingbranch,
74
        to_branch => $library_to->{branchcode},
75
        barcode => $new_item_1->barcode,
76
    });
73
77
74
    $transfer = $new_item_1->get_transfer();
78
    $transfer = $new_item_1->get_transfer();
75
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
79
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
76
- 

Return to bug 23695