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

(-)a/Koha/Item.pm (-5 / +16 lines)
Lines 131-138 sub store { Link Here
131
            $self->cn_sort($cn_sort);
131
            $self->cn_sort($cn_sort);
132
        }
132
        }
133
133
134
        if( $self->itemlost ) {
134
        # should be quite rare when adding item
135
            $self->_add_statistic('item_lost'); # should be quite rare when adding item
135
        if ( $self->itemlost && $self->itemlost > 0 ) {    # TODO BZ34308
136
            $self->_add_statistic('item_lost');
136
        }
137
        }
137
138
138
    } else { # ModItem
139
    } else { # ModItem
Lines 190-199 sub store { Link Here
190
            $self->permanent_location( $self->location );
191
            $self->permanent_location( $self->location );
191
        }
192
        }
192
193
193
        if( exists $updated_columns{itemlost} && !$updated_columns{itemlost} && $pre_mod_item->itemlost ) { # item found again
194
        # TODO BZ 34308 (gt zero checks)
194
            $self->_set_found_trigger($pre_mod_item); # reverse any list item charges if necessary
195
        if (   exists $updated_columns{itemlost}
196
            && ( !$updated_columns{itemlost} || $updated_columns{itemlost} <= 0 )
197
            && ( $pre_mod_item->itemlost && $pre_mod_item->itemlost > 0 ) )
198
        {
199
            # item found
200
            # reverse any list item charges if necessary
201
            $self->_set_found_trigger($pre_mod_item);
195
            $self->_add_statistic('item_found');
202
            $self->_add_statistic('item_found');
196
        } elsif( exists $updated_columns{itemlost} && $updated_columns{itemlost} && !$pre_mod_item->itemlost ) { # item lost
203
        } elsif ( exists $updated_columns{itemlost}
204
            && ( $updated_columns{itemlost} && $updated_columns{itemlost} > 0 )
205
            && ( !$pre_mod_item->itemlost || $pre_mod_item->itemlost <= 0 ) )
206
        {
207
            # item lost
197
            $self->_add_statistic('item_lost');
208
            $self->_add_statistic('item_lost');
198
        }
209
        }
199
    }
210
    }
(-)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