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

(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +1 lines)
Lines 781-787 sub marc_records_to_documents { Link Here
781
                my $avail_items = Koha::Items->search({
781
                my $avail_items = Koha::Items->search({
782
                    biblionumber => $biblionumber,
782
                    biblionumber => $biblionumber,
783
                    onloan       => undef,
783
                    onloan       => undef,
784
                    notforloan   => 0,
784
                    itemlost     => 0,
785
                })->count;
785
                })->count;
786
786
787
                $record_document->{available} = $avail_items ? \1 : \0;
787
                $record_document->{available} = $avail_items ? \1 : \0;
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-4 / +3 lines)
Lines 1006-1012 subtest 'marc_records_to_documents should set the "available" field' => sub { Link Here
1006
1006
1007
    $item->notforloan(1)->store();
1007
    $item->notforloan(1)->store();
1008
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1008
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1009
    is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is "notforloan" is not available');
1009
    is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is "notforloan" is available');
1010
1010
1011
    $item->set({ notforloan => 0, onloan => '2022-03-03' })->store();
1011
    $item->set({ notforloan => 0, onloan => '2022-03-03' })->store();
1012
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1012
    $docs = $see->marc_records_to_documents([$marc_record_1]);
Lines 1014-1020 subtest 'marc_records_to_documents should set the "available" field' => sub { Link Here
1014
1014
1015
    $item->set({ onloan => undef, withdrawn => 1 })->store();
1015
    $item->set({ onloan => undef, withdrawn => 1 })->store();
1016
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1016
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1017
    is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is withdrawn is not available');
1017
    is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is withdrawn is available');
1018
1018
1019
    $item->set({ withdrawn => 0, itemlost => 1 })->store();
1019
    $item->set({ withdrawn => 0, itemlost => 1 })->store();
1020
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1020
    $docs = $see->marc_records_to_documents([$marc_record_1]);
Lines 1022-1028 subtest 'marc_records_to_documents should set the "available" field' => sub { Link Here
1022
1022
1023
    $item->set({ itemlost => 0, damaged => 1 })->store();
1023
    $item->set({ itemlost => 0, damaged => 1 })->store();
1024
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1024
    $docs = $see->marc_records_to_documents([$marc_record_1]);
1025
    is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is damaged is not available');
1025
    is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is damaged is available');
1026
1026
1027
    my $item2 = Koha::Item->new({
1027
    my $item2 = Koha::Item->new({
1028
        biblionumber => $biblionumber,
1028
        biblionumber => $biblionumber,
1029
- 

Return to bug 25375