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

(-)a/Koha/Statistic.pm (-2 / +3 lines)
Lines 27-34 use Koha::BackgroundJob::PseudonymizeStatistic; Link Here
27
27
28
use base qw(Koha::Object);
28
use base qw(Koha::Object);
29
29
30
our @allowed_accounts_types     = qw( writeoff payment );
30
our @allowed_accounts_types = qw( writeoff payment );
31
our @allowed_circulation_types  = qw( renew issue localuse return onsite_checkout recall item_found item_lost invalid_item invalid_patron);
31
our @allowed_circulation_types =
32
    qw( renew issue localuse return onsite_checkout recall item_found item_lost invalid_item invalid_patron);
32
our @mandatory_accounts_keys    = qw( type branch borrowernumber value );    # note that amount is mapped to value
33
our @mandatory_accounts_keys    = qw( type branch borrowernumber value );    # note that amount is mapped to value
33
our @mandatory_circulation_keys = qw( type branch borrowernumber itemnumber ccode itemtype );
34
our @mandatory_circulation_keys = qw( type branch borrowernumber itemnumber ccode itemtype );
34
35
(-)a/Koha/Statistics.pm (-2 / +2 lines)
Lines 87-94 sub _log_invalid_value { Link Here
87
    my $type  = $params->{type};
87
    my $type  = $params->{type};
88
    my $value = $params->{value};
88
    my $value = $params->{value};
89
89
90
    my $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
90
    my $branch         = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
91
    my $dt     = dt_from_string();
91
    my $dt             = dt_from_string();
92
    my $borrowernumber = C4::Context->userenv->{'number'};
92
    my $borrowernumber = C4::Context->userenv->{'number'};
93
93
94
    return Koha::Statistic->new(
94
    return Koha::Statistic->new(
(-)a/installer/data/mysql/atomicupdate/bug_16117.pl (-5 / +8 lines)
Lines 1-17 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
return {
3
return {
4
    bug_number => "16117",
4
    bug_number  => "16117",
5
    description => "Log invalid borrower cardnumbers and item barcodes",
5
    description => "Log invalid borrower cardnumbers and item barcodes",
6
    up => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
9
10
        $dbh->do(q{
10
        $dbh->do(
11
            q{
11
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
12
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
12
            ('LogInvalidItems','0','','Log scanned invalid item identifiers as statistics','YesNo'),
13
            ('LogInvalidItems','0','','Log scanned invalid item identifiers as statistics','YesNo'),
13
            ('LogInvalidPatrons','0','','Log scanned invalid patron identifiers as statistics','YesNo');
14
            ('LogInvalidPatrons','0','','Log scanned invalid patron identifiers as statistics','YesNo');
14
        });
15
        }
16
        );
17
15
        # sysprefs
18
        # sysprefs
16
        say $out "Added new system preference 'LogInvalidItems'";
19
        say $out "Added new system preference 'LogInvalidItems'";
17
        say $out "Added new system preference 'LogInvalidPatrons'";
20
        say $out "Added new system preference 'LogInvalidPatrons'";
(-)a/t/db_dependent/Koha/Statistics.t (-3 / +2 lines)
Lines 196-202 subtest 'Log borrower cardnumbers and item barcodes which are not valid' => sub Link Here
196
    Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } );
196
    Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } );
197
    my $stat = Koha::Statistics->search()->next();
197
    my $stat = Koha::Statistics->search()->next();
198
    is( $stat->type,           'invalid_patron',    'Type set to invalid_patron' );
198
    is( $stat->type,           'invalid_patron',    'Type set to invalid_patron' );
199
    is( $stat->borrowernumber, '-1',                'Associated library id set correctly' );
199
    is( $stat->borrowernumber, '-1',                'Associated patron id set correctly' );
200
    is( $stat->other,          'InvalidCardnumber', 'Invalid cardnumber is set correctly' );
200
    is( $stat->other,          'InvalidCardnumber', 'Invalid cardnumber is set correctly' );
201
    is( $stat->branch,         $branchcode,         'Branchcode is set correctly' );
201
    is( $stat->branch,         $branchcode,         'Branchcode is set correctly' );
202
202
Lines 210-216 subtest 'Log borrower cardnumbers and item barcodes which are not valid' => sub Link Here
210
    Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } );
210
    Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } );
211
    $stat = Koha::Statistics->search()->next();
211
    $stat = Koha::Statistics->search()->next();
212
    is( $stat->type,           'invalid_item',   'Type set to invalid_item' );
212
    is( $stat->type,           'invalid_item',   'Type set to invalid_item' );
213
    is( $stat->borrowernumber, '-1',             'Associated library id set correctly' );
213
    is( $stat->borrowernumber, '-1',             'Associated patron id set correctly' );
214
    is( $stat->other,          'InvalidBarcode', 'Invalid barcode is set correctly' );
214
    is( $stat->other,          'InvalidBarcode', 'Invalid barcode is set correctly' );
215
    is( $stat->branch,         $branchcode,      'Branchcode is set correctly' );
215
    is( $stat->branch,         $branchcode,      'Branchcode is set correctly' );
216
216
217
- 

Return to bug 16117