[Koha-bugs] [Bug 8253] Fine doubling

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Aug 6 15:23:10 CEST 2012


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8253

--- Comment #12 from Julian Maurice <julian.maurice at biblibre.com> ---
I replayed my tests. Here's what I did:

# empty the accounlines table
mysql> delete from accountlines;

# run fines script
$ misc/cronjobs/fines.pl

mysql> select * from accountlines\G
*************************** 1. row ***************************
   borrowernumber: 58
        accountno: 1
       itemnumber: 2
             date: 2012-08-06
           amount: 112.000000
      description: Orchidées 06/01/2012 23:59
          dispute: NULL
      accounttype: FU
amountoutstanding: 112.000000
    lastincrement: 112.000000
        timestamp: 2012-08-06 14:46:45
        notify_id: 0
     notify_level: 0
             note: NULL
       manager_id: NULL
1 row in set (0.00 sec)

# simulate that fines script was run pre-3.8
mysql> update accountlines set description="Orchidées 06/01/2012";

# re-run
$ misc/cronjobs/fines.pl

# lines are duplicated (OK)
mysql> select * from accountlines\G
*************************** 1. row ***************************
   borrowernumber: 58
        accountno: 1
       itemnumber: 2
             date: 2012-08-06
           amount: 112.000000
      description: Orchidées 06/01/2012
          dispute: NULL
      accounttype: FU
amountoutstanding: 112.000000
    lastincrement: 112.000000
        timestamp: 2012-08-06 15:01:49
        notify_id: 0
     notify_level: 0
             note: NULL
       manager_id: NULL
*************************** 2. row ***************************
   borrowernumber: 58
        accountno: 2
       itemnumber: 2
             date: 2012-08-06
           amount: 112.000000
      description: Orchidées 06/01/2012 23:59
          dispute: NULL
      accounttype: FU
amountoutstanding: 112.000000
    lastincrement: 112.000000
        timestamp: 2012-08-06 15:01:52
        notify_id: 0
     notify_level: 0
             note: NULL
       manager_id: NULL
2 rows in set (0.00 sec)

# run the update script
$ perl installer/data/mysql/updatedatabase.pl 
# by the way, this warning is introduced by your patch:
"my" variable $sth masks earlier declaration in same scope at
installer/data/mysql/updatedatabase.pl line 5697.
Upgrade to 3.09.00.XXX done (Fix fine descriptions and remove duplicate fines)

# lines are still duplicated, but description has changed
mysql> select * from accountlines\G
*************************** 1. row ***************************
   borrowernumber: 58
        accountno: 1
       itemnumber: 2
             date: 2012-08-06
           amount: 112.000000
      description: Orchidées 06/01/2012 23:59
          dispute: NULL
      accounttype: FU
amountoutstanding: 112.000000
    lastincrement: 112.000000
        timestamp: 2012-08-06 15:02:25
        notify_id: 0
     notify_level: 0
             note: NULL
       manager_id: NULL
*************************** 2. row ***************************
   borrowernumber: 58
        accountno: 2
       itemnumber: 2
             date: 2012-08-06
           amount: 112.000000
      description: Orchidées 06/01/2012 23:59
          dispute: NULL
      accounttype: FU
amountoutstanding: 112.000000
    lastincrement: 112.000000
        timestamp: 2012-08-06 15:01:52
        notify_id: 0
     notify_level: 0
             note: NULL
       manager_id: NULL
2 rows in set (0.00 sec)


This is because, in the update process, you try to delete only lines that do
not contain 23:59:

$query = "SELECT * FROM accountlines WHERE description LIKE ? AND description
NOT LIKE ?";
...
foreach my $keeper ( @$results ) {
    my ( $description_to_match ) = split( / 23:59/, $keeper->{'description'} );
    $description_to_match .= '%';
    $sth->execute( $description_to_match, $keeper->{'description'} );
    while ( my $f = $sth->fetchrow_hashref() ) {
        ...
        my $sql = "DELETE FROM accountlines WHERE borrowernumber = ? AND
accountno = ? AND itemnumber = ? AND date = ? AND description = ? LIMIT 1";
       
$dbh->do($sql,undef,$f->{'borrowernumber'},$f->{'accountno'},$f->{'itemnumber'},
$f->{'date'}, $f->{'description'});
    }
}

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list