From fcd336168300b453749d5ec12355a74fd4ff57f3 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 7 Jan 2021 16:16:00 -0300 Subject: [PATCH] Bug 25670: New orders included only if standing The original implementation included new orders regardless they were standing orders. This patch makes the query respect that conditions found on C4::Acquisitions::SearchOrders. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Acquisition/Orders.t => FAIL: More orders than expected are returned 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! New orders are only considered if the basket they are attached to, is marked as standing! 5. Verify the tests make sense 6. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/Acquisition/Orders.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm index 67b5dd0244..2b06b81d1e 100644 --- a/Koha/Acquisition/Orders.pm +++ b/Koha/Acquisition/Orders.pm @@ -143,8 +143,13 @@ sub filter_by_active { my ($self) = @_; return $self->search( { - orderstatus => [ 'new', 'ordered', 'partial' ] - } + '-or' => [ + { 'basket.is_standing' => 1, + 'orderstatus' => [ 'new', 'ordered', 'partial' ] }, + { 'orderstatus' => [ 'ordered', 'partial' ] } + ] + }, + { join => 'basket' } ); } -- 2.39.5