From 7a54e4df535d56422285d85ce92533f5ce8b57ed Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 5 Jan 2024 18:36:51 +0000 Subject: [PATCH] Bug 35717: Tidy --- Koha/Acquisition/Order.pm | 6 ++-- Koha/EDI.pm | 2 +- acqui/addorder.pl | 2 +- .../data/mysql/atomicupdate/bug_28844.pl | 14 ++++---- t/db_dependent/Koha/Acquisition/Order.t | 32 ++++++++++++------- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index 7c3cbaa0bbb..de084b0271b 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -147,7 +147,7 @@ sub cancel { # If ordered from a suggestion, revert the suggestion status to ACCEPTED my $suggestions = $self->suggestions; - while ( my $suggestion = $suggestions->next ){ + while ( my $suggestion = $suggestions->next ) { if ( $suggestion && $suggestion->STATUS eq "ORDERED" ) { ModSuggestion( { @@ -309,10 +309,10 @@ to the order. =cut sub suggestions { - my ( $self ) = @_; + my ($self) = @_; my $rs = $self->_result->suggestions; return unless $rs; - return Koha::Suggestions->_new_from_dbic( $rs ); + return Koha::Suggestions->_new_from_dbic($rs); } =head3 current_item_level_holds diff --git a/Koha/EDI.pm b/Koha/EDI.pm index 0cacb45e6a5..447c38add94 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -332,7 +332,7 @@ sub process_invoice { if ($order) { my $order_koha_object = Koha::Acquisition::Orders->find($ordernumber); - my $suggestions = $order_koha_object->suggestions; + my $suggestions = $order_koha_object->suggestions; while ( my $suggestion = $suggestions->next ) { ModSuggestion( { diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 5ffe3d8cc52..8485ca260be 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -351,7 +351,7 @@ if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { { suggestionid => $suggestionid, biblionumber => $orderinfo->{biblionumber}, - ordernumber => $order->ordernumber, + ordernumber => $order->ordernumber, STATUS => 'ORDERED', } ); diff --git a/installer/data/mysql/atomicupdate/bug_28844.pl b/installer/data/mysql/atomicupdate/bug_28844.pl index a11b3f154be..c36354b7b7d 100755 --- a/installer/data/mysql/atomicupdate/bug_28844.pl +++ b/installer/data/mysql/atomicupdate/bug_28844.pl @@ -1,17 +1,19 @@ use Modern::Perl; return { - bug_number => "28844", + bug_number => "28844", description => "Link orders and suggestions", - up => sub { + up => sub { my ($args) = @_; - my ($dbh, $out) = @$args{qw(dbh out)}; - unless ( column_exists('suggestions', 'ordernumber') ) { - $dbh->do(q{ + my ( $dbh, $out ) = @$args{qw(dbh out)}; + unless ( column_exists( 'suggestions', 'ordernumber' ) ) { + $dbh->do( + q{ ALTER TABLE suggestions ADD COLUMN `ordernumber` int(10) DEFAULT NULL COMMENT 'links suggestion to an acquisitions order (aqorders.ordernumber)' AFTER biblionumber, ADD CONSTRAINT `suggestions_ordernumber` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE SET NULL ON UPDATE CASCADE - }); + } + ); say $out "Added column 'suggestions.ordernumber'"; } }, diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t index cbe2b5e089f..429dd10d98c 100755 --- a/t/db_dependent/Koha/Acquisition/Order.t +++ b/t/db_dependent/Koha/Acquisition/Order.t @@ -221,10 +221,14 @@ subtest 'suggestions' => sub { ); my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); - is( ref( $order->suggestions ), 'Koha::Suggestions', - '->suggestions should return a Koha::Suggestions object'); - is( $order->suggestions->count, 0, - '->suggestions should return empty set if no linked suggestion'); + is( + ref( $order->suggestions ), 'Koha::Suggestions', + '->suggestions should return a Koha::Suggestions object' + ); + is( + $order->suggestions->count, 0, + '->suggestions should return empty set if no linked suggestion' + ); $o = $builder->build_object( { @@ -239,10 +243,14 @@ subtest 'suggestions' => sub { ); $order = Koha::Acquisition::Orders->find( $o->ordernumber ); - is( ref( $order->suggestions ), 'Koha::Suggestions', - '->suggestions should return a Koha::Suggestions object'); - is( $order->suggestions->count, 1, - '->suggestions should return linked suggestions'); + is( + ref( $order->suggestions ), 'Koha::Suggestions', + '->suggestions should return a Koha::Suggestions object' + ); + is( + $order->suggestions->count, 1, + '->suggestions should return linked suggestions' + ); $schema->storage->txn_rollback; }; @@ -957,11 +965,11 @@ subtest 'cancel() tests' => sub { { class => 'Koha::Suggestions', value => { - biblionumber => $biblio_id, + biblionumber => $biblio_id, suggesteddate => dt_from_string, - STATUS => 'ORDERED', - archived => 0, - ordernumber => $order->id, + STATUS => 'ORDERED', + archived => 0, + ordernumber => $order->id, } } ); -- 2.30.2