1 # @tag: rundungsfehler_korrigieren_BUG1328-2
2 # @description: Die entsprechende Cent-Abweichung die durch den Rundungsfehler in Bug 1328 behoben wurde, entsprechende für alte Buchungen korrigieren.
3 # @depends: release_2_6_0
8 die("This script cannot be run from the command line.") unless ($main::form);
12 die($dbup_locale->text("Database update error:") .
13 "<br>$msg<br>" . $DBI::errstr);
17 my ($query, $may_fail) = @_;
19 if (!$dbh->do($query)) {
20 mydberror($query) unless ($may_fail);
30 my $query = qq|select distinct id,acamount from (select ap.id,ap.amount as apamount, ac.amount*-1 as acamount from ap left join acc_trans ac on (ac.trans_id =
31 ap.id) where ac.chart_id IN (select id from chart where link ='AP' OR link like '%:AP' OR link like 'AP:%')) as foo where apamount + 0.01 = abs(acamount)|;
32 my $sth_all_groups = prepare_execute_query($form, $dbh, $query);
33 while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife
34 push @queries, "UPDATE ap set amount =" . $hash_ref->{acamount} . " WHERE id = " . $hash_ref->{id};
36 $sth_all_groups->finish();
39 my $query = qq|select distinct id,acamount from (select ar.id, ar.amount as aramount, ac.amount*-1 as acamount from ar left join acc_trans ac on (ac.trans_id =
40 ar.id) where ac.chart_id IN (select id from chart where link ='AR' OR link like '%:AR' OR link like 'AR:%')) as foo where aramount + 0.01 = abs(acamount)|;
41 my $sth_all_groups = prepare_execute_query($form, $dbh, $query);
42 while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife
43 # Falls wir keine alte buggy Installation haben, ist es super die
44 # Gewissheit zu haben, dass kein acc_trans-Eintrag ohne trans_id vorhanden ist
45 push @queries, "UPDATE ar set amount =" . $hash_ref->{acamount} . " WHERE id = " . $hash_ref->{id};
47 $sth_all_groups->finish();
49 # if in doubt use brute force ;-) jb
50 foreach my $query (@queries){
51 my $sth = prepare_query($form, $dbh, $query);
52 do_statement($form,$sth,$query);