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

(-)a/Koha/Item.pm (-7 / +7 lines)
Lines 131-137 sub store { Link Here
131
        }
131
        }
132
132
133
        # should be quite rare when adding item
133
        # should be quite rare when adding item
134
        if ( $self->itemlost ) {
134
        if ( $self->itemlost && $self->itemlost > 0 ) {    # TODO BZ34308
135
            $self->_add_statistic('item_lost');
135
            $self->_add_statistic('item_lost');
136
        }
136
        }
137
137
Lines 190-207 sub store { Link Here
190
            $self->permanent_location( $self->location );
190
            $self->permanent_location( $self->location );
191
        }
191
        }
192
192
193
        # TODO BZ 34308 (gt zero checks)
193
        if (   exists $updated_columns{itemlost}
194
        if (   exists $updated_columns{itemlost}
194
            && !$updated_columns{itemlost}
195
            && ( !$updated_columns{itemlost} || $updated_columns{itemlost} <= 0 )
195
            && $pre_mod_item->itemlost )
196
            && ( $pre_mod_item->itemlost && $pre_mod_item->itemlost > 0 ) )
196
        {
197
        {
197
            # item found
198
            # item found
198
            # reverse any list item charges if necessary
199
            # reverse any list item charges if necessary
199
            $self->_set_found_trigger($pre_mod_item);
200
            $self->_set_found_trigger($pre_mod_item);
200
            $self->_add_statistic('item_found');
201
            $self->_add_statistic('item_found');
201
        }
202
        } elsif ( exists $updated_columns{itemlost}
202
        elsif (exists $updated_columns{itemlost}
203
            && ( $updated_columns{itemlost} && $updated_columns{itemlost} > 0 )
203
            && $updated_columns{itemlost}
204
            && ( !$pre_mod_item->itemlost || $pre_mod_item->itemlost <= 0 ) )
204
            && !$pre_mod_item->itemlost )
205
        {
205
        {
206
            # item lost
206
            # item lost
207
            $self->_add_statistic('item_lost');
207
            $self->_add_statistic('item_lost');
(-)a/t/db_dependent/Koha/Items.t (-2 / +18 lines)
Lines 33-38 use Koha::Item::Transfer::Limits; Link Here
33
use Koha::Items;
33
use Koha::Items;
34
use Koha::Database;
34
use Koha::Database;
35
use Koha::DateUtils qw( dt_from_string );
35
use Koha::DateUtils qw( dt_from_string );
36
use Koha::Statistics;
36
37
37
use t::lib::TestBuilder;
38
use t::lib::TestBuilder;
38
use t::lib::Mocks;
39
use t::lib::Mocks;
Lines 68-74 my $retrieved_item_1 = Koha::Items->find( $new_item_1->itemnumber ); Link Here
68
is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' );
69
is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' );
69
70
70
subtest 'store' => sub {
71
subtest 'store' => sub {
71
    plan tests => 7;
72
    plan tests => 8;
72
73
73
    my $biblio = $builder->build_sample_biblio;
74
    my $biblio = $builder->build_sample_biblio;
74
    my $today  = dt_from_string->set( hour => 0, minute => 0, second => 0 );
75
    my $today  = dt_from_string->set( hour => 0, minute => 0, second => 0 );
Lines 1363-1368 subtest 'store' => sub { Link Here
1363
            "Item modification logged"
1364
            "Item modification logged"
1364
        );
1365
        );
1365
    };
1366
    };
1367
1368
    subtest 'itemlost / statistics' => sub {    # TODO BZ 34308 (gt zero checks)
1369
        plan tests => 5;
1370
1371
        my $item = $builder->build_sample_item;
1372
        $item->itemlost(-1)->store;             # weird value; >0 test not triggered ?
1373
        is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 0, 'No statistics added' );
1374
        $item->itemlost(1)->store;
1375
        is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 1, 'statistics added' );
1376
        $item->itemlost(2)->store;
1377
        is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 1, 'No statistics added, already lost' );
1378
        $item->itemlost(-1)->store;             # weird value; <=0 test triggered ?
1379
        is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 2, 'statistics added' );
1380
        $item->itemlost(-2)->store;             # weird value, but no status change
1381
        is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 2, 'No statistics added, already *found*' );
1382
    };
1366
};
1383
};
1367
1384
1368
subtest 'get_transfer' => sub {
1385
subtest 'get_transfer' => sub {
1369
- 

Return to bug 33608