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",
15 { "message" => $msg }));
20 sub update_steuersaetze_skr03 {
23 $query = "SELECT COUNT(*) FROM chart " .
24 "WHERE accno = '1776'";
25 my ($count) = $dbh->selectrow_array($query);
29 qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
30 VALUES ('1776','Umsatzsteuer 19 %', 'A', 'I', 'AR_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 511,6)|;
31 $dbh->do($query) || mydberror($query);
33 $query = "SELECT COUNT(*) FROM chart " .
34 "WHERE accno = '1576'";
35 my ($count) = $dbh->selectrow_array($query);
39 qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
40 VALUES ('1576','Abziehbare Vorsteuer 19 %', 'A', 'E', 'AP_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 66,27)|;
41 $dbh->do($query) || mydberror($query);
45 qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='1776'), 0.19, '1776', 3, 'Umsatzsteuer 19%')|;
46 $dbh->do($query) || mydberror($query);
48 qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='1576'), 0.19, '1576', 9, 'Vorsteuer 19%')|;
49 $dbh->do($query) || mydberror($query);
52 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|;
53 $dbh->do($query) || mydberror($query);
56 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|;
57 $dbh->do($query) || mydberror($query);
63 sub update_steuersaetze_skr04 {
66 $query = "SELECT COUNT(*) FROM chart " .
67 "WHERE accno = '3806'";
68 my ($count) = $dbh->selectrow_array($query);
72 qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
73 VALUES ('3806','Umsatzsteuer 19 %', 'A', 'I', 'AR_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 511,6)|;
74 $dbh->do($query) || mydberror($query);
76 $query = "SELECT COUNT(*) FROM chart " .
77 "WHERE accno = '1406'";
78 my ($count) = $dbh->selectrow_array($query);
82 qq|INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_ustva, pos_eur)
83 VALUES ('1406','Abziehbare Vorsteuer 19 %', 'A', 'E', 'AP_tax:IC_taxpart:IC_taxservice:CT_tax', 0, 66,27)|;
84 $dbh->do($query) || mydberror($query);
88 qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='3806'), 0.19, '3806', 3, 'Umsatzsteuer 19%')|;
89 $dbh->do($query) || mydberror($query);
91 qq|INSERT INTO tax (chart_id, rate, taxnumber, taxkey, taxdescription) VALUES ((SELECT id from CHART WHERE accno='1406'), 0.19, '1406', 9, 'Vorsteuer 19%')|;
92 $dbh->do($query) || mydberror($query);
95 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|;
96 $dbh->do($query) || mydberror($query);
99 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|;
100 $dbh->do($query) || mydberror($query);
107 sub update_steuersaetze {
108 my $form = $main::form;
110 my $query = "SELECT coa FROM defaults";
111 my ($coa) = $dbh->selectrow_array($query);
113 if ($coa eq "Germany-DATEV-SKR03EU") {
114 return update_steuersaetze_skr03();
116 } elsif ($coa eq "Germany-DATEV-SKR04EU") {
117 return update_steuersaetze_skr04();
120 print($form->parse_html_template("dbupgrade/" .
121 "std_buchungsgruppen_unknown_coa",
129 return update_steuersaetze();