From c752695f1b5bc44c3fd72d20564a63f5eb5ea4c2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Jul 2013 10:43:05 +0200 Subject: [PATCH] [PASSED QA] Bug 5336: Change numbers with understandable codes for orderstatus This patch uses understandable codes instead of magical numbers for the aqorders.orderstatus field. + execute sql queries in unit tests into a transaction. Signed-off-by: Pierre Angot Signed-off-by: Katrin Fischer --- C4/Acquisition.pm | 20 ++++++------ installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 10 +++--- .../prog/en/modules/acqui/histsearch.tt | 21 ++++++------- t/db_dependent/Acquisition/OrderFromSubscription.t | 2 +- t/db_dependent/Acquisition/close_reopen_basket.t | 33 ++++++++++---------- 6 files changed, 43 insertions(+), 45 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 115dfe5..0d9c2ff 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -235,7 +235,7 @@ sub CloseBasket { foreach my $order (@orders) { $query = qq{ UPDATE aqorders - SET orderstatus = 1 + SET orderstatus = 'ordered' WHERE ordernumber = ?; }; $sth = $dbh->prepare($query); @@ -266,7 +266,7 @@ sub ReopenBasket { foreach my $order (@orders) { $query = qq{ UPDATE aqorders - SET orderstatus = 0 + SET orderstatus = 'new' WHERE ordernumber = ?; }; $sth = $dbh->prepare($query); @@ -1394,7 +1394,7 @@ sub ModReceiveOrder { $sth=$dbh->prepare(" UPDATE aqorders SET quantity = ?, - orderstatus = 2 + orderstatus = 'partial' WHERE ordernumber = ? "); @@ -1410,7 +1410,7 @@ sub ModReceiveOrder { $order->{'unitprice'} = $cost; $order->{'rrp'} = $rrp; $order->{ecost} = $ecost; - $order->{'orderstatus'} = 3; # totally received + $order->{'orderstatus'} = 'complete'; my $basketno; ( $basketno, $new_ordernumber ) = NewOrder($order); @@ -1422,7 +1422,7 @@ sub ModReceiveOrder { } else { $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=?,invoiceid=?, - unitprice=?,rrp=?,ecost=?,orderstatus=3 + unitprice=?,rrp=?,ecost=?,orderstatus='complete' where biblionumber=? and ordernumber=?"); $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber); $sth->finish; @@ -1473,7 +1473,7 @@ sub CancelReceipt { SET quantityreceived = ?, datereceived = ?, invoiceid = ?, - orderstatus = 1 + orderstatus = 'ordered' WHERE ordernumber = ? }; $sth = $dbh->prepare($query); @@ -1501,7 +1501,7 @@ sub CancelReceipt { $query = qq{ UPDATE aqorders SET quantity = ?, - orderstatus = 1 + orderstatus = 'ordered' WHERE ordernumber = ? }; $sth = $dbh->prepare($query); @@ -1641,7 +1641,7 @@ sub DelOrder { my $dbh = C4::Context->dbh; my $query = " UPDATE aqorders - SET datecancellationprinted=now(), orderstatus=4 + SET datecancellationprinted=now(), orderstatus='cancelled' WHERE biblionumber=? AND ordernumber=? "; my $sth = $dbh->prepare($query); @@ -1992,7 +1992,7 @@ sub GetLateOrders { $from .= ' AND borrowers.branchcode LIKE ? '; push @query_params, C4::Context->userenv->{branch}; } - $from .= " AND orderstatus <> 4 "; + $from .= " AND orderstatus <> 'cancelled' "; my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier"; $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params); my $sth = $dbh->prepare($query); @@ -2115,7 +2115,7 @@ sub GetHistory { $query .= " WHERE 1 "; - $query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne '4'; + $query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne 'cancelled'; my @query_params = (); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 5ad10fd..8286ff2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2933,7 +2933,7 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items `claimed_date` date default NULL, -- last date a claim was generated `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid) parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent - `orderstatus` tinyint(2) default 0, -- the current status for this line item + `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled' PRIMARY KEY (`ordernumber`), KEY `basketno` (`basketno`), KEY `biblionumber` (`biblionumber`), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 0edb7fb..2289420 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7164,11 +7164,11 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.13.00.XXX"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { my $return_count; - $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus tinyint(2) DEFAULT 0 AFTER parent_ordernumber"); - $dbh->do("UPDATE aqorders SET orderstatus=1 WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)"); - $dbh->do("UPDATE aqorders SET orderstatus=2 WHERE quantity > quantityreceived AND quantityreceived > 0"); - $dbh->do("UPDATE aqorders SET orderstatus=3 WHERE quantity=quantityreceived"); - $dbh->do("UPDATE aqorders SET orderstatus=4 WHERE datecancellationprinted IS NOT NULL"); + $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus varchar(16) DEFAULT 'new' AFTER parent_ordernumber"); + $dbh->do("UPDATE aqorders SET orderstatus='ordered' WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)"); + $dbh->do("UPDATE aqorders SET orderstatus='partial' WHERE quantity > quantityreceived AND quantityreceived > 0"); + $dbh->do("UPDATE aqorders SET orderstatus='complete' WHERE quantity=quantityreceived"); + $dbh->do("UPDATE aqorders SET orderstatus='cancelled' WHERE datecancellationprinted IS NOT NULL"); print "Upgrade to $DBversion done (Bug 5336: Add the new column aqorders.orderstatus)\n"; SetVersion($DBversion); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt index e82c141..fe6623b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt @@ -52,14 +52,13 @@ -