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

(-)a/Koha/Item.pm (+17 lines)
Lines 126-131 sub checkout { Link Here
126
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
126
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
127
}
127
}
128
128
129
=head3 holds
130
131
my $transfer = $item->holds();
132
my $transfer = $item->holds($params);
133
my $transfer = $item->holds({ found => 'W'});
134
135
Return reserves attached to an item, optionally accept a hashref of params to pass to search
136
137
=cut
138
139
sub holds {
140
    my ( $self,$params ) = @_;
141
    my $transfer_rs = $self->_result->reserves->search($params);
142
    return unless $transfer_rs->count;
143
    return Koha::Holds->_new_from_dbic( $transfer_rs );
144
}
145
129
=head3 get_transfer
146
=head3 get_transfer
130
147
131
my $transfer = $item->get_transfer;
148
my $transfer = $item->get_transfer;
(-)a/t/db_dependent/Koha/Items.t (-2 / +20 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 9;
22
use Test::More tests => 10;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use C4::Circulation;
25
use C4::Circulation;
Lines 81-86 subtest 'get_transfer' => sub { Link Here
81
    is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' );
81
    is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' );
82
};
82
};
83
83
84
subtest 'holds' => sub {
85
    plan tests => 5;
86
87
    my $biblio = $builder->build_sample_biblio();
88
    my $item   = $builder->build_sample_item({
89
        biblionumber => $biblio->biblionumber,
90
    });
91
    $nb_of_items++;
92
    is($item->holds(), undef, "Nothing returned if no holds");
93
    my $hold1 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'T' }});
94
    my $hold2 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'W' }});
95
    my $hold3 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'W' }});
96
97
    is($item->holds()->count,3,"Three holds found");
98
    is($item->holds({found => 'W'})->count,2,"Two waiting holds found");
99
    is_deeply($item->holds({found => 'T'})->next->unblessed,$hold1,"Found transit holds matches the hold");
100
    is($item->holds({found => undef}),undef,"Nothing returned if no matching holds");
101
};
102
84
subtest 'biblio' => sub {
103
subtest 'biblio' => sub {
85
    plan tests => 2;
104
    plan tests => 2;
86
105
87
- 

Return to bug 23413