From 1324646ff7bc9a1ae03db0baea9cb45e51f730cc Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Mon, 1 Jul 2013 21:58:57 +0200 Subject: [PATCH] Bug 10490: Overdue fines cap can't store decimal values When overduefinescap was added to the issuingrules the datatype given was decimal. This translates in MySQL to decimal(10,0). This doesn't allow you to store decimal values and therefore values like 4.5 are saved as 5 in the database. To test: On a current installation: 1) Try to enter 4.5 as Overdue fines cap. Verify that the value is not correctly saved. 2) Apply patch and run database update. 3) Try adding/changing an issuing rule setting Overdue fines cap to 4.5 again. 4) Verify the value is saved correctly. Create a new Koha installation from scratch: 1) Verify that the issuingrules table has been created correctly and that you can add/mofidy issuingrules correctly. Because this bug can create data loss, the old database update has also been changed to avoid this problem for people updating at a later point in time. Checkout an older version of Koha pre 3.09.00.027. 1) Run the database updates. 2) Verify again, that adding/modifying issuingrules works correctly. Signed-off-by: Srdjan Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton (cherry picked from commit 16c57940441aac62c1c90538f3c7b7cd386e6d92) Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 47df7c9641321b70cd132790d4cfeab500bc34be) Conflicts: installer/data/mysql/updatedatabase.pl Solved Signed-off-by: Bernardo Gonzalez Kriegel (cherry picked from commit 47df7c9641321b70cd132790d4cfeab500bc34be) Conflicts: installer/data/mysql/kohastructure.sql installer/data/mysql/updatedatabase.pl Signed-off-by: Chris Hall (cherry picked from commit 2727ca9512ad9e06fbba9a3c299dbdd78289da7c) --- installer/data/mysql/kohastructure.sql | 29 +++++++++++++------------- installer/data/mysql/updatedatabase.pl | 7 +++++++ kohaversion.pl | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 035e465587..44a8325bd0 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -983,20 +983,21 @@ CREATE TABLE `issuingrules` ( `restrictedtype` tinyint(1) default NULL, `rentaldiscount` decimal(28,6) default NULL, `reservecharge` decimal(28,6) default NULL, - `fine` decimal(28,6) default NULL, - `finedays` int(11) default NULL, - `firstremind` int(11) default NULL, - `chargeperiod` int(11) default NULL, - `accountsent` int(11) default NULL, - `chargename` varchar(100) default NULL, - `maxissueqty` int(4) default NULL, - `issuelength` int(4) default NULL, - `lengthunit` varchar(10) default 'days', - `hardduedate` date default NULL, - `hardduedatecompare` tinyint NOT NULL default "0", - `renewalsallowed` smallint(6) NOT NULL default "0", - `reservesallowed` smallint(6) NOT NULL default "0", - `branchcode` varchar(10) NOT NULL default '', + `fine` decimal(28,6) default NULL, -- fine amount + `finedays` int(11) default NULL, -- suspension in days + `firstremind` int(11) default NULL, -- fine grace period + `chargeperiod` int(11) default NULL, -- how often the fine amount is charged + `accountsent` int(11) default NULL, -- not used? always NULL + `chargename` varchar(100) default NULL, -- not used? always NULL + `maxissueqty` int(4) default NULL, -- total number of checkouts allowed + `issuelength` int(4) default NULL, -- length of checkout in the unit set in issuingrules.lengthunit + `lengthunit` varchar(10) default 'days', -- unit of checkout length (days, hours) + `hardduedate` date default NULL, -- hard due date + `hardduedatecompare` tinyint NOT NULL default "0", -- type of hard due date (1 = after, 0 = on, -1 = before) + `renewalsallowed` smallint(6) NOT NULL default "0", -- how many renewals are allowed + `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed + `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode) + overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`), KEY `categorycode` (`categorycode`), KEY `itemtype` (`itemtype`) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index da64f669d7..9fe10a516b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5386,6 +5386,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.08.16.002"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE issuingrules MODIFY COLUMN overduefinescap decimal(28,6) DEFAULT NULL;"); + print "Upgrade to $DBversion done (Bug 10490: Correct datatype for overduefinescap in issuingrules)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/kohaversion.pl b/kohaversion.pl index e1ef7dffc1..8258d5054b 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : use strict; sub kohaversion { - our $VERSION = '3.08.16.001'; + our $VERSION = '3.08.16.002'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.39.5