From 745ac87c20b4166cb28ada18eebcc7e39948042a Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Mon, 8 Feb 2010 15:39:46 +0000 Subject: [PATCH] Bug 4133 Ensure that orders have a valid quantity received quantityreceived drives other parts of acq noticeably budget balances ensure that a number (usually 0) is set in NewOrder give field a valid default and set as not null reinterpret exsting nulls in table as zero Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 3 +++ installer/data/mysql/updatedatabase.pl | 7 +++++++ kohaversion.pl | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 80dd667826..cd4a449518 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1015,6 +1015,9 @@ sub NewOrder { $orderinfo->{'subscription'} = 0; } $orderinfo->{'entrydate'} ||= C4::Dates->new()->output("iso"); + if (!$orderinfo->{quantityreceived}) { + $orderinfo->{quantityreceived} = 0; + } my $ordernumber=InsertInTable("aqorders",$orderinfo); return ( $orderinfo->{'basketno'}, $ordernumber ); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e63f537c8d..2406a41631 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3421,6 +3421,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.01.00.115'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL'); + $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0'); + print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) diff --git a/kohaversion.pl b/kohaversion.pl index c8a0db6a3a..3c5dda577e 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.01.00.114'; + our $VERSION = '3.01.00.115'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.39.5