Bug 5336: (follow-up) fix case where partial status was not correctly set
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 1 Oct 2013 12:06:11 +0000 (14:06 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 22 Oct 2013 13:30:09 +0000 (13:30 +0000)
An order (o1) is considered as partially received if (at least) another
order (o2) has the o1.ordernumber == o2.parent_ordernumber and the
quantity received is < to the quantity (to receive) and o1.ordernumber
!= o1.parent_ordernumber.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
installer/data/mysql/updatedatabase.pl

index 7d8832e..5ac921d 100755 (executable)
@@ -7311,7 +7311,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     my $return_count;
     $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='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("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";