Bug 33028: Perltidy database update script
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit f0a3b98cdb
)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
0bd5fb0bb6
commit
495a4a7477
1 changed files with 20 additions and 13 deletions
|
@ -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.";
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue