@@ -, +, @@ orderstatus + execute sql queries in unit tests into a transaction. --- 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(-) --- a/C4/Acquisition.pm +++ a/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); @@ -1384,7 +1384,7 @@ sub ModReceiveOrder { $sth=$dbh->prepare(" UPDATE aqorders SET quantity = ?, - orderstatus = 2 + orderstatus = 'partial' WHERE ordernumber = ? "); @@ -1400,7 +1400,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); @@ -1412,7 +1412,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; @@ -1463,7 +1463,7 @@ sub CancelReceipt { SET quantityreceived = ?, datereceived = ?, invoiceid = ?, - orderstatus = 1 + orderstatus = 'ordered' WHERE ordernumber = ? }; $sth = $dbh->prepare($query); @@ -1491,7 +1491,7 @@ sub CancelReceipt { $query = qq{ UPDATE aqorders SET quantity = ?, - orderstatus = 1 + orderstatus = 'ordered' WHERE ordernumber = ? }; $sth = $dbh->prepare($query); @@ -1631,7 +1631,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); @@ -1924,7 +1924,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); @@ -2047,7 +2047,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 = (); --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -2931,7 +2931,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`), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -7113,11 +7113,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); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt @@ -52,14 +52,13 @@ -