From 2105982b1a1c2b4e5ebbb8968679fd47b43f5670 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 6 Jul 2018 12:56:54 +0000 Subject: [PATCH] Bug 20980: DBRev 18.05.02.001 Signed-off-by: Nick Clemens (cherry picked from commit 64761e56ccfbf98844d2fc8c7aa68ee608a2b162) Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_20980.perl | 39 ------------------ installer/data/mysql/updatedatabase.pl | 40 +++++++++++++++++++ 3 files changed, 41 insertions(+), 40 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_20980.perl diff --git a/Koha.pm b/Koha.pm index 60edd1e867..e620372509 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.05.02.000"; +$VERSION = "18.05.02.001"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_20980.perl b/installer/data/mysql/atomicupdate/bug_20980.perl deleted file mode 100644 index 691ecd571f..0000000000 --- a/installer/data/mysql/atomicupdate/bug_20980.perl +++ /dev/null @@ -1,39 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - - # Add 'Manual Credit' offset type - $dbh->do(q{ - INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Manual Credit'); - }); - - # Fix wrong account offsets / Manual credits - $dbh->do(q{ - UPDATE account_offsets - SET credit_id=debit_id, - debit_id=NULL, - type='Manual Credit' - WHERE amount < 0 AND - type='Manual Debit' AND - debit_id IN - (SELECT accountlines_id AS debit_id - FROM accountlines - WHERE accounttype='C'); - }); - - # Fix wrong account offsets / Manually forgiven amounts - $dbh->do(q{ - UPDATE account_offsets - SET credit_id=debit_id, - debit_id=NULL, - type='Writeoff' - WHERE amount < 0 AND - type='Manual Debit' AND - debit_id IN - (SELECT accountlines_id AS debit_id - FROM accountlines - WHERE accounttype='FOR'); - }); - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 20980 - Manual credit offsets are stored as debits)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e353ea5202..79c850d297 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16065,6 +16065,46 @@ if ( CheckVersion($DBversion) ) { } +$DBversion = '18.05.02.001'; +if( CheckVersion( $DBversion ) ) { + + # Add 'Manual Credit' offset type + $dbh->do(q{ + INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Manual Credit'); + }); + + # Fix wrong account offsets / Manual credits + $dbh->do(q{ + UPDATE account_offsets + SET credit_id=debit_id, + debit_id=NULL, + type='Manual Credit' + WHERE amount < 0 AND + type='Manual Debit' AND + debit_id IN + (SELECT accountlines_id AS debit_id + FROM accountlines + WHERE accounttype='C'); + }); + + # Fix wrong account offsets / Manually forgiven amounts + $dbh->do(q{ + UPDATE account_offsets + SET credit_id=debit_id, + debit_id=NULL, + type='Writeoff' + WHERE amount < 0 AND + type='Manual Debit' AND + debit_id IN + (SELECT accountlines_id AS debit_id + FROM accountlines + WHERE accounttype='FOR'); + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 20980 - Manual credit offsets are stored as debits)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5