From f0a3b98cdb1ae0938403bf919f5494e2708821c4 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 --- ...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.20.1