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

(-)a/Koha/Item.pm (-2 / +2 lines)
Lines 565-571 we still expect the item to end up at a final location eventually. Link Here
565
sub get_transfer {
565
sub get_transfer {
566
    my ($self) = @_;
566
    my ($self) = @_;
567
567
568
    my $transfer = $self->_result->branchtransfer;
568
    my $transfer = $self->_result->current_branchtransfers;
569
569
570
    return Koha::Item::Transfers->_new_from_dbic($transfer)->next;
570
    return Koha::Item::Transfers->_new_from_dbic($transfer)->next;
571
}
571
}
Lines 590-596 we still expect the item to end up at a final location eventually. Link Here
590
sub get_transfers {
590
sub get_transfers {
591
    my ($self) = @_;
591
    my ($self) = @_;
592
592
593
    my $transfer_rs = $self->_result->branchtransfer;
593
    my $transfer_rs = $self->_result->current_branchtransfers;
594
594
595
    return Koha::Item::Transfers->_new_from_dbic($transfer_rs);
595
    return Koha::Item::Transfers->_new_from_dbic($transfer_rs);
596
}
596
}
(-)a/Koha/Schema/Result/Item.pm (-1 / +1 lines)
Lines 973-979 __PACKAGE__->many_to_many( Link Here
973
);
973
);
974
974
975
__PACKAGE__->has_many(
975
__PACKAGE__->has_many(
976
  "branchtransfer",
976
  "current_branchtransfers",
977
  "Koha::Schema::Result::Branchtransfer",
977
  "Koha::Schema::Result::Branchtransfer",
978
  { 'foreign.itemnumber' => 'self.itemnumber' },
978
  { 'foreign.itemnumber' => 'self.itemnumber' },
979
  {
979
  {
(-)a/t/db_dependent/Koha/Item.t (-2 / +33 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 => 28;
23
use Test::More tests => 29;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 2175-2177 subtest 'is_denied_renewal' => sub { Link Here
2175
2175
2176
    $schema->storage->txn_rollback;
2176
    $schema->storage->txn_rollback;
2177
};
2177
};
2178
- 
2178
2179
subtest 'current_branchtransfers relationship' => sub {
2180
    plan tests => 3;
2181
2182
    $schema->storage->txn_begin;
2183
2184
    my $biblio = $builder->build_sample_biblio();
2185
    my $item   = $builder->build_sample_item({
2186
        biblionumber => $biblio->biblionumber,
2187
    });
2188
    my $transfers = $item->_result->current_branchtransfers;
2189
    is( ref($transfers), 'DBIx::Class::ResultSet', 'current_branchtransfers returns a Koha::Item::Transfers object set' );
2190
    is($transfers->count, 0, "Empty Koha::Item::Transfers set returned if no return_claims");
2191
    my $transfer1 = $builder->build({ source => 'Branchtransfer', value => {
2192
        itemnumber => $item->itemnumber,
2193
        datearrived => dt_from_string,
2194
    }});
2195
    my $transfer2 = $builder->build({ source => 'Branchtransfer', value => {
2196
        itemnumber => $item->itemnumber,
2197
        datearrived => undef,
2198
        datecancelled => dt_from_string,
2199
    }});
2200
    my $transfer3 = $builder->build({ source => 'Branchtransfer', value => {
2201
        itemnumber => $item->itemnumber,
2202
        datearrived => undef,
2203
        datecancelled => undef,
2204
    }});
2205
2206
    is($item->_result->current_branchtransfers()->count, 1, "One transfer found for item");
2207
2208
    $schema->storage->txn_rollback;
2209
};

Return to bug 33493