X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=sql%2FPg-upgrade2%2Frundungsfehler_korrigieren_BUG1328.pl;h=fb742b081c17cb46f995f92a9394eb72c2ca0c58;hb=4e33311d0fd7167148faec7564db8acc07239054;hp=1e9b00d08c4a987cc3130e3781910d5223ba6545;hpb=4602be1fb9b8e38e36a86c40fce59db74c62949e;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/rundungsfehler_korrigieren_BUG1328.pl b/sql/Pg-upgrade2/rundungsfehler_korrigieren_BUG1328.pl
index 1e9b00d08..fb742b081 100644
--- a/sql/Pg-upgrade2/rundungsfehler_korrigieren_BUG1328.pl
+++ b/sql/Pg-upgrade2/rundungsfehler_korrigieren_BUG1328.pl
@@ -1,47 +1,35 @@
# @tag: rundungsfehler_korrigieren_BUG1328-2
# @description: Die entsprechende Cent-Abweichung die durch den Rundungsfehler in Bug 1328 behoben wurde, entsprechende für alte Buchungen korrigieren.
# @depends: release_2_6_0
-# @charset: utf-8
+package SL::DBUpgrade2::rundungsfehler_korrigieren_BUG1328_2;
-use utf8;
use strict;
-use Data::Dumper;
-die("This script cannot be run from the command line.") unless ($main::form);
+use utf8;
-sub mydberror {
- my ($msg) = @_;
- die($dbup_locale->text("Database update error:") .
- "
$msg
" . $DBI::errstr);
-}
+use parent qw(SL::DBUpgrade2::Base);
-sub do_query {
- my ($query, $may_fail) = @_;
+use SL::DBUtils;
- if (!$dbh->do($query)) {
- mydberror($query) unless ($may_fail);
- $dbh->rollback();
- $dbh->begin_work();
- }
-}
+sub run {
+ my ($self) = @_;
-sub do_update {
my @queries;
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 =
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)|;
- my $sth_all_groups = prepare_execute_query($form, $dbh, $query);
+ my $sth_all_groups = prepare_execute_query($::form, $self->dbh, $query);
while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife
push @queries, "UPDATE ap set amount =" . $hash_ref->{acamount} . " WHERE id = " . $hash_ref->{id};
}
$sth_all_groups->finish();
- 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 =
+ $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 =
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)|;
- my $sth_all_groups = prepare_execute_query($form, $dbh, $query);
+ $sth_all_groups = prepare_execute_query($::form, $self->dbh, $query);
while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife
- # Falls wir keine alte buggy Installation haben, ist es super die
+ # Falls wir keine alte buggy Installation haben, ist es super die
# Gewissheit zu haben, dass kein acc_trans-Eintrag ohne trans_id vorhanden ist
push @queries, "UPDATE ar set amount =" . $hash_ref->{acamount} . " WHERE id = " . $hash_ref->{id};
}
@@ -49,13 +37,11 @@ ar.id) where ac.chart_id IN (select id from chart where link ='AR' OR link like
# if in doubt use brute force ;-) jb
foreach my $query (@queries){
- my $sth = prepare_query($form, $dbh, $query);
- do_statement($form,$sth,$query);
+ my $sth = prepare_query($::form, $self->dbh, $query);
+ do_statement($::form,$sth,$query);
$sth->finish();
}
- $dbh ->commit();
return 1;
}
-return do_update();
-
+1;