From 9fff49444368dffa9032feda071a1f70d429afc0 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 25 Apr 2019 11:09:38 +0000 Subject: [PATCH] Bug 22511: DBRev 18.12.00.063 Signed-off-by: Nick Clemens --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_22511.perl | 25 ------------------ installer/data/mysql/updatedatabase.pl | 26 +++++++++++++++++++ 3 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_22511.perl diff --git a/Koha.pm b/Koha.pm index 41b814b6a9..81c19c78dd 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "18.12.00.062"; +$VERSION = "18.12.00.063"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_22511.perl b/installer/data/mysql/atomicupdate/bug_22511.perl deleted file mode 100644 index 4ec384b072..0000000000 --- a/installer/data/mysql/atomicupdate/bug_22511.perl +++ /dev/null @@ -1,25 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if ( CheckVersion($DBversion) ) { - - my $types_map = { - 'Writeoff' => 'W', - 'Payment' => 'Pay', - 'List Item' => 'CR', - 'Manual Credit' => 'C', - 'Forgiven' => 'FOR' - }; - - my $sth = $dbh->prepare( "SELECT accountlines_id FROM accountlines WHERE accounttype = 'VOID'" ); - my $sth2 = $dbh->prepare( "SELECT type FROM account_offsets WHERE credit_id = ? ORDER BY created_on LIMIT 1" ); - my $sth3 = $dbh->prepare( "UPDATE accountlines SET accounttype = ?, status = 'VOID' WHERE accountlines_id = ?" ); - $sth->execute(); - while (my $row = $sth->fetchrow_hashref) { - $sth2->execute($row->{accountlines_id}); - my $result = $sth2->fetchrow_hashref; - my $type = $types_map->{$result->{'type'}} // 'Pay'; - $sth3->execute($type,$row->{accountlines_id}); - } - - SetVersion($DBversion); - print "Upgrade to $DBversion done (Bug 22511 - Update existing VOID accountlines)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3bc127dcce..fec941711b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -18337,6 +18337,32 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 22339 - Fix search field mappings of MARC fixed fields)\n"; } +$DBversion = '18.12.00.063'; +if ( CheckVersion($DBversion) ) { + + my $types_map = { + 'Writeoff' => 'W', + 'Payment' => 'Pay', + 'Lost Item' => 'CR', + 'Manual Credit' => 'C', + 'Forgiven' => 'FOR' + }; + + my $sth = $dbh->prepare( "SELECT accountlines_id FROM accountlines WHERE accounttype = 'VOID'" ); + my $sth2 = $dbh->prepare( "SELECT type FROM account_offsets WHERE credit_id = ? ORDER BY created_on LIMIT 1" ); + my $sth3 = $dbh->prepare( "UPDATE accountlines SET accounttype = ?, status = 'VOID' WHERE accountlines_id = ?" ); + $sth->execute(); + while (my $row = $sth->fetchrow_hashref) { + $sth2->execute($row->{accountlines_id}); + my $result = $sth2->fetchrow_hashref; + my $type = $types_map->{$result->{'type'}} // 'Pay'; + $sth3->execute($type,$row->{accountlines_id}); + } + + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 22511 - Update existing VOID accountlines)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5