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

(-)a/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl (-12 / +20 lines)
Lines 1-5 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2016 Jacek Ablewicz
4
#
3
# This file is part of Koha.
5
# This file is part of Koha.
4
#
6
#
5
# Koha is free software; you can redistribute it and/or modify it
7
# Koha is free software; you can redistribute it and/or modify it
Lines 97-106 sub Bug_17135_fix { Link Here
97
        ## which does not require any correction
99
        ## which does not require any correction
98
        next if ($fine->{description} =~ /$due_qr/);
100
        next if ($fine->{description} =~ /$due_qr/);
99
101
100
        {
102
        if( !$old_date_pattern ) {
101
            ## for extracting old due date from fine description
103
            ## for extracting old due date from fine description
102
            ## not used for fixing anything, logging/debug purposes only
104
            ## not used for fixing anything, logging/debug purposes only
103
            last if $old_date_pattern;
104
            $old_date_pattern = $due;
105
            $old_date_pattern = $due;
105
            $old_date_pattern =~ s/[A-Za-z]/\[A-Za-z\]/g;
106
            $old_date_pattern =~ s/[A-Za-z]/\[A-Za-z\]/g;
106
            $old_date_pattern =~ s/[0-9]/\\d/g;
107
            $old_date_pattern =~ s/[0-9]/\\d/g;
Lines 174-188 sub Bug_17135_fix { Link Here
174
        };
175
        };
175
    }
176
    }
176
177
177
    if ($verbose) {
178
    if( $verbose ) {
178
        Warn("Fine records with mismatched old vs current due dates: $different_dates_cnt");
179
        Warn( "Fine records with mismatched old vs current due dates: $different_dates_cnt" );
179
        Warn("Non-accruing accountlines FU records (item not due): ".$not_due_not_accruning_cnt);
180
        Warn( "Non-accruing accountlines FU records (item not due): ".$not_due_not_accruning_cnt );
180
        Warn("Non-accruing accountlines FU records (item due): ".$due_not_accruning_cnt);
181
        Warn( "Non-accruing accountlines FU records (item due): ".$due_not_accruning_cnt );
181
    }
182
    }
182
183
183
    if (@$forfixing > 0) {
184
        Warn("Dry run (test only mode), skipping ".scalar(@$forfixing)." database changes.") unless ($confirm);
185
    }
186
    my $updated_cnt = 0;
184
    my $updated_cnt = 0;
187
    my $update_sql = "UPDATE accountlines SET accounttype = 'F' WHERE accounttype = 'FU' AND accountlines_id = ? LIMIT 1";
185
    my $update_sql = "UPDATE accountlines SET accounttype = 'F' WHERE accounttype = 'FU' AND accountlines_id = ? LIMIT 1";
188
    for my $fine (@$forfixing) {
186
    for my $fine (@$forfixing) {
Lines 197-204 sub Bug_17135_fix { Link Here
197
        $updated_cnt += $rows_affected;
195
        $updated_cnt += $rows_affected;
198
        logaction("FINES", "FU", $fine->{borrowernumber}, $logentry) if ($log);
196
        logaction("FINES", "FU", $fine->{borrowernumber}, $logentry) if ($log);
199
    }
197
    }
200
    if (@$forfixing > 0 && $confirm && $mode eq 'production') {
198
201
        Warn("Database update done, $updated_cnt".((@$forfixing == $updated_cnt)? "": "/".scalar(@$forfixing))." fine records closed successfully.");
199
    # Regardless of verbose, we report at least a number here
200
    if( @$forfixing > 0 ) {
201
        if( $confirm && $mode eq 'production') {
202
            Warn( "Database update done, $updated_cnt".
203
                ( @$forfixing == $updated_cnt? "": ( "/". @$forfixing )).
204
                " fine records closed successfully." );
205
        } else {
206
            Warn( "Dry run (test only mode), skipping ". @$forfixing.
207
                " fine records." );
208
        }
209
    } else {
210
        Warn( "No fine records needed to be fixed" );
202
    }
211
    }
203
}
212
}
204
213
205
- 

Return to bug 17135