Bug 18736: (QA follow-up) Cosmetic changes
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 28 Sep 2018 08:09:01 +0000 (10:09 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 25 Mar 2019 14:29:30 +0000 (14:29 +0000)
[1] Resolve warnings like:
Use of uninitialized value $rounding_pref in string eq at /usr/share/koha/devclone/C4/Acquisition.pm line 2040.

[2] Fixing unusual use of whitespace too.

[3] Remove list operator from get_rounding_sql return. Only used in scalar
context.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 9922d2bf40e2b7429f300d4d73134f9fef3b8c65)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Acquisition.pm

index 9373868..ed09360 100644 (file)
@@ -2002,7 +2002,7 @@ sub TransferOrder {
 
 =head3 get_rounding_sql
 
-    $rounding_sql = get_rounding_sql("mysql_variable_to_round_string");
+    $rounding_sql = get_rounding_sql($column_name);
 
 returns the correct SQL routine based on OrderPriceRounding system preference.
 
@@ -2010,9 +2010,11 @@ returns the correct SQL routine based on OrderPriceRounding system preference.
 
 sub get_rounding_sql {
     my ( $round_string ) = @_;
-    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
-    if ( $rounding_pref eq "nearest_cent"  ) { return ("CAST($round_string*100 AS UNSIGNED)/100"); }
-    else                                     { return ("$round_string"); }
+    my $rounding_pref = C4::Context->preference('OrderPriceRounding') // q{};
+    if ( $rounding_pref eq "nearest_cent"  ) {
+        return "CAST($round_string*100 AS UNSIGNED)/100";
+    }
+    return $round_string;
 }
 
 =head3 get_rounded_price
@@ -2025,9 +2027,11 @@ returns a price rounded as specified in OrderPriceRounding system preference.
 
 sub get_rounded_price {
     my ( $price ) =  @_;
-    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
-    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->round(); }
-    else                                   { return $price; }
+    my $rounding_pref = C4::Context->preference('OrderPriceRounding') // q{};
+    if( $rounding_pref eq 'nearest_cent' ) {
+        return Koha::Number::Price->new( $price )->round();
+    }
+    return $price;
 }