From eb0e1e6bba31a2e741ed9b074ba7e1c9dd0c6083 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 22 Oct 2013 13:49:32 +0000 Subject: [PATCH] Bug 5336: (follow-up) improve setting 'partial' order status during upgrade This patch modifies the logic to set the partial status for an order to verify that: - at least one item has been received already - the order belongs to a closed basket Signed-off-by: Galen Charlton --- installer/data/mysql/updatedatabase.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 89ce9f4950..b031ed8279 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7310,7 +7310,20 @@ $DBversion = "3.13.00.032"; if ( CheckVersion($DBversion) ) { $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 ordernumber IN ( SELECT parent_ordernumber FROM ( SELECT DISTINCT(parent_ordernumber) FROM aqorders WHERE ordernumber != parent_ordernumber) AS aq )"); + $dbh->do(q{ + UPDATE aqorders SET orderstatus='partial' + WHERE quantity > quantityreceived + AND quantityreceived > 0 + AND ordernumber IN ( + SELECT parent_ordernumber + FROM ( + SELECT DISTINCT(parent_ordernumber) + FROM aqorders + WHERE ordernumber != parent_ordernumber + ) AS aq + ) + AND basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL) + }); $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"; -- 2.11.4.GIT