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

(-)a/C4/Circulation.pm (+2 lines)
Lines 1438-1443 sub AddIssue { Link Here
1438
                    other          => ( $sipmode ? "SIP-$sipmode" : '' ),
1438
                    other          => ( $sipmode ? "SIP-$sipmode" : '' ),
1439
                    itemnumber     => $item->{'itemnumber'},
1439
                    itemnumber     => $item->{'itemnumber'},
1440
                    itemtype       => $item->{'itype'},
1440
                    itemtype       => $item->{'itype'},
1441
                    location       => $item->{location},
1441
                    borrowernumber => $borrower->{'borrowernumber'},
1442
                    borrowernumber => $borrower->{'borrowernumber'},
1442
                    ccode          => $item->{'ccode'}
1443
                    ccode          => $item->{'ccode'}
1443
                }
1444
                }
Lines 2971-2976 sub AddRenewal { Link Here
2971
            amount         => $charge,
2972
            amount         => $charge,
2972
            itemnumber     => $itemnumber,
2973
            itemnumber     => $itemnumber,
2973
            itemtype       => $item->{itype},
2974
            itemtype       => $item->{itype},
2975
            location       => $item->{location},
2974
            borrowernumber => $borrowernumber,
2976
            borrowernumber => $borrowernumber,
2975
            ccode          => $item->{'ccode'}
2977
            ccode          => $item->{'ccode'}
2976
        }
2978
        }
(-)a/C4/Stats.pm (-6 / +7 lines)
Lines 84-90 sub UpdateStats { Link Here
84
# make some controls
84
# make some controls
85
    return () if ! defined $params;
85
    return () if ! defined $params;
86
# change these arrays if new types of transaction or new parameters are allowed
86
# change these arrays if new types of transaction or new parameters are allowed
87
    my @allowed_keys = qw (type branch amount other itemnumber itemtype borrowernumber accountno ccode);
87
    my @allowed_keys = qw (type branch amount other itemnumber itemtype borrowernumber accountno ccode location);
88
    my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout);
88
    my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout);
89
    my @allowed_accounts_types = qw (writeoff payment);
89
    my @allowed_accounts_types = qw (writeoff payment);
90
    my @circulation_mandatory_keys = qw (type branch borrowernumber itemnumber ccode itemtype);
90
    my @circulation_mandatory_keys = qw (type branch borrowernumber itemnumber ccode itemtype);
Lines 123-128 sub UpdateStats { Link Here
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 $accountno         = exists $params->{accountno}      ? $params->{accountno} :'';
127
    my $accountno         = exists $params->{accountno}      ? $params->{accountno} :'';
127
    my $ccode             = exists $params->{ccode}          ? $params->{ccode} :'';
128
    my $ccode             = exists $params->{ccode}          ? $params->{ccode} :'';
128
129
Lines 131-144 sub UpdateStats { Link Here
131
        "INSERT INTO statistics
132
        "INSERT INTO statistics
132
        (datetime,
133
        (datetime,
133
         branch,          type,        value,
134
         branch,          type,        value,
134
         other,           itemnumber,  itemtype,
135
         other,           itemnumber,  itemtype, location,
135
         borrowernumber,  proccode,    ccode)
136
         borrowernumber,  proccode,    ccode)
136
         VALUES (now(),?,?,?,?,?,?,?,?,?)"
137
         VALUES (now(),?,?,?,?,?,?,?,?,?,?)"
137
    );
138
    );
138
    $sth->execute(
139
    $sth->execute(
139
        $branch,         $type,        $amount,
140
        $branch,     $type,     $amount,   $other,
140
        $other,          $itemnumber,  $itemtype,
141
        $itemnumber, $itemtype, $location, $borrowernumber,
141
        $borrowernumber, $accountno,   $ccode
142
        $accountno,  $ccode
142
    );
143
    );
143
}
144
}
144
145
(-)a/installer/data/mysql/atomicupdate/bug_18882.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if ( CheckVersion($DBversion) ) {
3
    if ( !column_exists( 'statistics', 'location' ) ) {
4
        $dbh->do('ALTER TABLE statistics ADD COLUMN location VARCHAR(80) default NULL AFTER itemtype');
5
    }
6
7
    SetVersion($DBversion);
8
    print "Upgrade to $DBversion done (Bug 18882 - Add location code to statistics table for checkouts and renewals)\n";
9
}
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2013-2018 CREATE TABLE `statistics` ( -- information related to transactions (circulation Link Here
2013
  `usercode` varchar(10) default NULL, -- unused in Koha
2013
  `usercode` varchar(10) default NULL, -- unused in Koha
2014
  `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
2014
  `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
2015
  `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
2015
  `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
2016
  `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
2016
  `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
2017
  `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
2017
  `associatedborrower` int(11) default NULL, -- unused in Koha
2018
  `associatedborrower` int(11) default NULL, -- unused in Koha
2018
  `ccode` varchar(10) default NULL, -- foreign key from the items table, links transaction to a specific collection code
2019
  `ccode` varchar(10) default NULL, -- foreign key from the items table, links transaction to a specific collection code
(-)a/t/db_dependent/Stats.t (-10 / +12 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 => 17;
6
use Test::More tests => 18;
7
7
8
BEGIN {
8
BEGIN {
9
    use_ok('C4::Stats');
9
    use_ok('C4::Stats');
Lines 33-38 my $params = { Link Here
33
              amount =>5.1,
33
              amount =>5.1,
34
              other => "bla",
34
              other => "bla",
35
              itemtype => "BK",
35
              itemtype => "BK",
36
              location => "LOC",
36
              accountno => 51,
37
              accountno => 51,
37
              ccode => "CODE",
38
              ccode => "CODE",
38
};
39
};
Lines 105-110 $params = { Link Here
105
              amount =>5.1,
106
              amount =>5.1,
106
              other => "bla",
107
              other => "bla",
107
              itemtype => "BK",
108
              itemtype => "BK",
109
              location => "LOC",
108
              accountno => 51,
110
              accountno => 51,
109
              ccode => "CODE",
111
              ccode => "CODE",
110
              type => "return"
112
              type => "return"
Lines 113-126 UpdateStats ($params); Link Here
113
my $sth = $dbh->prepare("SELECT * FROM statistics");
115
my $sth = $dbh->prepare("SELECT * FROM statistics");
114
$sth->execute();
116
$sth->execute();
115
my $line = ${ $sth->fetchall_arrayref( {} ) }[0];
117
my $line = ${ $sth->fetchall_arrayref( {} ) }[0];
116
is ($params-> {branch},         $line->{branch},         "UpdateStats save branch param in branch field of statistics table");
118
is ($params->{branch},         $line->{branch},         "UpdateStats save branch param in branch field of statistics table");
117
is ($params-> {type},           $line->{type},           "UpdateStats save type param in type field of statistics table");
119
is ($params->{type},           $line->{type},           "UpdateStats save type param in type field of statistics table");
118
is ($params-> {borrowernumber}, $line->{borrowernumber}, "UpdateStats save borrowernumber param in borrowernumber field of statistics table");
120
is ($params->{borrowernumber}, $line->{borrowernumber}, "UpdateStats save borrowernumber param in borrowernumber field of statistics table");
119
cmp_ok($params-> {amount},'==', $line->{value},          "UpdateStats save amount param in value field of statistics table");
121
cmp_ok($params->{amount},'==', $line->{value},          "UpdateStats save amount param in value field of statistics table");
120
is ($params-> {other},          $line->{other},          "UpdateStats save other param in other field of statistics table");
122
is ($params->{other},          $line->{other},          "UpdateStats save other param in other field of statistics table");
121
is ($params-> {itemtype},       $line->{itemtype},       "UpdateStats save itemtype param in itemtype field of statistics table");
123
is ($params->{itemtype},       $line->{itemtype},       "UpdateStats save itemtype param in itemtype field of statistics table");
122
is ($params-> {accountno},      $line->{proccode},       "UpdateStats save accountno param in proccode field of statistics table");
124
is ($params->{location},       $line->{location},       "UpdateStats save location param in location field of statistics table");
123
is ($params-> {ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode 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");
124
127
125
#
128
#
126
# Test TotalPaid
129
# Test TotalPaid
127
- 

Return to bug 18882