X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fcharts_without_taxkey.pl;h=b0a703c0329e1b48d75789cb611eafe356f2f2d2;hb=bd25baf67d259c1b805951dfd92a310766c13661;hp=5b7893b47bf5a8fd5e12f7c890c8d86f35d8c5ea;hpb=11c511f708201bafc1851c364215838c79f5b322;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade2/charts_without_taxkey.pl b/sql/Pg-upgrade2/charts_without_taxkey.pl index 5b7893b47..b0a703c03 100644 --- a/sql/Pg-upgrade2/charts_without_taxkey.pl +++ b/sql/Pg-upgrade2/charts_without_taxkey.pl @@ -1,64 +1,49 @@ # @tag: charts_without_taxkey # @description: Fügt für jedes Konto, was keinen Steuerschlüssel hat, den Steuerschlüssel 0 hinzu -# @depends: -# @charset: UTF-8 +# @depends: release_3_0_0 +package SL::DBUpgrade2::charts_without_taxkey; -use utf8; use strict; -use SL::Locale; - -die("This script cannot be run from the command line.") unless ($main::form); - -sub mydberror { - my ($msg) = @_; - die($dbup_locale->text("Database update error:") . "
$msg
" . $DBI::errstr); -} - -sub do_query { - my ($query, $may_fail) = @_; +use utf8; - if (!$dbh->do($query)) { - mydberror($query) unless ($may_fail); - $dbh->rollback(); - $dbh->begin_work(); - } -} +use parent qw(SL::DBUpgrade2::Base); +sub run { + my ($self) = @_; -sub do_update { - my ($taxkey0_with_taxes_exists) = $dbh->selectrow_array("SELECT COUNT(*) FROM tax WHERE taxkey=0 AND NOT rate=0;"); + my ($taxkey0_with_taxes_exists) = $self->dbh->selectrow_array("SELECT COUNT(*) FROM tax WHERE taxkey=0 AND NOT rate=0;"); if ($taxkey0_with_taxes_exists > 0){ print_error_message(); return 0; } - my ($taxkey0_exists) = $dbh->selectrow_array("SELECT COUNT(*) FROM tax WHERE taxkey=0"); + my ($taxkey0_exists) = $self->dbh->selectrow_array("SELECT COUNT(*) FROM tax WHERE taxkey=0"); if ($taxkey0_exists == 0){ my $insert_taxkey0 = <text("taxkey 0 with taxrate 0 was created."); + $self->db_query($insert_taxkey0); +# print $::locale->text("taxkey 0 with taxrate 0 was created."); }; - + my $insert_taxkeys = <db_query($insert_taxkeys); return 1; -}; # end do_update +} # end run sub print_error_message { - print $main::form->parse_html_template("dbupgrade/taxkey_update"); -}; + print $::form->parse_html_template("dbupgrade/taxkey_update"); +} -return do_update(); +1;