Bug 15036: Do not overwrite complete status in basket ops
Reopening or closing a basket should preserve the completed
status for receipted orders.
This patch excludes orderlines with the completed status
from having their status rewritten as a result of the
change in basket status
Made the subroutines involved more efficient by removing an
unnecessary loop and by not fetching a large amount of
superfluous data
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 4a4dbbf123)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
parent
ee185cfd1a
commit
9dace4e21e
|
|
@ -237,24 +237,11 @@ close a basket (becomes unmodifiable, except for receives)
|
|||
sub CloseBasket {
|
||||
my ($basketno) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "
|
||||
UPDATE aqbasket
|
||||
SET closedate=now()
|
||||
WHERE basketno=?
|
||||
";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($basketno);
|
||||
$dbh->do('UPDATE aqbasket SET closedate=now() WHERE basketno=?', {}, $basketno );
|
||||
|
||||
my @orders = GetOrders($basketno);
|
||||
foreach my $order (@orders) {
|
||||
$query = qq{
|
||||
UPDATE aqorders
|
||||
SET orderstatus = 'ordered'
|
||||
WHERE ordernumber = ?;
|
||||
};
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute($order->{'ordernumber'});
|
||||
}
|
||||
$dbh->do( q{UPDATE aqorders SET orderstatus = 'ordered' WHERE basketno = ? AND orderstatus != 'complete'},
|
||||
{}, $basketno);
|
||||
return;
|
||||
}
|
||||
|
||||
=head3 ReopenBasket
|
||||
|
|
@ -268,24 +255,15 @@ reopen a basket
|
|||
sub ReopenBasket {
|
||||
my ($basketno) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "
|
||||
UPDATE aqbasket
|
||||
SET closedate=NULL
|
||||
WHERE basketno=?
|
||||
";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($basketno);
|
||||
$dbh->do( q{UPDATE aqbasket SET closedate=NULL WHERE basketno=?}, {}, $basketno );
|
||||
|
||||
my @orders = GetOrders($basketno);
|
||||
foreach my $order (@orders) {
|
||||
$query = qq{
|
||||
UPDATE aqorders
|
||||
SET orderstatus = 'new'
|
||||
WHERE ordernumber = ?;
|
||||
};
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute($order->{'ordernumber'});
|
||||
}
|
||||
$dbh->do( q{
|
||||
UPDATE aqorders
|
||||
SET orderstatus = 'new'
|
||||
WHERE basketno = ?
|
||||
AND orderstatus != 'complete'
|
||||
}, {}, $basketno);
|
||||
return;
|
||||
}
|
||||
|
||||
#------------------------------------------------------------#
|
||||
|
|
|
|||
Loading…
Reference in New Issue