3 die("This script cannot be run from the command line.") unless ($main::form);
 
   7   die($dbup_locale->text("Database update error:") .
 
   8       "<br>$msg<br>" . $DBI::errstr);
 
  14   print($main::form->parse_html_template("dbupgrade/units_error", { "message" => $msg }));
 
  19 sub update_steuersaetze_skr03 {
 
  22   $query = "SELECT COUNT(*) FROM chart " .
 
  23     "WHERE accno = '1776'";
 
  24   my ($count) = $dbh->selectrow_array($query);
 
  28       qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
 
  29       VALUES ('1776','Umsatzsteuer 19 %', 'A', 'I', 'AR_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 511,6)|;
 
  30     $dbh->do($query) || mydberror($query);
 
  32   $query = "SELECT COUNT(*) FROM chart " .
 
  33     "WHERE accno = '1576'";
 
  34   my ($count) = $dbh->selectrow_array($query);
 
  38       qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
 
  39       VALUES ('1576','Abziehbare Vorsteuer 19 %', 'A', 'E', 'AP_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 66,27)|;
 
  40     $dbh->do($query) || mydberror($query);
 
  44     qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='1776'), 0.19, '1776', 3, 'Umsatzsteuer 19%')|;
 
  45   $dbh->do($query) || mydberror($query);
 
  47     qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='1576'), 0.19, '1576', 9, 'Vorsteuer 19%')|;
 
  48   $dbh->do($query) || mydberror($query);
 
  51     qq|insert into taxkeys (chart_id, tax_id, taxkey_id, pos_ustva, startdate) select chart.id, (SELECT id from tax where taxdescription='Umsatzsteuer 19%'), 3, pos_ustva, '2007-01-01' from chart WHERE taxkey_id=3|;
 
  52   $dbh->do($query) || mydberror($query);
 
  55     qq|insert into taxkeys (chart_id, tax_id, taxkey_id, pos_ustva, startdate) select chart.id, (SELECT id from tax where taxdescription='Vorsteuer 19%'), 9, pos_ustva, '2007-01-01' from chart WHERE taxkey_id=9|;
 
  56   $dbh->do($query) || mydberror($query);
 
  62 sub update_steuersaetze_skr04 {
 
  65   $query = "SELECT COUNT(*) FROM chart " .
 
  66     "WHERE accno = '3806'";
 
  67   my ($count) = $dbh->selectrow_array($query);
 
  71       qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
 
  72       VALUES ('3806','Umsatzsteuer 19 %', 'A', 'I', 'AR_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 511,6)|;
 
  73     $dbh->do($query) || mydberror($query);
 
  75   $query = "SELECT COUNT(*) FROM chart " .
 
  76     "WHERE accno = '1406'";
 
  77   my ($count) = $dbh->selectrow_array($query);
 
  81       qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
 
  82       VALUES ('1406','Abziehbare Vorsteuer 19 %', 'A', 'E', 'AP_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 66,27)|;
 
  83     $dbh->do($query) || mydberror($query);
 
  87     qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='3806'), 0.19, '3806', 3, 'Umsatzsteuer 19%')|;
 
  88   $dbh->do($query) || mydberror($query);
 
  90     qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='1406'), 0.19, '1406', 9, 'Vorsteuer 19%')|;
 
  91   $dbh->do($query) || mydberror($query);
 
  94     qq|insert into taxkeys (chart_id, tax_id, taxkey_id, pos_ustva, startdate) select chart.id, (SELECT id from tax where taxdescription='Umsatzsteuer 19%'), 3, pos_ustva, '2007-01-01' from chart WHERE taxkey_id=3|;
 
  95   $dbh->do($query) || mydberror($query);
 
  98     qq|insert into taxkeys (chart_id, tax_id, taxkey_id, pos_ustva, startdate) select chart.id, (SELECT id from tax where taxdescription='Vorsteuer 19%'), 9, pos_ustva, '2007-01-01' from chart WHERE taxkey_id=9|;
 
  99   $dbh->do($query) || mydberror($query);
 
 106 sub update_steuersaetze {
 
 107   my $form = $main::form;
 
 109   my $query = "SELECT coa FROM defaults";
 
 110   my ($coa) = $dbh->selectrow_array($query);
 
 112   if ($coa eq "Germany-DATEV-SKR03EU") {
 
 113     return update_steuersaetze_skr03();
 
 115   } elsif ($coa eq "Germany-DATEV-SKR04EU") {
 
 116     return update_steuersaetze_skr04();
 
 119   print($form->parse_html_template("dbupgrade/std_buchungsgruppen_unknown_coa", { "coa" => $coa }));
 
 126 return update_steuersaetze();