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

(-)a/C4/Circulation.pm (-5 / +13 lines)
Lines 250-261 sub decode { Link Here
250
250
251
=head2 transferbook
251
=head2 transferbook
252
252
253
  ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, 
253
  ($dotransfer, $messages, $iteminformation) = &transferbook({
254
                                            $barcode, $ignore_reserves);
254
                                                   from_branch => $frombranch
255
                                                   to_branch => $tobranch,
256
                                                   barcode => $barcode,
257
                                                   ignore_reserves => $ignore_reserves
258
                                                });
255
259
256
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
260
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
257
261
258
C<$newbranch> is the code for the branch to which the item should be transferred.
262
C<$fbr> is the code for the branch initiating the transfer.
263
C<$tbr> is the code for the branch to which the item should be transferred.
259
264
260
C<$barcode> is the barcode of the item to be transferred.
265
C<$barcode> is the barcode of the item to be transferred.
261
266
Lines 303-309 The item was eligible to be transferred. Barring problems communicating with the Link Here
303
=cut
308
=cut
304
309
305
sub transferbook {
310
sub transferbook {
306
    my ( $tbr, $barcode, $ignoreRs ) = @_;
311
    my $params = shift;
312
    my $tbr      = $params->{to_branch};
313
    my $fbr      = $params->{from_branch};
314
    my $ignoreRs = $params->{ignore_reserves};
315
    my $barcode  = $params->{barcode};
307
    my $messages;
316
    my $messages;
308
    my $dotransfer      = 1;
317
    my $dotransfer      = 1;
309
    my $item = Koha::Items->find( { barcode => $barcode } );
318
    my $item = Koha::Items->find( { barcode => $barcode } );
Lines 318-324 sub transferbook { Link Here
318
    my $itemnumber = $item->itemnumber;
327
    my $itemnumber = $item->itemnumber;
319
    # get branches of book...
328
    # get branches of book...
320
    my $hbr = $item->homebranch;
329
    my $hbr = $item->homebranch;
321
    my $fbr = $item->holdingbranch;
322
330
323
    # if using Branch Transfer Limits
331
    # if using Branch Transfer Limits
324
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
332
    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