From 6deab87d2dc9ecde15a21f9e01a0396a336ede5a Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Tue, 11 Jul 2023 13:23:40 +0000 Subject: [PATCH] Bug 33028: Perltidy database update script Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit f0a3b98cdb1ae0938403bf919f5494e2708821c4) Signed-off-by: Fridolin Somers (cherry picked from commit 495a4a7477c715b56a4f96f07c455df029bbcd1c) Signed-off-by: Pedro Amorim --- ...ix_calc_fines_fr-currency_21-11-MT39815.pl | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/installer/data/mysql/atomicupdate/fix_calc_fines_fr-currency_21-11-MT39815.pl b/installer/data/mysql/atomicupdate/fix_calc_fines_fr-currency_21-11-MT39815.pl index f3203dc764..1ce01a0dca 100755 --- a/installer/data/mysql/atomicupdate/fix_calc_fines_fr-currency_21-11-MT39815.pl +++ b/installer/data/mysql/atomicupdate/fix_calc_fines_fr-currency_21-11-MT39815.pl @@ -1,32 +1,39 @@ use Modern::Perl; return { - bug_number => "33028", + bug_number => "33028", description => "Fix wrongly formatted values for monetary values in circulation rules", - up => sub { + up => sub { my ($args) = @_; - my ($dbh, $out) = @$args{qw(dbh out)}; + my ( $dbh, $out ) = @$args{qw(dbh out)}; my $rules = $dbh->selectall_arrayref( q|SELECT * FROM circulation_rules WHERE rule_name IN ('fine', 'overduefinescap', 'recall_overdue_fine', 'article_request_fee')|, { Slice => {} } ); - my $query = $dbh->prepare( - "UPDATE circulation_rules SET rule_value = ? WHERE id = ?"); + my $query = $dbh->prepare("UPDATE circulation_rules SET rule_value = ? WHERE id = ?"); my $error; for my $rule ( @{$rules} ) { - my $library = defined($rule->{'branchcode'}) ? $rule->{'branchcode'} : "All"; - my $category = defined($rule->{'categorycode'}) ? $rule->{'categorycode'} : "All"; - my $itemtype = defined($rule->{'itemtype'}) ? $rule->{'itemtype'} : "All"; - if ( !( $rule->{'rule_value'} =~ /^[0-9.]*$/ )) { - $error .= "Rule ID: $rule->{'id'} ($library-$category-$itemtype) \tRule: $rule->{'rule_name'}\tValue: $rule->{'rule_value'}\n"; + my $library = + defined( $rule->{'branchcode'} ) ? $rule->{'branchcode'} : "All"; + my $category = + defined( $rule->{'categorycode'} ) + ? $rule->{'categorycode'} + : "All"; + my $itemtype = + defined( $rule->{'itemtype'} ) ? $rule->{'itemtype'} : "All"; + if ( !( $rule->{'rule_value'} =~ /^[0-9.]*$/ ) ) { + $error .= + "Rule ID: $rule->{'id'} ($library-$category-$itemtype) \tRule: $rule->{'rule_name'}\tValue: $rule->{'rule_value'}\n"; } } - if ( $error ) { - die("Circulation rules contain invalid monetary values:\n$error\nPlease fix these before you restart the update."); + if ($error) { + die( + "Circulation rules contain invalid monetary values:\n$error\nPlease fix these before you restart the update." + ); } say $out "Circulation rules have been validated. All circulation rule values are correctly formatted."; }, - }; +}; -- 2.39.5