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

(-)a/C4/Circulation.pm (-5 / +15 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, $trigger);
255
                                                   from_branch => $frombranch
256
                                                   to_branch => $tobranch,
257
                                                   barcode => $barcode,
258
                                                   ignore_reserves => $ignore_reserves,
259
                                                   trigger => $trigger
260
                                                });
256
261
257
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.
258
263
259
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.
260
266
261
C<$barcode> is the barcode of the item to be transferred.
267
C<$barcode> is the barcode of the item to be transferred.
262
268
Lines 306-312 The item was eligible to be transferred. Barring problems communicating with the Link Here
306
=cut
312
=cut
307
313
308
sub transferbook {
314
sub transferbook {
309
    my ( $tbr, $barcode, $ignoreRs, $trigger ) = @_;
315
    my $params = shift;
316
    my $tbr      = $params->{to_branch};
317
    my $fbr      = $params->{from_branch};
318
    my $ignoreRs = $params->{ignore_reserves};
319
    my $barcode  = $params->{barcode};
320
    my $trigger  = $params->{trigger};
310
    my $messages;
321
    my $messages;
311
    my $dotransfer      = 1;
322
    my $dotransfer      = 1;
312
    my $item = Koha::Items->find( { barcode => $barcode } );
323
    my $item = Koha::Items->find( { barcode => $barcode } );
Lines 321-327 sub transferbook { Link Here
321
    my $itemnumber = $item->itemnumber;
332
    my $itemnumber = $item->itemnumber;
322
    # get branches of book...
333
    # get branches of book...
323
    my $hbr = $item->homebranch;
334
    my $hbr = $item->homebranch;
324
    my $fbr = $item->holdingbranch;
325
335
326
    # if using Branch Transfer Limits
336
    # if using Branch Transfer Limits
327
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
337
    if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) {
(-)a/C4/RotatingCollections.pm (-1 / +7 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}, 1, 'RotatingCollection' ) 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
            trigger => 'RotatingCollection'
455
        }) unless ( $status eq 'Waiting' || @transfers );
450
    }
456
    }
451
457
452
    return 1;
458
    return 1;
(-)a/circ/branchtransfers.pl (-1 / +8 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, 'Manual' );
130
131
        transferbook({
132
            from_branch => C4::Context->userenv->{'branch'},
133
            to_branch => $tobranchcd,
134
            barcode => $barcode,
135
            ignore_reserves => $ignoreRs,
136
            trigger => 'Manual'
137
        });
131
    my $item = Koha::Items->find({ barcode => $barcode });
138
    my $item = Koha::Items->find({ barcode => $barcode });
132
    $found = $messages->{'ResFound'};
139
    $found = $messages->{'ResFound'};
133
    if ($transferred) {
140
    if ($transferred) {
(-)a/t/db_dependent/Circulation.t (-4 / +9 lines)
Lines 3244-3250 subtest 'Set waiting flag' => sub { Link Here
3244
};
3244
};
3245
3245
3246
subtest 'Cancel transfers on lost items' => sub {
3246
subtest 'Cancel transfers on lost items' => sub {
3247
    plan tests => 5;
3247
    plan tests => 6;
3248
    my $library_1 = $builder->build( { source => 'Branch' } );
3248
    my $library_1 = $builder->build( { source => 'Branch' } );
3249
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
3249
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
3250
    my $library_2 = $builder->build( { source => 'Branch' } );
3250
    my $library_2 = $builder->build( { source => 'Branch' } );
Lines 3271-3285 subtest 'Cancel transfers on lost items' => sub { Link Here
3271
    my $do_transfer = 1;
3271
    my $do_transfer = 1;
3272
    my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} );
3272
    my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} );
3273
    ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );
3273
    ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );
3274
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode );
3274
    C4::Circulation::transferbook({
3275
        from_branch => $library_1->{branchcode},
3276
        to_branch => $library_2->{branchcode},
3277
        barcode   => $item->barcode,
3278
    });
3275
    my $hold = Koha::Holds->find( $reserve_id );
3279
    my $hold = Koha::Holds->find( $reserve_id );
3276
    is( $hold->found, 'T', 'Hold is in transit' );
3280
    is( $hold->found, 'T', 'Hold is in transit' );
3277
3281
3278
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
3282
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
3279
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber);
3283
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber);
3280
    is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table');
3284
    is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library');
3285
    is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library');
3281
    my $itemcheck = Koha::Items->find($item->itemnumber);
3286
    my $itemcheck = Koha::Items->find($item->itemnumber);
3282
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origin branch before it is marked as lost' );
3287
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' );
3283
3288
3284
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
3289
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
3285
    $item->itemlost(1)->store;
3290
    $item->itemlost(1)->store;
(-)a/t/db_dependent/Koha/Items.t (-2 / +5 lines)
Lines 92-98 subtest 'get_transfer' => sub { Link Here
92
92
93
    my $library_to = $builder->build( { source => 'Branch' } );
93
    my $library_to = $builder->build( { source => 'Branch' } );
94
94
95
    C4::Circulation::transferbook( $library_to->{branchcode}, $new_item_1->barcode );
95
    C4::Circulation::transferbook({
96
        from_branch => $new_item_1->holdingbranch,
97
        to_branch => $library_to->{branchcode},
98
        barcode => $new_item_1->barcode,
99
    });
96
100
97
    $transfer = $new_item_1->get_transfer();
101
    $transfer = $new_item_1->get_transfer();
98
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
102
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
99
- 

Return to bug 23695