View | Details | Raw Unified | Return to bug 33028
Collapse All | Expand All

(-)a/Koha/CirculationRules.pm (+7 lines)
Lines 24-29 use Koha::Exceptions; Link Here
24
use Koha::CirculationRule;
24
use Koha::CirculationRule;
25
use Koha::Caches;
25
use Koha::Caches;
26
use Koha::Cache::Memory::Lite;
26
use Koha::Cache::Memory::Lite;
27
use Koha::Number::Price;
27
28
28
use base qw(Koha::Objects);
29
use base qw(Koha::Objects);
29
30
Lines 388-393 sub set_rule { Link Here
388
        }
389
        }
389
    )->next();
390
    )->next();
390
391
392
    if ( $rule
393
    && ( $rule->rule_name eq 'overduefinescap' || $rule->rule_name eq 'fine' ) )
394
    {
395
        $rule_value = Koha::Number::Price->new($rule_value)->unformat;
396
    }
397
391
    if ($rule) {
398
    if ($rule) {
392
        if ( defined $rule_value ) {
399
        if ( defined $rule_value ) {
393
            $rule->rule_value($rule_value);
400
            $rule->rule_value($rule_value);
(-)a/installer/data/mysql/atomicupdate/fix_calc_fines_fr-currency_21-11-MT39815.pl (-1 / +51 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
return {
4
    bug_number => "BUG_33028",
5
    description =>
6
"Fix calculations around fines and values with comma as decimal separator",
7
    up => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        my $rules = $dbh->selectall_arrayref(
12
q|select * from circulation_rules where rule_name IN ('fine', 'overduefinescap')|,
13
            { Slice => {} }
14
        );
15
16
        my $query = $dbh->prepare(
17
            "UPDATE circulation_rules SET rule_value = ? where id = ?");
18
19
        foreach my $rule ( @{$rules} ) {
20
            my $rule_id    = $rule->{'id'};
21
            my $rule_value = $rule->{'rule_value'};
22
            if ( $rule_value =~ /[a-zA-Z]/ ) {
23
                die(
24
                    sprintf(
25
                        'No only numbers in rule id %s ("%s") - fix it before restart this update',
26
                        $rule_id, $rule_value
27
                    )
28
                );
29
            }
30
            else {
31
                if ( $rule_value =~ /,/ ) {
32
                    if ( $rule_value !~ /,.*?,/ ) {
33
                        $rule_value =~ s/,/./;
34
                        $query->execute( $rule_value, $rule_id );
35
                    }
36
                    else {
37
                        die(
38
                            sprintf(
39
                                'Many commas in rule id %s ("%s") - fix it before restart this update',
40
                                $rule_id, $rule_value
41
                            )
42
                        );
43
                    }
44
                }
45
            }
46
47
        }
48
        say $out
49
        "BUG_33028 - Patch applied";
50
    },
51
  }

Return to bug 33028