@@ -, +, @@
---
.../data/mysql/atomicupdate/bug_22563.perl | 34 +++++++++++++++++++
.../en/modules/reports/cash_register_stats.tt | 2 +-
reports/cash_register_stats.pl | 4 +--
3 files changed, 37 insertions(+), 3 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_22563.perl
--- a/installer/data/mysql/atomicupdate/bug_22563.perl
+++ a/installer/data/mysql/atomicupdate/bug_22563.perl
@@ -0,0 +1,34 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if ( CheckVersion($DBversion) ) {
+
+ my $sth = $dbh->prepare( "SELECT accountlines_id, issue_id, borrowernumber, itemnumber, amount, manager_id FROM accountlines WHERE accounttype = 'LR' AND amount < 0" );
+ $sth->execute();
+ while ( my $row = $sth->fetchrow_hashref ) {
+ $dbh->do(
+"INSERT INTO accountlines (accounttype, issue_id, borrowernumber, itemnumber, amount, manager_id) VALUES ( ?, ?, ?, ?, ?, ? );",
+ {},
+ (
+ 'CR', $row->{issue_id},
+ $row->{borrowernumber}, $row->{itemnumber},
+ $row->{amount}, $row->{manager_id}
+ )
+ );
+ my $credit_id = $dbh->last_insert_id();
+ my $amount = $row->{amount} * -1;
+ $dbh->do("INSERT INTO account_offsets (credit_id, debit_id, type, amount) VALUES (?,?,?,?);",{},($credit_id, $row->{accountlines_id}, 'Lost Item', $amount));
+ $dbh->do("UPDATE accountlines SET amount = '$amount' WHERE accountlines_id = '$row->{accountlines_id}';");
+ }
+
+ $dbh->do(qq{
+ UPDATE
+ accountlines
+ SET
+ accounttype = 'LOST',
+ status = 'RETURNED'
+ WHERE
+ accounttype = 'LR';
+ });
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 22518 - Fix accounttypes for 'L' and 'LR')\n";
+}
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
@@ -211,7 +211,7 @@
Account management fee
[% ELSIF loopresul.accounttype == "M" %]
Sundry
- [% ELSIF loopresul.accounttype == "L" || loopresul.accounttype == "LR" %]
+ [% ELSIF loopresul.accounttype == "LOST" %]
Lost item
[% ELSIF loopresul.accounttype == "N" %]
New card
--- a/reports/cash_register_stats.pl
+++ a/reports/cash_register_stats.pl
@@ -118,11 +118,11 @@ if ($do_it) {
$row->{date} = dt_from_string($row->{date}, 'sql');
push (@loopresult, $row);
- if($transaction_type eq 'ACT' && ($row->{accounttype} !~ /^C$|^CR$|^LR$|^Pay$/)){
+ if($transaction_type eq 'ACT' && ($row->{accounttype} !~ /^C$|^CR$|^Pay$/)){
pop @loopresult;
next;
}
- if($row->{accounttype} =~ /^C$|^CR$|^LR$/){
+ if($row->{accounttype} =~ /^C$|^CR$/){
$grantotal -= abs($row->{amount});
$row->{amount} = '-' . $row->{amount};
}elsif($row->{accounttype} eq 'FORW' || $row->{accounttype} eq 'W'){
--