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

(-)a/Koha/Item.pm (-3 / +15 lines)
Lines 1834-1840 Return the relevant recall for this item Link Here
1834
=cut
1834
=cut
1835
1835
1836
sub recall {
1836
sub recall {
1837
    my ( $self ) = @_;
1837
    my ($self) = @_;
1838
    my @recalls = Koha::Recalls->search(
1838
    my @recalls = Koha::Recalls->search(
1839
        {
1839
        {
1840
            biblio_id => $self->biblionumber,
1840
            biblio_id => $self->biblionumber,
Lines 1842-1852 sub recall { Link Here
1842
        },
1842
        },
1843
        { order_by => { -asc => 'created_date' } }
1843
        { order_by => { -asc => 'created_date' } }
1844
    )->as_list;
1844
    )->as_list;
1845
1846
    my $item_level_recall;
1845
    foreach my $recall (@recalls) {
1847
    foreach my $recall (@recalls) {
1846
        if ( $recall->item_level and $recall->item_id == $self->itemnumber ){
1848
        if ( $recall->item_level ) {
1847
            return $recall;
1849
            $item_level_recall = 1;
1850
            if ( $recall->item_id == $self->itemnumber ) {
1851
                return $recall;
1852
            }
1848
        }
1853
        }
1849
    }
1854
    }
1855
    if ($item_level_recall) {
1856
1857
        # recall needs to be filled be a specific item only
1858
        # no other item is relevant to return
1859
        return;
1860
    }
1861
1850
    # no item-level recall to return, so return earliest biblio-level
1862
    # no item-level recall to return, so return earliest biblio-level
1851
    # FIXME: eventually this will be based on priority
1863
    # FIXME: eventually this will be based on priority
1852
    return $recalls[0];
1864
    return $recalls[0];
(-)a/t/db_dependent/Koha/Item.t (-2 / +2 lines)
Lines 1915-1921 subtest 'store() tests' => sub { Link Here
1915
1915
1916
subtest 'Recalls tests' => sub {
1916
subtest 'Recalls tests' => sub {
1917
1917
1918
    plan tests => 22;
1918
    plan tests => 23;
1919
1919
1920
    $schema->storage->txn_begin;
1920
    $schema->storage->txn_begin;
1921
1921
Lines 1956-1961 subtest 'Recalls tests' => sub { Link Here
1956
    )->store;
1956
    )->store;
1957
1957
1958
    is( $item1->recall->patron_id, $patron1->borrowernumber, 'Correctly returns most relevant recall' );
1958
    is( $item1->recall->patron_id, $patron1->borrowernumber, 'Correctly returns most relevant recall' );
1959
    is( $item2->recall,            undef,                    'Other items are not returned for item-level recalls' );
1959
1960
1960
    $recall2->set_cancelled;
1961
    $recall2->set_cancelled;
1961
1962
1962
- 

Return to bug 34722