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

(-)a/C4/Stats.pm (-8 / +8 lines)
Lines 118-131 sub UpdateStats { Link Here
118
# get the parameters
118
# get the parameters
119
    my $branch            = $params->{branch};
119
    my $branch            = $params->{branch};
120
    my $type              = $params->{type};
120
    my $type              = $params->{type};
121
    my $borrowernumber    = exists $params->{borrowernumber} ? $params->{borrowernumber} :'';
121
    my $borrowernumber    = exists $params->{borrowernumber} ? $params->{borrowernumber} : '';
122
    my $itemnumber        = exists $params->{itemnumber}     ? $params->{itemnumber} :'';
122
    my $itemnumber        = exists $params->{itemnumber}     ? $params->{itemnumber}     : '';
123
    my $amount            = exists $params->{amount}         ? $params->{amount} :'';
123
    my $amount            = exists $params->{amount}         ? $params->{amount}         : '';
124
    my $other             = exists $params->{other}          ? $params->{other} :'';
124
    my $other             = exists $params->{other}          ? $params->{other}          : '';
125
    my $itemtype          = exists $params->{itemtype}       ? $params->{itemtype} :'';
125
    my $itemtype          = exists $params->{itemtype}       ? $params->{itemtype}       : '';
126
    my $location          = exists $params->{location}       ? $params->{location} :'';
126
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
127
    my $accountno         = exists $params->{accountno}      ? $params->{accountno} :'';
127
    my $accountno         = exists $params->{accountno}      ? $params->{accountno}      : '';
128
    my $ccode             = exists $params->{ccode}          ? $params->{ccode} :'';
128
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
129
129
130
    my $dbh = C4::Context->dbh;
130
    my $dbh = C4::Context->dbh;
131
    my $sth = $dbh->prepare(
131
    my $sth = $dbh->prepare(
(-)a/t/db_dependent/Stats.t (-2 / +40 lines)
Lines 3-9 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Stats;
4
use C4::Stats;
5
5
6
use Test::More tests => 18;
6
use Test::More tests => 20;
7
7
8
BEGIN {
8
BEGIN {
9
    use_ok('C4::Stats');
9
    use_ok('C4::Stats');
Lines 125-130 is ($params->{location}, $line->{location}, "UpdateStats save locati Link Here
125
is ($params->{accountno},      $line->{proccode},       "UpdateStats save accountno param in proccode field of statistics table");
125
is ($params->{accountno},      $line->{proccode},       "UpdateStats save accountno param in proccode field of statistics table");
126
is ($params->{ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode field of statistics table");
126
is ($params->{ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode field of statistics table");
127
127
128
$dbh->do(q|DELETE FROM statistics|);
129
$params = {
130
    branch         => "BRA",
131
    itemnumber     => 31,
132
    borrowernumber => 5,
133
    amount         => 5.1,
134
    other          => "bla",
135
    itemtype       => "BK",
136
    accountno      => 51,
137
    ccode          => "CODE",
138
    type           => "return"
139
};
140
UpdateStats($params);
141
$sth = $dbh->prepare("SELECT * FROM statistics");
142
$sth->execute();
143
$line = ${ $sth->fetchall_arrayref( {} ) }[0];
144
is( $line->{location}, undef,
145
    "UpdateStats sets location to NULL if no location is passed in." );
146
147
$dbh->do(q|DELETE FROM statistics|);
148
$params = {
149
    branch         => "BRA",
150
    itemnumber     => 31,
151
    borrowernumber => 5,
152
    amount         => 5.1,
153
    other          => "bla",
154
    itemtype       => "BK",
155
    location       => undef,
156
    accountno      => 51,
157
    ccode          => "CODE",
158
    type           => "return"
159
};
160
UpdateStats($params);
161
$sth = $dbh->prepare("SELECT * FROM statistics");
162
$sth->execute();
163
$line = ${ $sth->fetchall_arrayref( {} ) }[0];
164
is( $line->{location}, undef,
165
    "UpdateStats sets location to NULL if undef is passed in." );
166
128
#
167
#
129
# Test TotalPaid
168
# Test TotalPaid
130
#
169
#
131
- 

Return to bug 18882