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
9 die("This script cannot be run from the command line.") unless ($main::form);
13 die($dbup_locale->text("Database update error:") .
14 "<br>$msg<br>" . $DBI::errstr);
18 my ($query, $may_fail) = @_;
20 if (!$dbh->do($query)) {
21 mydberror($query) unless ($may_fail);
31 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 =
32 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)|;
33 my $sth_all_groups = prepare_execute_query($form, $dbh, $query);
34 while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife
35 push @queries, "UPDATE ap set amount =" . $hash_ref->{acamount} . " WHERE id = " . $hash_ref->{id};
37 $sth_all_groups->finish();
40 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 =
41 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)|;
42 my $sth_all_groups = prepare_execute_query($form, $dbh, $query);
43 while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife
44 # Falls wir keine alte buggy Installation haben, ist es super die
45 # Gewissheit zu haben, dass kein acc_trans-Eintrag ohne trans_id vorhanden ist
46 push @queries, "UPDATE ar set amount =" . $hash_ref->{acamount} . " WHERE id = " . $hash_ref->{id};
48 $sth_all_groups->finish();
50 # if in doubt use brute force ;-) jb
51 foreach my $query (@queries){
52 my $sth = prepare_query($form, $dbh, $query);
53 do_statement($form,$sth,$query);