Auftrags-Controller: HTML-formatierte Bemerkungen richtig in PDF umwandeln.
[kivitendo-erp.git] / SL / USTVA.pm
index abbf4a3..a80372b 100644 (file)
@@ -1,5 +1,5 @@
 #=====================================================================
-# Lx-Office ERP
+# kivitendo ERP
 # Copyright (c) 2004 by Udo Spallek, Aachen
 #
 #  Author: Udo Spallek
@@ -77,19 +77,9 @@ sub _init {
 
 sub get_coa {
 
-  my ( $self, $form, $myconfig) = @_;
-
-  my $query = q{ SELECT coa FROM defaults };
-
-  my $dbh = $form->dbconnect($myconfig);
-  my $sth = $dbh->prepare($query);
-  $sth->execute() || $form->dberror($query);
-
-  my ($coa) = selectrow_query($form, $dbh, $query);
-
-  $sth->finish;
-  $dbh->disconnect;
+  my ( $self, $form ) = @_;
 
+  my $coa = $::instance_conf->get_coa;
   $form->{coa} = $coa;
   $form->{"COA_$coa"} = '1';
   $form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
@@ -102,8 +92,6 @@ sub report_variables {
   # Get all positions for taxreport out of the database
   # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl
 
-  return unless defined wantarray;
-
   my ( $self,
        $arg_ref) = @_;
 
@@ -518,9 +506,7 @@ sub query_finanzamt {
   my $filename = "sql/$table.sql";
 
   my $tst = $dbh->prepare("SELECT * FROM $table");
-  $tst->execute;
-  if ($DBI::err) {
-
+  $tst->execute || do {
     #There is no table, read the table from sql/finanzamt.sql
     print qq|<p>Bitte warten, Tabelle $table wird einmalig in Datenbank:
     $myconfig->{dbname} als Benutzer: $myconfig->{dbuser} hinzugefĆ¼gt...</p>|;
@@ -529,7 +515,7 @@ sub query_finanzamt {
     #execute second last call
     my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
     $dbh->disconnect();
-  }
+  };
   $tst->finish();
 
   #$dbh->disconnect();
@@ -663,7 +649,7 @@ sub ustva {
   my ($self, $myconfig, $form) = @_;
 
   # connect to database
-  my $dbh = $form->dbconnect($myconfig);
+  my $dbh = $form->get_standard_dbh;
 
   my $last_period     = 0;
   my $category        = "pos_ustva";
@@ -702,7 +688,7 @@ sub ustva {
   foreach my $item (@category_euro) {
     $form->{"$item"} = 0;
   }
-  my $coa_name = coa_get($dbh);
+  my $coa_name = $::instance_conf->get_coa;
   $form->{coa} = $coa_name;
 
   # Controlvariable for templates
@@ -761,10 +747,10 @@ sub ustva {
 
   $form->{"Z45"} = $form->{"Z43"};
 
-  $form->{"Z53"} = $form->{"Z45"}     + $form->{"53"}  + $form->{"74"}
+  $form->{"Z53"} = $form->{"Z45"}     + $form->{"47"}  + $form->{"53"}  + $form->{"74"}
                      + $form->{"85"}  + $form->{"65"};
 
-  $form->{"Z62"} = $form->{"Z43"}     - $form->{"66"}  - $form->{"61"}
+  $form->{"Z62"} = $form->{"Z53"}     - $form->{"66"}  - $form->{"61"}
                      - $form->{"62"}  - $form->{"67"}  - $form->{"63"}
                      - $form->{"64"}  - $form->{"59"};
 
@@ -776,23 +762,6 @@ sub ustva {
   $main::lxdebug->leave_sub();
 }
 
-sub coa_get {
-
-  my ($dbh) = @_;
-  my $form  = $main::form;
-
-  my $query= qq|SELECT coa FROM defaults|;
-
-  my $sth = $dbh->prepare($query);
-
-  $sth->execute || $form->dberror($query);
-
-  my ($ref) = $sth->fetchrow_array;
-
-  return $ref;
-
-};
-
 sub get_accounts_ustva {
   $main::lxdebug->enter_sub();
 
@@ -808,7 +777,7 @@ sub get_accounts_ustva {
   my $arwhere  = "";
   my $item;
 
-    my $gltaxkey_where = "(tk.pos_ustva>=59 AND tk.pos_ustva<=66)";
+    my $gltaxkey_where = "((tk.pos_ustva = 46) OR (tk.pos_ustva>=59 AND tk.pos_ustva<=67) or (tk.pos_ustva>=89 AND tk.pos_ustva<=93))";
 
   if ($fromdate) {
     if ($form->{method} eq 'cash') {
@@ -1034,7 +1003,7 @@ sub get_config {
 
   $form->error("Missing Parameter: @_") if !$userspath || !$filename;
 
-  $filename = "$form->{login}_$filename";
+  $filename = "$::myconfig{login}_$filename";
   $filename =~ s|.*/||;
   $filename = "$userspath/$filename";
   open my $FACONF, "<", $filename or do {# Annon Sub