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 / +53 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
        {
2187
            biblionumber => $biblio->biblionumber,
2188
        }
2189
    );
2190
    my $transfers = $item->_result->current_branchtransfers;
2191
    is( ref($transfers), 'DBIx::Class::ResultSet',
2192
        'current_branchtransfers returns a Koha::Item::Transfers object set' );
2193
    is( $transfers->count, 0,
2194
        "Empty Koha::Item::Transfers set returned if no return_claims" );
2195
    my $transfer1 = $builder->build(
2196
        {
2197
            source => 'Branchtransfer',
2198
            value  => {
2199
                itemnumber  => $item->itemnumber,
2200
                datearrived => dt_from_string,
2201
            }
2202
        }
2203
    );
2204
    my $transfer2 = $builder->build(
2205
        {
2206
            source => 'Branchtransfer',
2207
            value  => {
2208
                itemnumber    => $item->itemnumber,
2209
                datearrived   => undef,
2210
                datecancelled => dt_from_string,
2211
            }
2212
        }
2213
    );
2214
    my $transfer3 = $builder->build(
2215
        {
2216
            source => 'Branchtransfer',
2217
            value  => {
2218
                itemnumber    => $item->itemnumber,
2219
                datearrived   => undef,
2220
                datecancelled => undef,
2221
            }
2222
        }
2223
    );
2224
2225
    is( $item->_result->current_branchtransfers()->count,
2226
        1, "One transfer found for item" );
2227
2228
    $schema->storage->txn_rollback;
2229
};

Return to bug 33493