From e53ba5fd65020e80ec7600081df108750b902a30 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 15 Jul 2025 10:58:52 +0200 Subject: [PATCH] Bug 40371: Remove warnings from Budgets.t output t/db_dependent/Budgets.t .. 153/156 Use of uninitialized value in multiplication (*) at /kohadevbox/koha/Koha/Acquisition/Order.pm line 543. Use of uninitialized value in numeric eq (==) at /kohadevbox/koha/Koha/Acquisition/Order.pm line 554. t/db_dependent/Budgets.t .. 154/156 Use of uninitialized value in multiplication (*) at /kohadevbox/koha/Koha/Acquisition/Order.pm line 543. Use of uninitialized value in numeric eq (==) at /kohadevbox/koha/Koha/Acquisition/Order.pm line 554. t/db_dependent/Budgets.t .. 155/156 Use of uninitialized value in addition (+) at /kohadevbox/koha/Koha/Acquisition/Order.pm line 510. This change seems correct, but I am not 100% sure it won't introduce a regression. What about 0 vs undef? --- Koha/Acquisition/Order.pm | 7 ++++--- t/db_dependent/Budgets.t | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index 289e4a31153..7f097cc596d 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -503,12 +503,13 @@ sub populate_with_prices_for_ordering { my $discount = $self->discount || 0; $discount /= 100 if $discount > 1; + my $unitprice = $self->unitprice // 0; if ( $bookseller->listincgst ) { # The user entered the prices tax included - $self->unitprice( $self->unitprice + 0 ); - $self->unitprice_tax_included( $self->unitprice ); + $self->unitprice($unitprice); + $self->unitprice_tax_included($unitprice); $self->rrp_tax_included( $self->rrp ); # price tax excluded = price tax included / ( 1 + tax rate ) @@ -536,7 +537,7 @@ sub populate_with_prices_for_ordering { } else { # The user entered the prices tax excluded - $self->unitprice_tax_excluded( $self->unitprice ); + $self->unitprice_tax_excluded($unitprice); $self->rrp_tax_excluded( $self->rrp ); # price tax included = price tax excluded * ( 1 - tax rate ) diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t index 309c949ddf3..590c8673f24 100755 --- a/t/db_dependent/Budgets.t +++ b/t/db_dependent/Budgets.t @@ -1,6 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 156; +use Test::More tests => 157; +use Test::NoWarnings; use JSON; BEGIN { -- 2.34.1