[Koha-patches] [PATCH] Bug 4133 Ensure that orders have a valid quantity received

Colin Campbell colin.campbell at ptfs-europe.com
Mon Feb 8 16:39:46 CET 2010


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
---
 C4/Acquisition.pm                      |    3 +++
 installer/data/mysql/updatedatabase.pl |    7 +++++++
 kohaversion.pl                         |    2 +-
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index 80dd667..cd4a449 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 e63f537..2406a41 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 c8a0db6..3c5dda5 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
-- 
1.6.6




More information about the Koha-patches mailing list