Revision c1d8418b
Von Udo Spallek vor mehr als 17 Jahren hinzugefügt
SL/USTVA.pm | ||
---|---|---|
25 | 25 |
|
26 | 26 |
package USTVA; |
27 | 27 |
|
28 |
sub report_variables { |
|
29 |
# Get all positions for taxreport out of the database |
|
30 |
# Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl |
|
31 |
|
|
32 |
return unless defined wantarray; |
|
33 |
|
|
34 |
my ( $self, |
|
35 |
$arg_ref) = @_; |
|
36 |
|
|
37 |
my $myconfig = $arg_ref->{myconfig}; |
|
38 |
my $form = $arg_ref->{form}; |
|
39 |
my $type = $arg_ref->{type}; # 'paied' || 'received' || '' |
|
40 |
my $attribute = $arg_ref->{attribute}; # |
|
41 |
my $dec_places = (defined $arg_ref->{dec_places}) ? $arg_ref->{dec_places}:undef; |
|
42 |
|
|
43 |
my $where_type = "AND tax.report_headings.type = '$type'" if ( $type ); |
|
44 |
my $where_dcp = "AND tax.report_variables.dec_places = '$dec_places'" if ( defined $dec_places ); |
|
45 |
|
|
46 |
my $query = qq| |
|
47 |
SELECT $attribute |
|
48 |
FROM tax.report_variables |
|
49 |
LEFT JOIN tax.report_headings |
|
50 |
ON (tax.report_variables.heading_id = tax.report_headings.id) |
|
51 |
WHERE 1=1 |
|
52 |
$where_type |
|
53 |
$where_dcp |
|
54 |
|; |
|
55 |
|
|
56 |
$main::lxdebug->message(LXDebug::QUERY, "\$query= \n $query\n"); |
|
57 |
|
|
58 |
my $dbh = $form->dbconnect($myconfig); |
|
59 |
my $sth = $dbh->prepare($query); |
|
60 |
|
|
61 |
$sth->execute() || $form->dberror($query); |
|
62 |
|
|
63 |
my @positions; |
|
64 |
|
|
65 |
while ( my $row_ref = $sth->fetchrow_arrayref() ) { |
|
66 |
push @positions, @$row_ref; # Copy the array contents |
|
67 |
} |
|
68 |
|
|
69 |
$sth->finish; |
|
70 |
|
|
71 |
$dbh->disconnect; |
|
72 |
|
|
73 |
return @positions; |
|
74 |
|
|
75 |
} |
|
76 |
|
|
28 | 77 |
sub create_steuernummer { |
29 | 78 |
$main::lxdebug->enter_sub(); |
30 | 79 |
|
... | ... | |
40 | 89 |
my $h = 0; |
41 | 90 |
my $i = 0; |
42 | 91 |
|
43 |
$steuernummer_new = $part; |
|
44 |
$elstersteuernummer_new = $elster_FFFF; |
|
92 |
$steuernummer_new = $part;
|
|
93 |
$elstersteuernummer_new = $elster_FFFF;
|
|
45 | 94 |
$elstersteuernummer_new .= '0'; |
46 | 95 |
|
47 | 96 |
for ($h = 1; $h < $patterncount; $h++) { |
... | ... | |
572 | 621 |
|
573 | 622 |
my $last_period = 0; |
574 | 623 |
my $category = "pos_ustva"; |
575 |
my @category_cent = qw( |
|
576 |
511 861 36 80 971 931 98 96 53 74 |
|
577 |
85 65 66 61 62 67 63 64 59 69 |
|
578 |
39 83 811 891 Z43 Z45 Z53 Z62 Z65 Z67 |
|
579 |
); |
|
580 | 624 |
|
581 |
my @category_euro = qw( |
|
582 |
41 44 49 43 48 51 |
|
583 |
86 35 77 76 91 97 |
|
584 |
93 95 94 42 60 45 |
|
585 |
52 73 84 81 89 |
|
586 |
); |
|
625 |
my @category_cent = USTVA->report_variables({ |
|
626 |
myconfig => $myconfig, |
|
627 |
form => $form, |
|
628 |
type => '', |
|
629 |
attribute => 'position', |
|
630 |
dec_places => '2', |
|
631 |
}); |
|
632 |
|
|
633 |
push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67); |
|
634 |
|
|
635 |
my @category_euro = USTVA->report_variables({ |
|
636 |
myconfig => $myconfig, |
|
637 |
form => $form, |
|
638 |
type => '', |
|
639 |
attribute => 'position', |
|
640 |
dec_places => '0', |
|
641 |
}); |
|
642 |
|
|
643 |
push @category_euro, USTVA->report_variables({ |
|
644 |
myconfig => $myconfig, |
|
645 |
form => $form, |
|
646 |
type => '', |
|
647 |
attribute => 'position', |
|
648 |
dec_places => '0', |
|
649 |
}); |
|
587 | 650 |
|
588 | 651 |
$form->{decimalplaces} *= 1; |
589 | 652 |
|
... | ... | |
593 | 656 |
foreach $item (@category_euro) { |
594 | 657 |
$form->{"$item"} = 0; |
595 | 658 |
} |
659 |
my $coa_name = coa_get($dbh); |
|
660 |
$form->{coa} = $coa_name; |
|
661 |
|
|
662 |
# Controlvariable for templates |
|
663 |
$form->{"$coa_name"} = '1'; |
|
596 | 664 |
|
597 |
$form->{coa} = coa_get($dbh); |
|
598 |
$main::lxdebug->message(LXDebug::DEBUG2, "COA: $form->{coa}"); |
|
665 |
$main::lxdebug->message(LXDebug::DEBUG2, "COA: '$form->{coa}', \$form->{$coa_name} = 1"); |
|
599 | 666 |
|
600 | 667 |
&get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate}, |
601 | 668 |
$form, $category); |
... | ... | |
843 | 910 |
LEFT JOIN taxkeys tk ON ( |
844 | 911 |
tk.id = ( |
845 | 912 |
SELECT id FROM taxkeys |
846 |
WHERE chart_id=ac.chart_id |
|
913 |
WHERE 1=1 |
|
914 |
AND chart_id=ac.chart_id |
|
847 | 915 |
AND taxkey_id = ac.taxkey |
848 | 916 |
AND startdate <= COALESCE(AP.transdate) |
849 | 917 |
ORDER BY startdate DESC LIMIT 1 |
Auch abrufbar als: Unified diff
Verlagern der USTVA Kennziffern auf einen zentralen Datenbankeintrag.
Dies verhindert Probleme, dass manche Kennziffern in einzelnen Ausgabemedien nicht erscheinen, in anderen jedoch schon.
Auch bietet die Verlagerung auf die Datenbank - in einem späteren Schritt - die Abstraktion von Steuerreports auf verschiedene internationale Gegebenheiten.
Zur Vereinfachung habe ich das Schema tax.* eingefuehrt, in dem perspektivisch alle Steuerreport relevanten Tabellen einzug halten koennen.