X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=sql%2FPg-upgrade2%2Fdefaults_datev_check.pl;h=619a9fc02eb45c9a103b7230ca0395d893a0f51f;hb=953b505f3da71b5de15e21f812f06f4d6e6f2721;hp=50772810b7f11ea5dc848794b241c1c88b973625;hpb=5a23fdf6ec3cce197baaccad11b60bfe36005428;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/defaults_datev_check.pl b/sql/Pg-upgrade2/defaults_datev_check.pl
index 50772810b..619a9fc02 100644
--- a/sql/Pg-upgrade2/defaults_datev_check.pl
+++ b/sql/Pg-upgrade2/defaults_datev_check.pl
@@ -1,54 +1,33 @@
# @tag: defaults_datev_check
# @description: Einstellung für DATEV-Ãberprüfungen (datev_check) vom Config-File in die DB verlagern.
# @depends: release_2_7_0
-# @charset: utf-8
+package SL::DBUpgrade2::defaults_datev_check;
use utf8;
-use strict;
-
-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) = @_;
- if (!$dbh->do($query)) {
- mydberror($query) unless ($may_fail);
- $dbh->rollback();
- $dbh->begin_work();
- }
-}
+use parent qw(SL::DBUpgrade2::Base);
+use strict;
-sub do_update {
+sub run {
+ my ($self) = @_;
# this query will fail if column already exist (new database)
- do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_sales_invoice boolean DEFAULT true|, 1);
- do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_purchase_invoice boolean DEFAULT true|, 1);
- do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ar_transaction boolean DEFAULT true|, 1);
- do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ap_transaction boolean DEFAULT true|, 1);
- do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_gl_transaction boolean DEFAULT true|, 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_sales_invoice boolean DEFAULT true|, may_fail => 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_purchase_invoice boolean DEFAULT true|, may_fail => 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ar_transaction boolean DEFAULT true|, may_fail => 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ap_transaction boolean DEFAULT true|, may_fail => 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_gl_transaction boolean DEFAULT true|, may_fail => 1);
# check current configuration and set default variables accordingly, so that
# kivitendo's behaviour isn't changed by this update
# if checks are not set in config set it to true
foreach my $check (qw(check_on_sales_invoice check_on_purchase_invoice check_on_ar_transaction check_on_ap_transaction check_on_gl_transaction)) {
- my $check_set = 1;
- if (!$::lx_office_conf{datev_check}->{$check}) {
- $check_set = 0;
- }
-
+ my $check_set = defined($::lx_office_conf{datev_check}->{$check}) && ($::lx_office_conf{datev_check}->{$check} == 0) ? 0 : 1;
my $update_column = "UPDATE defaults SET datev_$check = '$check_set';";
- do_query($update_column);
+ $self->db_query($update_column);
}
-
return 1;
}
-return do_update();
-
+1;