From 4e215d20087f36e05712718eaadbebd157cd3c19 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 21 Feb 2024 12:34:50 +0000 Subject: [PATCH] Bug 36018: Rename orders->filter_by_current Current is a bit misleading here. It means the ones that are not cancelled. We already use the filter_out_etc naming schema. So in harmony with that, we switch it to filter_out_cancelled. Test plan: Run t/db_dependent/Koha/Acquisition/Order.t Run git grep -l '::Orders' | xargs grep filter_by_current * All occurrences should be related to Recalls, not Orders. Go to acqui/basket.pl. Delete a whole basket who has some active and some cancelled lines. Signed-off-by: Marcel de Rooy Signed-off-by: Janusz Kaczmarek --- Koha/Acquisition/Orders.pm | 11 +++++++---- acqui/basket.pl | 2 +- t/db_dependent/Koha/Acquisition/Order.t | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm index 2438886ac8..8672de10c9 100644 --- a/Koha/Acquisition/Orders.pm +++ b/Koha/Acquisition/Orders.pm @@ -149,7 +149,10 @@ sub filter_by_lates { my $new_rs = $orders->filter_by_active; -Returns a new resultset filtering orders that are not active. +Returns a new resultset containing active orders only. + +Note: An active order (line) has status ordered or partial, or it has status new +and the basket is marked as standing order. =cut @@ -167,15 +170,15 @@ sub filter_by_active { ); } -=head3 filter_by_current +=head3 filter_out_cancelled - $orders->filter_by_current + $orders->filter_out_cancelled Return the orders of the set that have not been cancelled. =cut -sub filter_by_current { +sub filter_out_cancelled { my ($self) = @_; return $self->search( { diff --git a/acqui/basket.pl b/acqui/basket.pl index 6401125d01..61b077d38b 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -127,7 +127,7 @@ if ( $op eq 'cud-delete_confirm' ) { my $delbiblio = $query->param('delbiblio'); my $basket_obj = Koha::Acquisition::Baskets->find($basketno); - my $orders = $basket_obj->orders->filter_by_current; + my $orders = $basket_obj->orders->filter_out_cancelled; my @cannotdelbiblios; diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t index 10fdfa4685..94c30fa3d4 100755 --- a/t/db_dependent/Koha/Acquisition/Order.t +++ b/t/db_dependent/Koha/Acquisition/Order.t @@ -590,7 +590,7 @@ subtest 'filter_by_late' => sub { $schema->storage->txn_rollback; }; -subtest 'filter_by_current & filter_by_cancelled' => sub { +subtest 'filter_out_cancelled & filter_by_cancelled' => sub { plan tests => 2; $schema->storage->txn_begin; @@ -631,7 +631,7 @@ subtest 'filter_by_current & filter_by_cancelled' => sub { } ); - is( $orders->filter_by_current->count, 2); + is( $orders->filter_out_cancelled->count, 2); is( $orders->filter_by_cancelled->count, 1); -- 2.30.2