Bug 20728: Proof that there is no cheating
To make sure the replacing code will acchieve the same things as the actual one, we replace the raw SQL query with the DBIC version of it. Then the tests will show us that they are equivalent. Test plan: Apply only this patch, run the tests, confirm they pass. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
82244a30b7
commit
220c4906bf
1 changed files with 11 additions and 24 deletions
|
@ -1284,30 +1284,17 @@ Returns a reference-to-hash describing the last order received for a subscriptio
|
|||
|
||||
sub GetLastOrderReceivedFromSubscriptionid {
|
||||
my ( $subscriptionid ) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq|
|
||||
SELECT * FROM aqorders
|
||||
LEFT JOIN subscription
|
||||
ON ( aqorders.subscriptionid = subscription.subscriptionid )
|
||||
WHERE aqorders.subscriptionid = ?
|
||||
AND aqorders.datereceived =
|
||||
(
|
||||
SELECT MAX( aqorders.datereceived )
|
||||
FROM aqorders
|
||||
LEFT JOIN subscription
|
||||
ON ( aqorders.subscriptionid = subscription.subscriptionid )
|
||||
WHERE aqorders.subscriptionid = ?
|
||||
AND aqorders.datereceived IS NOT NULL
|
||||
)
|
||||
ORDER BY ordernumber DESC
|
||||
LIMIT 1
|
||||
|;
|
||||
my $result_set =
|
||||
$dbh->selectall_arrayref( $query, { Slice => {} }, $subscriptionid, $subscriptionid );
|
||||
|
||||
# result_set assumed to contain 1 match
|
||||
return $result_set->[0];
|
||||
|
||||
my $lastOrderReceived = Koha::Acquisition::Orders->search(
|
||||
{
|
||||
subscriptionid => $subscriptionid,
|
||||
datereceived => { '!=' => undef }
|
||||
},
|
||||
{
|
||||
order_by =>
|
||||
[ { -desc => 'datereceived' }, { -desc => 'ordernumber' } ]
|
||||
}
|
||||
);
|
||||
return $lastOrderReceived->count ? $lastOrderReceived->next->unblessed : undef;
|
||||
}
|
||||
|
||||
#------------------------------------------------------------#
|
||||
|
|
Loading…
Reference in a new issue