From b7448dbd7531b24b7c54f254164881e144ce6b00 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 Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- 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 598790d414..f17ec3efa2 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 c5b86a5c19..64779bdffe 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -143,7 +143,7 @@ if ( $op eq 'cud-delete-order' ) { 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 f0da354697..973170d4ca 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.39.5