1 # @tag: defaults_datev_check
 
   2 # @description: Einstellung für DATEV-Überprüfungen (datev_check) vom Config-File in die DB verlagern.
 
   3 # @depends: release_2_7_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);
 
  29   # this query will fail if column already exist (new database)
 
  30   do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_sales_invoice boolean    DEFAULT true|, 1);
 
  31   do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_purchase_invoice boolean DEFAULT true|, 1);
 
  32   do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ar_transaction boolean   DEFAULT true|, 1);
 
  33   do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ap_transaction boolean   DEFAULT true|, 1);
 
  34   do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_gl_transaction boolean   DEFAULT true|, 1);
 
  36   # check current configuration and set default variables accordingly, so that
 
  37   # kivitendo's behaviour isn't changed by this update
 
  38   # if checks are not set in config set it to true
 
  39   foreach my $check (qw(check_on_sales_invoice check_on_purchase_invoice check_on_ar_transaction check_on_ap_transaction check_on_gl_transaction)) {
 
  41     if (!$::lx_office_conf{datev_check}->{$check}) {
 
  45     my $update_column = "UPDATE defaults SET datev_$check = '$check_set';";
 
  46     do_query($update_column);