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

(-)a/C4/Circulation.pm (-13 / +18 lines)
Lines 2368-2383 sub AddReturn { Link Here
2368
            if ( $transfer->tobranch eq $branch ) {
2368
            if ( $transfer->tobranch eq $branch ) {
2369
                $transfer->receive;
2369
                $transfer->receive;
2370
                $messages->{'TransferArrived'} = $transfer->frombranch;
2370
                $messages->{'TransferArrived'} = $transfer->frombranch;
2371
2371
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2372
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2372
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2373
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2373
            }
2374
            } else {
2374
            else {
2375
                $messages->{'TransferTrigger'} = $transfer->reason;
2375
                $messages->{'TransferTrigger'} = $transfer->reason;
2376
                if ( $transfer->frombranch eq $branch ) {
2376
                if ( $transfer->frombranch eq $branch ) {
2377
                    $transfer->transit;
2377
                    $messages->{'TransferTo'}    = $transfer->tobranch;
2378
                    $messages->{'WasTransfered'}   = $transfer->tobranch;
2378
                    $messages->{'WasTransfered'} = $transfer->id;
2379
                }
2379
                } else {
2380
                else {
2381
                    $messages->{'WrongTransfer'}     = $transfer->tobranch;
2380
                    $messages->{'WrongTransfer'}     = $transfer->tobranch;
2382
                    $messages->{'WrongTransferItem'} = $item->itemnumber;
2381
                    $messages->{'WrongTransferItem'} = $item->itemnumber;
2383
                }
2382
                }
Lines 2527-2541 sub AddReturn { Link Here
2527
        and not $messages->{RecallNeedsTransfer} )
2526
        and not $messages->{RecallNeedsTransfer} )
2528
    {
2527
    {
2529
        my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode';
2528
        my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode';
2530
        if  (C4::Context->preference("AutomaticItemReturn"    ) or
2529
        if (
2531
            (C4::Context->preference("UseBranchTransferLimits") and
2530
            C4::Context->preference("AutomaticItemReturn")
2532
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType )
2531
            or ( C4::Context->preference("UseBranchTransferLimits")
2533
           )) {
2532
                and !IsBranchTransferAllowed( $branch, $returnbranch, $item->$BranchTransferLimitsType ) )
2534
            ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 });
2533
            )
2535
            $messages->{'WasTransfered'} = $returnbranch;
2534
        {
2535
            my $transfer = ModItemTransfer(
2536
                $item->itemnumber, $branch, $returnbranch, $transfer_trigger,
2537
                { skip_record_index => 1 }
2538
            );
2539
            $messages->{'TransferTo'}      = $returnbranch;
2540
            $messages->{'WasTransfered'}   = $transfer->id;
2536
            $messages->{'TransferTrigger'} = $transfer_trigger;
2541
            $messages->{'TransferTrigger'} = $transfer_trigger;
2537
        } else {
2542
        } else {
2538
            $messages->{'NeedsTransfer'} = $returnbranch;
2543
            $messages->{'NeedsTransfer'}   = $returnbranch;
2539
            $messages->{'TransferTrigger'} = $transfer_trigger;
2544
            $messages->{'TransferTrigger'} = $transfer_trigger;
2540
        }
2545
        }
2541
    }
2546
    }
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 386-392 sub ModItemTransfer { Link Here
386
        $transfer->transit({ skip_record_index => $params->{skip_record_index} });
386
        $transfer->transit({ skip_record_index => $params->{skip_record_index} });
387
    }
387
    }
388
388
389
    return;
389
    return $transfer;
390
}
390
}
391
391
392
=head2 ModDateLastSeen
392
=head2 ModDateLastSeen
(-)a/Koha/Item.pm (-4 / +12 lines)
Lines 799-806 we still expect the item to end up at a final location eventually. Link Here
799
sub get_transfer {
799
sub get_transfer {
800
    my ($self) = @_;
800
    my ($self) = @_;
801
801
802
    my $transfer = $self->_result->current_branchtransfers->next;
802
    my $transfers = $self->_result->current_branchtransfers->search(
803
    return  Koha::Item::Transfer->_new_from_dbic($transfer) if $transfer;
803
        undef,
804
        { 'order_by' => [ { '-desc' => 'datesent' }, { '-asc' => 'daterequested' } ] }
805
    );
806
807
    my $transfer = $transfers->next;
808
    return Koha::Item::Transfer->_new_from_dbic($transfer) if $transfer;
804
}
809
}
805
810
806
=head3 transfer
811
=head3 transfer
Lines 844-852 we still expect the item to end up at a final location eventually. Link Here
844
sub get_transfers {
849
sub get_transfers {
845
    my ($self) = @_;
850
    my ($self) = @_;
846
851
847
    my $transfer_rs = $self->_result->current_branchtransfers;
852
    my $transfers_rs = $self->_result->current_branchtransfers->search(
853
        undef,
854
        { 'order_by' => [ { '-desc' => 'datesent' }, { '-asc' => 'daterequested' } ] }
855
    );
848
856
849
    return Koha::Item::Transfers->_new_from_dbic($transfer_rs);
857
    return Koha::Item::Transfers->_new_from_dbic($transfers_rs);
850
}
858
}
851
859
852
=head3 last_returned_by
860
=head3 last_returned_by
(-)a/Koha/Schema/Result/Item.pm (-2 / +1 lines)
Lines 1057-1064 __PACKAGE__->has_many( Link Here
1057
            "$args->{foreign_alias}.datearrived"   => undef,
1057
            "$args->{foreign_alias}.datearrived"   => undef,
1058
            "$args->{foreign_alias}.datecancelled" => undef,
1058
            "$args->{foreign_alias}.datecancelled" => undef,
1059
        };
1059
        };
1060
    },
1060
    }
1061
    { order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ] }
1062
);
1061
);
1063
1062
1064
# Relationship with bundled items
1063
# Relationship with bundled items
(-)a/circ/returns.pl (+4 lines)
Lines 542-547 if ( $messages->{'WasTransfered'} ) { Link Here
542
    $template->param(
542
    $template->param(
543
        found          => 1,
543
        found          => 1,
544
        transfer       => $messages->{'WasTransfered'},
544
        transfer       => $messages->{'WasTransfered'},
545
        transferto     => $messages->{'TransferTo'},
545
        trigger        => $messages->{'TransferTrigger'},
546
        trigger        => $messages->{'TransferTrigger'},
546
        itemnumber     => $itemnumber,
547
        itemnumber     => $itemnumber,
547
    );
548
    );
Lines 720-725 foreach my $code ( keys %$messages ) { Link Here
720
    elsif ( $code eq 'WasTransfered' ) {
721
    elsif ( $code eq 'WasTransfered' ) {
721
        ;    # FIXME... anything to do here?
722
        ;    # FIXME... anything to do here?
722
    }
723
    }
724
    elsif ( $code eq 'TransferTo' ) {
725
        ;    # Handled above, along with WasTransfered
726
    }
723
    elsif ( $code eq 'withdrawn' ) {
727
    elsif ( $code eq 'withdrawn' ) {
724
        $err{withdrawn} = 1;
728
        $err{withdrawn} = 1;
725
    }
729
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc (-2 / +2 lines)
Lines 43-51 Link Here
43
    [% END %]
43
    [% END %]
44
[% END %]
44
[% END %]
45
45
46
[% IF ( item.notforloan || item.effective_itemtype.notforloan ) %]
46
[% IF ( item.is_notforloan ) %]
47
    [% SET itemavailable = 0 %]
47
    [% SET itemavailable = 0 %]
48
    [% SET notforloan = item.notforloan || item.effective_itemtype.notforloan %]
48
    [% SET notforloan = item.is_notforloan %]
49
    [% notforloan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => notforloan ) %]
49
    [% notforloan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => notforloan ) %]
50
    [% IF notforloan_description %]
50
    [% IF notforloan_description %]
51
        <span class="item-status notforloan">[% notforloan_description | html %]</span>
51
        <span class="item-status notforloan">[% notforloan_description | html %]</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-2 / +3 lines)
Lines 122-128 Link Here
122
                                </div> <!-- /.hold-auto-filled -->
122
                                </div> <!-- /.hold-auto-filled -->
123
                            [% END # /IF hold_auto_filled %]
123
                            [% END # /IF hold_auto_filled %]
124
124
125
                            [% IF ( trigger ) %]
125
                            [% IF ( trigger && !transfertodo ) %]
126
                                 <div id="transfer-trigger" class="dialog message">
126
                                 <div id="transfer-trigger" class="dialog message">
127
                                     <h3>Reason for transfer</h3>
127
                                     <h3>Reason for transfer</h3>
128
                                     <p>
128
                                     <p>
Lines 754-760 Link Here
754
754
755
                                                <div class="modal-header">
755
                                                <div class="modal-header">
756
                                                    <h3>
756
                                                    <h3>
757
                                                        Please return this item to [% IF transfer %][% Branches.GetName( transfer ) | html %][% ELSE %][% Branches.GetName( returnbranch ) | html %][% END %]
757
                                                        Please return this item to [% IF transferto %][% Branches.GetName( transferto ) | html %][% ELSE %][% Branches.GetName( returnbranch ) | html %][% END %]
758
                                                    </h3>
758
                                                    </h3>
759
                                                </div>
759
                                                </div>
760
                                                <div class="modal-body">
760
                                                <div class="modal-body">
Lines 781-786 Link Here
781
                                                        <button type="button" name="dotransfer" class="btn btn-default print openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;&amp;branchcode=[% returnbranch | uri %]&amp;op=slip"><i class="fa fa-print"></i> Yes, print slip</button>
781
                                                        <button type="button" name="dotransfer" class="btn btn-default print openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;&amp;branchcode=[% returnbranch | uri %]&amp;op=slip"><i class="fa fa-print"></i> Yes, print slip</button>
782
                                                        <button type="button" data-dismiss="modal" class="btn btn-default deny" name="notransfer" value="No" accesskey="n"><i class="fa fa-times"></i> No (N)</button>
782
                                                        <button type="button" data-dismiss="modal" class="btn btn-default deny" name="notransfer" value="No" accesskey="n"><i class="fa fa-times"></i> No (N)</button>
783
                                                    [% ELSE %]
783
                                                    [% ELSE %]
784
                                                        <input type="hidden" name="transit" value="[% transfer | uri %]"/>
784
                                                        <button type="button" data-dismiss="modal" class="btn btn-default" accesskey="y"><i class="fa fa-check"></i> OK (Y)</button>
785
                                                        <button type="button" data-dismiss="modal" class="btn btn-default" accesskey="y"><i class="fa fa-check"></i> OK (Y)</button>
785
                                                        <button type="button" data-dismiss="modal" class="btn btn-default openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;branchcode=[% transfer | uri %]&amp;op=slip" accesskey="p"><i class="fa fa-print"></i> Print slip (P)</button>
786
                                                        <button type="button" data-dismiss="modal" class="btn btn-default openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;branchcode=[% transfer | uri %]&amp;op=slip" accesskey="p"><i class="fa fa-print"></i> Print slip (P)</button>
786
                                                    [% END %]
787
                                                    [% END %]
(-)a/t/db_dependent/Circulation.t (-10 / +25 lines)
Lines 6654-6677 subtest 'Tests for transfer not in transit' => sub { Link Here
6654
6654
6655
    plan tests => 2;
6655
    plan tests => 2;
6656
6656
6657
6658
    # These tests are to ensure a 'pending' transfer, generated by
6657
    # These tests are to ensure a 'pending' transfer, generated by
6659
    # stock rotation, will be advanced when checked in
6658
    # stock rotation, will be advanced when checked in
6660
6659
6661
    my $item = $builder->build_sample_item();
6660
    my $item     = $builder->build_sample_item();
6662
    my $transfer = $builder->build_object({ class => 'Koha::Item::Transfers', value => {
6661
    my $transfer = $builder->build_object(
6663
        itemnumber => $item->id,
6662
        {
6664
        reason => 'StockrotationRepatriation',
6663
            class => 'Koha::Item::Transfers',
6665
        datesent => undef,
6664
            value => {
6666
        frombranch => $item->homebranch,
6665
                itemnumber => $item->id,
6667
    }});
6666
                reason     => 'StockrotationRepatriation',
6667
                datesent   => undef,
6668
                frombranch => $item->homebranch,
6669
            }
6670
        }
6671
    );
6668
    my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6672
    my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6669
    is_deeply(
6673
    is_deeply(
6670
        \@return,
6674
        \@return,
6671
        [ 0, { WasTransfered => $transfer->tobranch, TransferTrigger => 'StockrotationRepatriation', NotIssued => $item->barcode }, undef, {} ], "Item is reported to have been transferred");
6675
        [
6676
            0,
6677
            {
6678
                TransferTo      => $transfer->tobranch, WasTransfered => $transfer->id,
6679
                TransferTrigger => 'StockrotationRepatriation',
6680
                NotIssued       => $item->barcode
6681
            },
6682
            undef,
6683
            {}
6684
        ],
6685
        "Item is reported to have been transferred"
6686
    );
6672
6687
6673
    $transfer->discard_changes;
6688
    $transfer->discard_changes;
6674
    ok( $transfer->datesent, 'The datesent field is populated, i.e. transfer is initiated');
6689
    is( $transfer->datesent, undef, 'The datesent field remains unpopulated, i.e. transfer is not yet initiated' );
6675
6690
6676
};
6691
};
6677
6692
(-)a/t/db_dependent/Koha/Item.t (-3 / +249 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
21
use utf8;
22
22
23
use Test::More tests => 35;
23
use Test::More tests => 36;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 1225-1232 subtest 'Tests for itemtype|item_type' => sub { Link Here
1225
    $schema->storage->txn_rollback;
1225
    $schema->storage->txn_rollback;
1226
};
1226
};
1227
1227
1228
subtest 'get_transfer' => sub {
1229
    plan tests => 8;
1230
    $schema->storage->txn_begin;
1231
1232
    my $item = $builder->build_sample_item();
1233
1234
    my $transfer = $item->get_transfer();
1235
    is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item has no queued transfers' );
1236
1237
    my $library_to = $builder->build( { source => 'Branch' } );
1238
1239
    my $transfer_1 = $builder->build_object(
1240
        {
1241
            class => 'Koha::Item::Transfers',
1242
            value => {
1243
                itemnumber    => $item->itemnumber,
1244
                frombranch    => $item->holdingbranch,
1245
                tobranch      => $library_to->{branchcode},
1246
                reason        => 'Manual',
1247
                datesent      => undef,
1248
                datearrived   => undef,
1249
                datecancelled => undef,
1250
                daterequested => \'NOW()'
1251
            }
1252
        }
1253
    );
1254
1255
    $transfer = $item->get_transfer();
1256
    is(
1257
        ref($transfer), 'Koha::Item::Transfer',
1258
        'Koha::Item->get_transfer should return a Koha::Item::Transfer object'
1259
    );
1260
1261
    my $transfer_2 = $builder->build_object(
1262
        {
1263
            class => 'Koha::Item::Transfers',
1264
            value => {
1265
                itemnumber    => $item->itemnumber,
1266
                frombranch    => $item->holdingbranch,
1267
                tobranch      => $library_to->{branchcode},
1268
                reason        => 'Manual',
1269
                datesent      => undef,
1270
                datearrived   => undef,
1271
                datecancelled => undef,
1272
                daterequested => \'NOW()'
1273
            }
1274
        }
1275
    );
1276
1277
    $transfer = $item->get_transfer();
1278
    is(
1279
        $transfer->branchtransfer_id, $transfer_1->branchtransfer_id,
1280
        'Koha::Item->get_transfer returns the oldest transfer request'
1281
    );
1282
1283
    $transfer_2->datesent( \'NOW()' )->store;
1284
    $transfer = $item->get_transfer();
1285
    is(
1286
        $transfer->branchtransfer_id, $transfer_2->branchtransfer_id,
1287
        'Koha::Item->get_transfer returns the in_transit transfer'
1288
    );
1289
1290
    my $transfer_3 = $builder->build_object(
1291
        {
1292
            class => 'Koha::Item::Transfers',
1293
            value => {
1294
                itemnumber    => $item->itemnumber,
1295
                frombranch    => $item->holdingbranch,
1296
                tobranch      => $library_to->{branchcode},
1297
                reason        => 'Manual',
1298
                datesent      => undef,
1299
                datearrived   => undef,
1300
                datecancelled => undef,
1301
                daterequested => \'NOW()'
1302
            }
1303
        }
1304
    );
1305
1306
    $transfer_2->datearrived( \'NOW()' )->store;
1307
    $transfer = $item->get_transfer();
1308
    is(
1309
        $transfer->branchtransfer_id, $transfer_1->branchtransfer_id,
1310
        'Koha::Item->get_transfer returns the next queued transfer'
1311
    );
1312
    is( $transfer->itemnumber, $item->itemnumber, 'Koha::Item->get_transfer returns the right items transfer' );
1313
1314
    $transfer_1->datecancelled( \'NOW()' )->store;
1315
    $transfer = $item->get_transfer();
1316
    is(
1317
        $transfer->branchtransfer_id, $transfer_3->branchtransfer_id,
1318
        'Koha::Item->get_transfer ignores cancelled transfers'
1319
    );
1320
1321
    subtest "Ensure prefetches don't affect which transfer if returned" => sub {
1322
        plan tests => 5;
1323
1324
        # Reset test data
1325
        $transfer_1->datecancelled(undef)->store;
1326
        $transfer_2->set( { datesent => undef, datearrived => undef } )->store;
1327
1328
        my $prefetched_item = Koha::Items->search(
1329
            { 'me.itemnumber' => $item->itemnumber },
1330
            { prefetch        => ['current_branchtransfers'] }
1331
        )->next;
1332
1333
        $transfer = $prefetched_item->get_transfer();
1334
        is(
1335
            $transfer->branchtransfer_id, $transfer_1->branchtransfer_id,
1336
            'Koha::Item->get_transfer returns the oldest transfer request'
1337
        );
1338
1339
        $transfer_2->datesent( \'NOW()' )->store;
1340
        $prefetched_item = Koha::Items->search(
1341
            { 'me.itemnumber' => $item->itemnumber },
1342
            { prefetch        => ['current_branchtransfers'] }
1343
        )->next;
1344
1345
        $transfer = $prefetched_item->get_transfer();
1346
        is(
1347
            $transfer->branchtransfer_id, $transfer_2->branchtransfer_id,
1348
            'Koha::Item->get_transfer returns the in_transit transfer'
1349
        );
1350
1351
        $transfer_2->datearrived( \'NOW()' )->store;
1352
        $prefetched_item = Koha::Items->search(
1353
            { 'me.itemnumber' => $item->itemnumber },
1354
            { prefetch        => ['current_branchtransfers'] }
1355
        )->next;
1356
        $transfer = $prefetched_item->get_transfer();
1357
        is(
1358
            $transfer->branchtransfer_id, $transfer_1->branchtransfer_id,
1359
            'Koha::Item->get_transfer returns the next queued transfer'
1360
        );
1361
        is( $transfer->itemnumber, $item->itemnumber, 'Koha::Item->get_transfer returns the right items transfer' );
1362
1363
        $transfer_1->datecancelled( \'NOW()' )->store;
1364
        $prefetched_item = Koha::Items->search(
1365
            { 'me.itemnumber' => $item->itemnumber },
1366
            { prefetch        => ['current_branchtransfers'] }
1367
        )->next;
1368
        $transfer = $prefetched_item->get_transfer();
1369
        is(
1370
            $transfer->branchtransfer_id, $transfer_3->branchtransfer_id,
1371
            'Koha::Item->get_transfer ignores cancelled transfers'
1372
        );
1373
    };
1374
    $schema->storage->txn_rollback;
1375
};
1376
1228
subtest 'get_transfers' => sub {
1377
subtest 'get_transfers' => sub {
1229
    plan tests => 16;
1378
    plan tests => 17;
1230
    $schema->storage->txn_begin;
1379
    $schema->storage->txn_begin;
1231
1380
1232
    my $item = $builder->build_sample_item();
1381
    my $item = $builder->build_sample_item();
Lines 1321-1326 subtest 'get_transfers' => sub { Link Here
1321
    $result_1 = $transfers->next;
1470
    $result_1 = $transfers->next;
1322
    is( $result_1->branchtransfer_id, $transfer_3->branchtransfer_id, 'Koha::Item->get_transfers returns the only transfer that remains');
1471
    is( $result_1->branchtransfer_id, $transfer_3->branchtransfer_id, 'Koha::Item->get_transfers returns the only transfer that remains');
1323
1472
1473
    subtest "Ensure prefetches don't affect the return order" => sub {
1474
        plan tests => 13;
1475
1476
        # Reset test data
1477
        $transfer_2->datesent(undef)->store;
1478
        $transfer_2->datearrived(undef)->store;
1479
        $transfer_1->datecancelled(undef)->store;
1480
1481
        my $prefetched_item = Koha::Items->search(
1482
            { 'me.itemnumber' => $item->itemnumber },
1483
            { prefetch        => ['current_branchtransfers'] }
1484
        )->next;
1485
1486
        $transfers = $prefetched_item->get_transfers();
1487
        is(
1488
            $transfers->count, 3,
1489
            'When there are multiple open transfer requests, the Koha::Item::Transfers object contains them all'
1490
        );
1491
        $result_1 = $transfers->next;
1492
        $result_2 = $transfers->next;
1493
        $result_3 = $transfers->next;
1494
        is(
1495
            $result_1->branchtransfer_id, $transfer_1->branchtransfer_id,
1496
            'Koha::Item->get_transfers returns the oldest transfer request first'
1497
        );
1498
        is(
1499
            $result_2->branchtransfer_id, $transfer_2->branchtransfer_id,
1500
            'Koha::Item->get_transfers returns the newer transfer request second'
1501
        );
1502
        is(
1503
            $result_3->branchtransfer_id, $transfer_3->branchtransfer_id,
1504
            'Koha::Item->get_transfers returns the newest transfer request last'
1505
        );
1506
1507
        $transfer_2->datesent( \'NOW()' )->store;
1508
        $prefetched_item = Koha::Items->search(
1509
            { 'me.itemnumber' => $item->itemnumber },
1510
            { prefetch        => ['current_branchtransfers'] }
1511
        )->next;
1512
        $transfers = $prefetched_item->get_transfers();
1513
        is(
1514
            $transfers->count, 3,
1515
            'When one transfer is set to in_transit, the Koha::Item::Transfers object still contains them all'
1516
        );
1517
        $result_1 = $transfers->next;
1518
        $result_2 = $transfers->next;
1519
        $result_3 = $transfers->next;
1520
        is(
1521
            $result_1->branchtransfer_id, $transfer_2->branchtransfer_id,
1522
            'Koha::Item->get_transfers returns the active transfer request first'
1523
        );
1524
        is(
1525
            $result_2->branchtransfer_id, $transfer_1->branchtransfer_id,
1526
            'Koha::Item->get_transfers returns the other transfers oldest to newest'
1527
        );
1528
        is(
1529
            $result_3->branchtransfer_id, $transfer_3->branchtransfer_id,
1530
            'Koha::Item->get_transfers returns the other transfers oldest to newest'
1531
        );
1532
1533
        $transfer_2->datearrived( \'NOW()' )->store;
1534
        $prefetched_item = Koha::Items->search(
1535
            { 'me.itemnumber' => $item->itemnumber },
1536
            { prefetch        => ['current_branchtransfers'] }
1537
        )->next;
1538
        $transfers = $prefetched_item->get_transfers();
1539
        is(
1540
            $transfers->count, 2,
1541
            'Once a transfer is received, it no longer appears in the list from ->get_transfers()'
1542
        );
1543
        $result_1 = $transfers->next;
1544
        $result_2 = $transfers->next;
1545
        is(
1546
            $result_1->branchtransfer_id, $transfer_1->branchtransfer_id,
1547
            'Koha::Item->get_transfers returns the other transfers oldest to newest'
1548
        );
1549
        is(
1550
            $result_2->branchtransfer_id, $transfer_3->branchtransfer_id,
1551
            'Koha::Item->get_transfers returns the other transfers oldest to newest'
1552
        );
1553
1554
        $transfer_1->datecancelled( \'NOW()' )->store;
1555
        $prefetched_item = Koha::Items->search(
1556
            { 'me.itemnumber' => $item->itemnumber },
1557
            { prefetch        => ['current_branchtransfers'] }
1558
        )->next;
1559
        $transfers = $prefetched_item->get_transfers();
1560
        is(
1561
            $transfers->count, 1,
1562
            'Once a transfer is cancelled, it no longer appears in the list from ->get_transfers()'
1563
        );
1564
        $result_1 = $transfers->next;
1565
        is(
1566
            $result_1->branchtransfer_id, $transfer_3->branchtransfer_id,
1567
            'Koha::Item->get_transfers returns the only transfer that remains'
1568
        );
1569
    };
1570
1324
    $schema->storage->txn_rollback;
1571
    $schema->storage->txn_rollback;
1325
};
1572
};
1326
1573
1327
- 

Return to bug 35100