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

(-)a/C4/Circulation.pm (-5 / +13 lines)
Lines 252-263 sub decode { Link Here
252
252
253
=head2 transferbook
253
=head2 transferbook
254
254
255
  ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, 
255
  ($dotransfer, $messages, $iteminformation) = &transferbook({
256
                                            $barcode, $ignore_reserves);
256
                                                   from_branch => $frombranch
257
                                                   to_branch => $tobranch,
258
                                                   barcode => $barcode,
259
                                                   ignore_reserves => $ignore_reserves
260
                                                });
257
261
258
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
262
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
259
263
260
C<$newbranch> is the code for the branch to which the item should be transferred.
264
C<$fbr> is the code for the branch initiating the transfer.
265
C<$tbr> is the code for the branch to which the item should be transferred.
261
266
262
C<$barcode> is the barcode of the item to be transferred.
267
C<$barcode> is the barcode of the item to be transferred.
263
268
Lines 305-311 The item was eligible to be transferred. Barring problems communicating with the Link Here
305
=cut
310
=cut
306
311
307
sub transferbook {
312
sub transferbook {
308
    my ( $tbr, $barcode, $ignoreRs ) = @_;
313
    my $params = shift;
314
    my $tbr      = $params->{to_branch};
315
    my $fbr      = $params->{from_branch};
316
    my $ignoreRs = $params->{ignore_reserves};
317
    my $barcode  = $params->{barcode};
309
    my $messages;
318
    my $messages;
310
    my $dotransfer      = 1;
319
    my $dotransfer      = 1;
311
    my $item = Koha::Items->find( { barcode => $barcode } );
320
    my $item = Koha::Items->find( { barcode => $barcode } );
Lines 320-326 sub transferbook { Link Here
320
    my $issue = GetOpenIssue($itemnumber);
329
    my $issue = GetOpenIssue($itemnumber);
321
    # get branches of book...
330
    # get branches of book...
322
    my $hbr = $item->homebranch;
331
    my $hbr = $item->homebranch;
323
    my $fbr = $item->holdingbranch;
324
332
325
    # if using Branch Transfer Limits
333
    # if using Branch Transfer Limits
326
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
334
    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 2702-2708 subtest 'Set waiting flag' => sub { Link Here
2702
};
2702
};
2703
2703
2704
subtest 'Cancel transfers on lost items' => sub {
2704
subtest 'Cancel transfers on lost items' => sub {
2705
    plan tests => 5;
2705
    plan tests => 6;
2706
    my $library_1 = $builder->build( { source => 'Branch' } );
2706
    my $library_1 = $builder->build( { source => 'Branch' } );
2707
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2707
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2708
    my $library_2 = $builder->build( { source => 'Branch' } );
2708
    my $library_2 = $builder->build( { source => 'Branch' } );
Lines 2733-2747 subtest 'Cancel transfers on lost items' => sub { Link Here
2733
    my $do_transfer = 1;
2733
    my $do_transfer = 1;
2734
    my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} );
2734
    my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} );
2735
    ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id );
2735
    ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id );
2736
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} );
2736
    C4::Circulation::transferbook({
2737
        from_branch => $library_1->{branchcode},
2738
        to_branch => $library_2->{branchcode},
2739
        barcode   => $item->{barcode},
2740
    });
2737
    my $hold = Koha::Holds->find( $reserve_id );
2741
    my $hold = Koha::Holds->find( $reserve_id );
2738
    is( $hold->found, 'T', 'Hold is in transit' );
2742
    is( $hold->found, 'T', 'Hold is in transit' );
2739
2743
2740
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
2744
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
2741
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2745
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2742
    is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table');
2746
    is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library');
2747
    is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library');
2743
    my $itemcheck = Koha::Items->find($item->{itemnumber});
2748
    my $itemcheck = Koha::Items->find($item->{itemnumber});
2744
    is( $itemcheck->holdingbranch, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' );
2749
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' );
2745
2750
2746
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
2751
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
2747
    ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} );
2752
    ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} );
(-)a/t/db_dependent/Koha/Items.t (-2 / +5 lines)
Lines 73-79 subtest 'get_transfer' => sub { Link Here
73
73
74
    my $library_to = $builder->build( { source => 'Branch' } );
74
    my $library_to = $builder->build( { source => 'Branch' } );
75
75
76
    C4::Circulation::transferbook( $library_to->{branchcode}, $new_item_1->barcode );
76
    C4::Circulation::transferbook({
77
        from_branch => $new_item_1->holdingbranch,
78
        to_branch => $library_to->{branchcode},
79
        barcode => $new_item_1->barcode,
80
    });
77
81
78
    $transfer = $new_item_1->get_transfer();
82
    $transfer = $new_item_1->get_transfer();
79
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
83
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
80
- 

Return to bug 23695