X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUSTVA.pm;h=ee2d21f78252815877764987ca08a37feaaca98e;hb=feb6f563968f53e59511578429b1dd61fda52008;hp=505efb438330e8d7b249f08302f7e69498e57570;hpb=e8f2a7327d2cb0aa802fdc98c38f9fdff9beb7d8;p=kivitendo-erp.git
diff --git a/SL/USTVA.pm b/SL/USTVA.pm
index 505efb438..ee2d21f78 100644
--- a/SL/USTVA.pm
+++ b/SL/USTVA.pm
@@ -1,5 +1,5 @@
#=====================================================================
-# Lx-Office ERP
+# kivitendo ERP
# Copyright (c) 2004 by Udo Spallek, Aachen
#
# Author: Udo Spallek
@@ -18,213 +18,314 @@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
# Utilities for ustva
#=====================================================================
package USTVA;
-sub create_steuernummer {
- $main::lxdebug->enter_sub();
+use Carp;
+use Data::Dumper;
+use List::Util qw(first);
+
+use SL::DB;
+use SL::DBUtils;
+use SL::DB::Default;
+use SL::DB::Finanzamt;
+use SL::Locale::String qw(t8);
+
+use utf8;
+use strict;
+
+my @tax_office_information = (
+ { 'id' => 8, 'name' => 'Baden-Württemberg', 'taxbird_nr' => '1', 'elster_format' => 'FFBBB/UUUUP', },
+ { 'id' => 9, 'name' => 'Bayern', 'taxbird_nr' => '2', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 11, 'name' => 'Berlin', 'taxbird_nr' => '3', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 12, 'name' => 'Brandenburg', 'taxbird_nr' => '4', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 4, 'name' => 'Bremen', 'taxbird_nr' => '5', 'elster_format' => 'FF BBB UUUUP', },
+ { 'id' => 2, 'name' => 'Hamburg', 'taxbird_nr' => '6', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 6, 'name' => 'Hessen', 'taxbird_nr' => '7', 'elster_format' => '0FF BBB UUUUP', },
+ { 'id' => 13, 'name' => 'Mecklenburg-Vorpommern', 'taxbird_nr' => '8', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 3, 'name' => 'Niedersachsen', 'taxbird_nr' => '9', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 5, 'name' => 'Nordrhein-Westfalen', 'taxbird_nr' => '10', 'elster_format' => 'FFF/BBBB/UUUP', },
+ { 'id' => 7, 'name' => 'Rheinland-Pfalz', 'taxbird_nr' => '11', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 10, 'name' => 'Saarland', 'taxbird_nr' => '12', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 14, 'name' => 'Sachsen', 'taxbird_nr' => '13', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 15, 'name' => 'Sachsen-Anhalt', 'taxbird_nr' => '14', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 1, 'name' => 'Schleswig-Holstein', 'taxbird_nr' => '15', 'elster_format' => 'FF BBB UUUUP', },
+ { 'id' => 16, 'name' => 'Thüringen', 'taxbird_nr' => '16', 'elster_format' => 'FFF/BBB/UUUUP', },
+ );
- $part = $form->{part};
- $patterncount = $form->{patterncount};
- $delimiter = $form->{delimiter};
- $elster_pattern = $form->{elster_pattern};
+ my @fiamt_config = qw(taxnumber fa_bufa_nr fa_dauerfrist fa_steuerberater_city fa_steuerberater_name
+ fa_steuerberater_street fa_steuerberater_tel fa_voranmeld);
- # rebuild steuernummer and elstersteuernummer
- # es gibt eine gespeicherte steuernummer $form->{steuernummer}
- # und die parts und delimiter
+ my @fiamt_finanzamt = qw(
+ fa_land_nr fa_bufa_nr fa_name fa_strasse
+ fa_plz fa_ort fa_telefon fa_fax
+ fa_plz_grosskunden fa_plz_postfach fa_postfach
+ fa_blz_1 fa_kontonummer_1 fa_bankbezeichnung_1
+ fa_blz_2 fa_kontonummer_2 fa_bankbezeichnung_2 fa_oeffnungszeiten
+ fa_email fa_internet);
- my $h = 0;
- my $i = 0;
- $steuernummer_new = $part;
- $elstersteuernummer_new = $elster_FFFF;
- $elstersteuernummer_new .= '0';
+sub new {
+ my $type = shift;
- for ($h = 1; $h < $patterncount; $h++) {
- $steuernummer_new .= qq|$delimiter|;
- for ($i = 1; $i <= length($elster_pattern); $i++) {
- $steuernummer_new .= $form->{"part_$h\_$i"};
- $elstersteuernummer_new .= $form->{"part_$h\_$i"};
- }
- }
- if ($form->{steuernummer} ne $steuernummer_new) {
- $form->{steuernummer} = $steuernummer_new;
- $form->{elstersteuernummer} = $elstersteuernummer_new;
- $form->{steuernummer_new} = $steuernummer_new;
+ my $self = {};
+
+ bless $self, $type;
+
+ $self->_init(@_);
+
+ return $self;
+}
+
+sub _init {
+ my $self = shift;
+
+ $self->{tax_office_information} = [];
+
+ foreach (@tax_office_information) {
+ my $entry = \%{ $_ };
+ $entry->{name} = $::locale->{iconv_utf8}->convert($entry->{name});
+ push @{ $self->{tax_office_information} }, $entry;
}
- $main::lxdebug->leave_sub();
- return ($steuernummer_new, $elstersteuernummer_new);
}
+sub get_coa {
+
+ 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);
+
+ return;
+}
+
+
+sub report_variables {
+ # Get all positions for taxreport out of the database
+ # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl
+
+ my ( $self,
+ $arg_ref) = @_;
+
+ my $myconfig = $arg_ref->{myconfig};
+ my $form = $arg_ref->{form};
+ my $type = $arg_ref->{type}; # 'paied' || 'received' || ''
+ my $attribute = $arg_ref->{attribute}; #
+ my $dec_places = (defined $arg_ref->{dec_places}) ? $arg_ref->{dec_places}:undef;
+
+ my $where_type = $type ? "AND tax.report_headings.type = '$type'" : '';
+ my $where_dcp = defined $dec_places ? "AND tax.report_variables.dec_places = '$dec_places'" : '';
+
+ my $query = qq|
+ SELECT $attribute
+ FROM tax.report_variables
+ LEFT JOIN tax.report_headings
+ ON (tax.report_variables.heading_id = tax.report_headings.id)
+ WHERE 1=1
+ $where_type
+ $where_dcp
+ |;
+
+ my @positions;
+
+ SL::DB->client->with_transaction(sub {
+ my $dbh = SL::DB->client->dbh;
+ my $sth = $dbh->prepare($query);
+
+ $sth->execute() || $form->dberror($query);
+
+ while ( my $row_ref = $sth->fetchrow_arrayref() ) {
+ push @positions, @$row_ref; # Copy the array contents
+ }
+
+ $sth->finish;
+ 1;
+ }) or do { die SL::DB->client->error };
+
+ return @positions;
+}
+
+
sub steuernummer_input {
$main::lxdebug->enter_sub();
- ($elsterland, $elsterFFFF, $steuernummer) = @_;
+ my ($self, $elsterland, $elsterFFFF, $steuernummer) = @_;
+ our ($elster_FFFF, $elster_land);
+
+ my $steuernummer_input = '';
$elster_land = $elsterland;
$elster_FFFF = $elsterFFFF;
$steuernummer = '0000000000' if ($steuernummer eq '');
# $steuernummer formatieren (nur Zahlen) -> $stnr
- $stnr = $steuernummer;
+ my $stnr = $steuernummer;
$stnr =~ s/\D+//g;
#Pattern description Elstersteuernummer
- my %elster_STNRformat = (
- 'Mecklenburg Vorpommern' => 'FFF/BBB/UUUUP', # '/' 3
- 'Hessen' => '0FF BBB UUUUP', # ' ' 3
- 'Nordrhein Westfalen' => 'FFF/BBBB/UUUP', # '/' 3
- 'Schleswig Holstein' => 'FF BBB UUUUP', # ' ' 2
- 'Berlin' => 'FF/BBB/UUUUP', # '/' 3
- 'Thüringen' => 'FFF/BBB/UUUUP', # '/' 3
- 'Sachsen' => 'FFF/BBB/UUUUP', # '/' 3
- 'Hamburg' => 'FF/BBB/UUUUP', # '/' 3
- 'Baden Würtemberg' => 'FF/BBB/UUUUP', # '/' 2
- 'Sachsen Anhalt' => 'FFF/BBB/UUUUP', # '/' 3
- 'Saarland' => 'FFF/BBB/UUUUP', # '/' 3
- 'Bremen' => 'FF BBB UUUUP', # ' ' 3
- 'Bayern' => 'FFF/BBB/UUUUP', # '/' 3
- 'Rheinland Pfalz' => 'FF/BBB/UUUU/P', # '/' 4
- 'Niedersachsen' => 'FF/BBB/UUUUP', # '/' 3
- 'Brandenburg' => 'FFF/BBB/UUUUP', # '/' 3
- );
#split the pattern
- $elster_pattern = $elster_STNRformat{$elster_land};
+ my $tax_office = first { $_->{id} eq $elster_land } @{ $self->{tax_office_information} };
+ my $elster_pattern = $tax_office->{elster_format};
+ # $::lxdebug->message(LXDebug->DEBUG2, "stnr=".$stnr." elster_FFFF=".$elster_FFFF.
+ # " pattern=".$elster_pattern." land=".$elster_land);
my @elster_pattern = split(' ', $elster_pattern);
- my $delimiter = ' ';
+ my $delimiter1 = ' ';
+ my $delimiter2 = ' ';
my $patterncount = @elster_pattern;
if ($patterncount < 2) {
@elster_pattern = ();
@elster_pattern = split('/', $elster_pattern);
- $delimiter = '/';
+ $delimiter1 = '/';
+ $delimiter2 = '/';
$patterncount = @elster_pattern;
+ if ($patterncount < 2) {
+ @elster_pattern = ();
+ @elster_pattern = split(' ', $elster_pattern);
+ $delimiter1 = ' ';
+ $delimiter2 = ' ';
+ $patterncount = @elster_pattern;
+ }
}
# no we have an array of patternparts and a delimiter
# create the first automated and fixed part and delimiter
- print qq||;
- $part = '';
+ $steuernummer_input .= qq||;
+ my $part = '';
+# $::lxdebug->message(LXDebug->DEBUG2, "pattern0=".$elster_pattern[0]);
SWITCH: {
$elster_pattern[0] eq 'FFF' && do {
$part = substr($elster_FFFF, 1, 4);
- print qq|$part|;
+ $steuernummer_input .= qq|$part|;
last SWITCH;
};
$elster_pattern[0] eq '0FF' && do {
$part = '0' . substr($elster_FFFF, 2, 4);
- print qq|$part|;
+ $steuernummer_input .= qq|$part|;
+ last SWITCH;
+ };
+ $elster_pattern[0] eq 'FFBBB' && do {
+ $part = substr($elster_FFFF, 2, 4);
+ $steuernummer_input .= qq|$part|;
+ $delimiter1 = '';
+ $patterncount++ ;
+ # Sonderfall BW
+ @elster_pattern = ('FF','BBB','UUUUP');
last SWITCH;
};
$elster_pattern[0] eq 'FF' && do {
$part = substr($elster_FFFF, 2, 4);
- print qq|$part|;
+ $steuernummer_input .= qq|$part|;
last SWITCH;
};
1 == 1 && do {
- print qq|Fehler!|;
+ $steuernummer_input .= qq|Fehler!|;
last SWITCH;
};
}
#now the rest of the Steuernummer ...
- print qq||;
- print qq|\n
+ $steuernummer_input .= qq||;
+ $steuernummer_input .= qq|\n
-
+
+
|;
- my $h = 0;
- my $i = 0;
- my $j = 0;
- $k = 0;
-
- for ($h = 1; $h < $patterncount; $h++) {
- print qq| $delimiter \n|;
- for ($i = 1; $i <= length($elster_pattern[$h]); $i++) {
- print qq|\n|;
+ $steuernummer_input .= qq|\n|;
}
}
+
$main::lxdebug->leave_sub();
+
+ return $steuernummer_input;
}
sub fa_auswahl {
$main::lxdebug->enter_sub();
- use SL::Form;
+ # Referenz wird übergeben, hash of hash wird nicht
+ # in neues Hash kopiert, sondern direkt über die Referenz verändert
+ # Prototyp für diese Konstruktion
- # Referenz wird übergeben, hash of hash wird nicht
- # in neues Hash kopiert, sondern direkt über die Referenz verändert
- # Prototyp für diese Konstruktion
+ my ($self, $land, $elsterFFFF, $elster_init) = @_;
- my ($land, $elsterFFFF, $elster_init) =
- @_; #Referenz auf Hash von Hash übergeben
+# $::lxdebug->message(LXDebug->DEBUG2,"land=".$land." amt=".$elsterFFFF);
my $terminal = '';
my $FFFF = $elsterFFFF;
my $ffff = '';
my $checked = '';
$checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
+ my %elster_land_fa;
+ my %elster_land_name = ();
- #if ($ENV{HTTP_USER_AGENT} =~ /(mozilla|opera|w3m)/i){
- #$terminal='mozilla';
- #} elsif ($ENV{HTTP_USER_AGENT} =~ /(links|lynx)/i){
- #$terminal = 'lynx';
- #}
-
- #if ( $terminal eq 'mozilla' or $terminal eq 'js' ) {
- print qq|
-
+ my $fa_auswahl = qq|
@@ -234,20 +335,22 @@ sub fa_auswahl {
Bundesland