1 #=====================================================================
3 # Copyright (c) 2004 by Udo Spallek, Aachen
7 # Web: http://www.lx-office.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
24 #=====================================================================
28 use List::Util qw(first);
34 my @tax_office_information = (
35 { 'id' => 8, 'name' => 'Baden Württemberg', 'taxbird_nr' => '0', 'elster_format' => 'FF/BBB/UUUUP', },
36 { 'id' => 9, 'name' => 'Bayern', 'taxbird_nr' => '1', 'elster_format' => 'FFF/BBB/UUUUP', },
37 { 'id' => 11, 'name' => 'Berlin', 'taxbird_nr' => '2', 'elster_format' => 'FF/BBB/UUUUP', },
38 { 'id' => 12, 'name' => 'Brandenburg', 'taxbird_nr' => '3', 'elster_format' => 'FFF/BBB/UUUUP', },
39 { 'id' => 4, 'name' => 'Bremen', 'taxbird_nr' => '4', 'elster_format' => 'FF BBB UUUUP', },
40 { 'id' => 2, 'name' => 'Hamburg', 'taxbird_nr' => '5', 'elster_format' => 'FF/BBB/UUUUP', },
41 { 'id' => 6, 'name' => 'Hessen', 'taxbird_nr' => '6', 'elster_format' => '0FF BBB UUUUP', },
42 { 'id' => 13, 'name' => 'Mecklenburg Vorpommern', 'taxbird_nr' => '7', 'elster_format' => 'FFF/BBB/UUUUP', },
43 { 'id' => 3, 'name' => 'Niedersachsen', 'taxbird_nr' => '8', 'elster_format' => 'FF/BBB/UUUUP', },
44 { 'id' => 5, 'name' => 'Nordrhein Westfalen', 'taxbird_nr' => '9', 'elster_format' => 'FFF/BBBB/UUUP', },
45 { 'id' => 7, 'name' => 'Rheinland Pfalz', 'taxbird_nr' => '10', 'elster_format' => 'FF/BBB/UUUU/P', },
46 { 'id' => 10, 'name' => 'Saarland', 'taxbird_nr' => '11', 'elster_format' => 'FFF/BBB/UUUUP', },
47 { 'id' => 14, 'name' => 'Sachsen', 'taxbird_nr' => '12', 'elster_format' => 'FFF/BBB/UUUUP', },
48 { 'id' => 15, 'name' => 'Sachsen Anhalt', 'taxbird_nr' => '13', 'elster_format' => 'FFF/BBB/UUUUP', },
49 { 'id' => 1, 'name' => 'Schleswig Holstein', 'taxbird_nr' => '14', 'elster_format' => 'FF BBB UUUUP', },
50 { 'id' => 16, 'name' => 'Thüringen', 'taxbird_nr' => '15', 'elster_format' => 'FFF/BBB/UUUUP', },
68 $self->{tax_office_information} = [];
70 foreach (@tax_office_information) {
72 $entry->{name} = $main::locale->{iconv_iso8859}->convert($entry->{name});
73 push @{ $self->{tax_office_information} }, $entry;
79 my ( $self, $form, $myconfig) = @_;
81 my $query = q{ SELECT coa FROM defaults };
83 my $dbh = $form->dbconnect($myconfig);
84 my $sth = $dbh->prepare($query);
85 $sth->execute() || $form->dberror($query);
87 my ($coa) = selectrow_query($form, $dbh, $query);
93 $form->{"COA_$coa"} = '1';
94 $form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
100 sub report_variables {
101 # Get all positions for taxreport out of the database
102 # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl
104 return unless defined wantarray;
109 my $myconfig = $arg_ref->{myconfig};
110 my $form = $arg_ref->{form};
111 my $type = $arg_ref->{type}; # 'paied' || 'received' || ''
112 my $attribute = $arg_ref->{attribute}; #
113 my $dec_places = (defined $arg_ref->{dec_places}) ? $arg_ref->{dec_places}:undef;
115 my $where_type = "AND tax.report_headings.type = '$type'" if ( $type );
116 my $where_dcp = "AND tax.report_variables.dec_places = '$dec_places'" if ( defined $dec_places );
120 FROM tax.report_variables
121 LEFT JOIN tax.report_headings
122 ON (tax.report_variables.heading_id = tax.report_headings.id)
128 my $dbh = $form->dbconnect($myconfig);
129 my $sth = $dbh->prepare($query);
131 $sth->execute() || $form->dberror($query);
135 while ( my $row_ref = $sth->fetchrow_arrayref() ) {
136 push @positions, @$row_ref; # Copy the array contents
147 sub create_steuernummer {
148 $main::lxdebug->enter_sub();
150 my $form = $main::form;
154 my $part = $form->{part};
155 my $patterncount = $form->{patterncount};
156 my $delimiter = $form->{delimiter};
157 my $elster_pattern = $form->{elster_pattern};
159 # rebuild steuernummer and elstersteuernummer
160 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
161 # und die parts und delimiter
166 my $steuernummer_new = $part;
167 my $elstersteuernummer_new = $elster_FFFF;
168 $elstersteuernummer_new .= '0';
170 for ($h = 1; $h < $patterncount; $h++) {
171 $steuernummer_new .= qq|$delimiter|;
172 for ($i = 1; $i <= length($elster_pattern); $i++) {
173 $steuernummer_new .= $form->{"part_$h\_$i"};
174 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
177 if ($form->{steuernummer} ne $steuernummer_new) {
178 $form->{steuernummer} = $steuernummer_new;
179 $form->{elstersteuernummer} = $elstersteuernummer_new;
180 $form->{steuernummer_new} = $steuernummer_new;
182 $main::lxdebug->leave_sub();
183 return ($steuernummer_new, $elstersteuernummer_new);
186 sub steuernummer_input {
187 $main::lxdebug->enter_sub();
189 my ($self, $elsterland, $elsterFFFF, $steuernummer) = @_;
190 our ($elster_FFFF, $elster_land);
192 my $steuernummer_input = '';
194 $elster_land = $elsterland;
195 $elster_FFFF = $elsterFFFF;
196 $steuernummer = '0000000000' if ($steuernummer eq '');
198 # $steuernummer formatieren (nur Zahlen) -> $stnr
199 my $stnr = $steuernummer;
202 #Pattern description Elstersteuernummer
205 my $tax_office = first { $_->{name} eq $elster_land } @{ $self->{tax_office_information} };
206 my $elster_pattern = $tax_office->{elster_format};
207 my @elster_pattern = split(' ', $elster_pattern);
208 my $delimiter = ' ';
209 my $patterncount = @elster_pattern;
210 if ($patterncount < 2) {
211 @elster_pattern = ();
212 @elster_pattern = split('/', $elster_pattern);
214 $patterncount = @elster_pattern;
217 # no we have an array of patternparts and a delimiter
218 # create the first automated and fixed part and delimiter
220 $steuernummer_input .= qq|<b><font size="+1">|;
223 $elster_pattern[0] eq 'FFF' && do {
224 $part = substr($elster_FFFF, 1, 4);
225 $steuernummer_input .= qq|$part|;
228 $elster_pattern[0] eq '0FF' && do {
229 $part = '0' . substr($elster_FFFF, 2, 4);
230 $steuernummer_input .= qq|$part|;
233 $elster_pattern[0] eq 'FF' && do {
234 $part = substr($elster_FFFF, 2, 4);
235 $steuernummer_input .= qq|$part|;
239 $steuernummer_input .= qq|Fehler!|;
244 #now the rest of the Steuernummer ...
245 $steuernummer_input .= qq|</b></font>|;
246 $steuernummer_input .= qq|\n
247 <input type=hidden name="elster_pattern" value="$elster_pattern">
248 <input type=hidden name="patterncount" value="$patterncount">
249 <input type=hidden name="patternlength" value="$patterncount">
250 <input type=hidden name="delimiter" value="$delimiter">
251 <input type=hidden name="part" value="$part">
256 for (my $h = 1; $h < $patterncount; $h++) {
257 $steuernummer_input .= qq| $delimiter \n|;
258 for (my $i = 1; $i <= length($elster_pattern[$h]); $i++) {
259 $steuernummer_input .= qq|<select name="part_$h\_$i">\n|;
261 for (my $j = 0; $j <= 9; $j++) {
262 $steuernummer_input .= qq| <option value="$j"|;
263 if ($steuernummer ne '') {
264 if ($j eq substr($stnr, length($part) + $k, 1)) {
265 $steuernummer_input .= qq| selected|;
268 $steuernummer_input .= qq|>$j</option>\n|;
271 $steuernummer_input .= qq|</select>\n|;
275 $main::lxdebug->leave_sub();
277 return $steuernummer_input;
281 $main::lxdebug->enter_sub();
285 # Referenz wird übergeben, hash of hash wird nicht
286 # in neues Hash kopiert, sondern direkt über die Referenz verändert
287 # Prototyp für diese Konstruktion
289 my ($self, $land, $elsterFFFF, $elster_init) = @_;
292 my $FFFF = $elsterFFFF;
295 $checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
299 <script language="Javascript">
300 function update_auswahl()
302 var elsterBLAuswahl = document.verzeichnis.elsterland_new;
303 var elsterFAAuswahl = document.verzeichnis.elsterFFFF_new;
305 elsterFAAuswahl.options.length = 0; // dropdown aufräumen
308 foreach my $elster_land (sort keys %$elster_init) {
310 if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex].
311 value == "$elster_land")
315 %elster_land_fa = ();
317 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
318 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
320 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
321 keys(%elster_land_fa)
324 elsterFAAuswahl.options[$j] = new Option("$elster_land_fa{$ffff} ($ffff)","$ffff");|;
340 <select size="1" name="elsterland_new" onchange="update_auswahl()">|;
342 $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select federal state...') . qq|</option>\n|;
344 foreach my $elster_land (sort keys %$elster_init) {
346 <option value="$elster_land"|;
347 if ($elster_land eq $land and $checked eq '') {
348 $fa_auswahl .= qq| selected|;
350 $fa_auswahl .= qq|>$elster_land</option>
358 my $elster_land = '';
359 $elster_land = ($land ne '') ? $land : '';
360 %elster_land_fa = ();
361 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
362 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
370 <select size="1" name="elsterFFFF_new">|;
371 if ($elsterFFFF eq '') {
372 $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select tax office...') . qq|</option>|;
374 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
375 keys(%elster_land_fa)
379 <option value="$ffff"|;
380 if ($ffff eq $elsterFFFF and $checked eq '') {
381 $fa_auswahl .= qq| selected|;
383 $fa_auswahl .= qq|>$elster_land_fa{$ffff} ($ffff)</option>|;
392 $main::lxdebug->leave_sub();
398 $main::lxdebug->enter_sub();
402 if ($ENV{HTTP_USER_AGENT}) {
405 print qq|<body><h2 class=info>Hinweis</h2>
411 <input type=button value="| . $main::locale->text('Back') . qq|" onClick="history.go(-1)">
419 die "Hinweis: $msg\n";
422 $main::lxdebug->leave_sub();
425 # 20.10.2009 sschoeling: this sub seems to be orphaned.
427 $main::lxdebug->enter_sub();
430 # soll mal eine Erinnerungsfunktion für USTVA Abgaben werden, die automatisch
431 # den Termin der nächsten USTVA anzeigt.
434 my ($today, $FA_dauerfrist, $FA_voranmeld) = @_;
439 $today =~ /(\d\d\d\d)(\d\d)(\d\d)/;
445 my $yymmdd = "$year$month$day" * 1;
446 my $mmdd = "$month$day" * 1;
450 #$ical = '...vcal format';
452 #if ($FA_voranmeld eq 'month'){
455 "0110" => 'December',
457 "0310" => 'February',
464 "1010" => 'September',
466 "1210" => 'November',
471 $month += 1 if ($day > 10);
472 $month = sprintf("%02d", $month);
473 $stichtag = $year . $month . "10";
474 my $ust_va = $month . "10";
476 foreach my $date (%liste) {
477 $ust_va = $liste{$date} if ($date eq $stichtag);
480 #} elsif ($FA_voranmeld eq 'quarter'){
485 #@stichtag = ('10.04.2004', '10.05.2004');
487 #@liste = ['0110', '0210', '0310', '0410', '0510', '0610', '0710', '0810', '0910',
488 # '1010', '1110', '1210', ];
490 #foreach $key (@liste){
491 # #if ($ddmm < ('0110' * 1));
493 # $stichtag = $liste[$key - 1] if ($ddmm > $key);
497 #$stichtag =~ /([\d]\d)(\d\d)$/
498 #$stichtag = "$1.$2.$yy"
500 our $description; # most probably not existent.
501 our $tage_bis; # most probably not existent.
502 our $ical; # most probably not existent.
504 $main::lxdebug->leave_sub();
505 return ($stichtag, $description, $tage_bis, $ical);
508 sub query_finanzamt {
509 $main::lxdebug->enter_sub();
511 my ($self, $myconfig, $form) = @_;
513 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
515 #Test, if table finanzamt exist
516 my $table = 'finanzamt';
517 my $filename = "sql/$table.sql";
519 my $tst = $dbh->prepare("SELECT * FROM $table");
523 #There is no table, read the table from sql/finanzamt.sql
524 print qq|<p>Bitte warten, Tabelle $table wird einmalig in Datenbank:
525 $myconfig->{dbname} als Benutzer: $myconfig->{dbuser} hinzugefügt...</p>|;
526 process_query($form, $dbh, $filename) || $self->error(DBI->errstr);
528 #execute second last call
529 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
546 'FA_PLZ_Grosskunden', # 9
547 'FA_PLZ_Postfach', # 10
550 'FA_Kontonummer_1', # 13
551 'FA_Bankbezeichnung_1', # 14
552 #'FA_BankIBAN_1', # 15
553 #'FA_BankBIC_1', # 16
554 #'FA_BankInhaber_BUFA_Nr_1', # 17
556 'FA_Kontonummer_2', # 19
557 'FA_Bankbezeichnung_2', # 20
558 #'FA_BankIBAN_2', # 21
559 #'FA_BankBIC_2', # 22
560 #'FA_BankInhaber_BUFA_Nr_2', # 23
561 'FA_Oeffnungszeiten', # 24
564 #'FA_zustaendige_Hauptstelle_BUFA_Nr', # 27
565 #'FA_zustaendige_vorgesetzte_Finanzbehoerde' # 28
568 my $field = join(', ', @vars);
570 my $query = "SELECT $field FROM finanzamt ORDER BY FA_Land_nr";
571 my $sth = $dbh->prepare($query) or $self->error($dbh->errstr);
572 $sth->execute || $form->dberror($query);
573 my $array_ref = $sth->fetchall_arrayref();
576 foreach my $row (@$array_ref) {
577 my $FA_finanzamt = $row;
578 my $tax_office = first { $_->{id} == $FA_finanzamt->[0] } @{ $self->{tax_office_information} };
579 $land = $tax_office->{name};
581 # $land = $main::locale->{iconv}->convert($land);
583 my $ffff = @$FA_finanzamt[1];
586 $rec->{$land} = $ffff;
591 $finanzamt{$land}{$ffff} = [@$FA_finanzamt];
597 $main::lxdebug->leave_sub();
603 $main::lxdebug->enter_sub();
605 # Copyright D. Simander -> SL::Form under Gnu GPL.
606 my ($form, $dbh, $filename) = @_;
608 # return unless (-f $filename);
610 open my $FH, "<", "$filename" or $form->error("$filename : $!\n");
617 # Remove DOS and Unix style line endings.
620 # don't add comments or empty lines
621 next if /^(--.*|\s+)$/;
623 for (my $i = 0; $i < length($_); $i++) {
624 my $char = substr($_, $i, 1);
626 # Are we inside a string?
628 if ($char eq $quote_chars[-1]) {
634 if (($char eq "'") || ($char eq "\"")) {
635 push(@quote_chars, $char);
637 } elsif ($char eq ";") {
639 # Query is complete. Send it.
641 $sth = $dbh->prepare($query);
642 $sth->execute || $form->dberror($query);
656 $main::lxdebug->leave_sub();
660 $main::lxdebug->enter_sub();
662 my ($self, $myconfig, $form) = @_;
664 # connect to database
665 my $dbh = $form->dbconnect($myconfig);
668 my $category = "pos_ustva";
670 my @category_cent = USTVA->report_variables({
671 myconfig => $myconfig,
674 attribute => 'position',
678 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
680 my @category_euro = USTVA->report_variables({
681 myconfig => $myconfig,
684 attribute => 'position',
688 push @category_euro, USTVA->report_variables({
689 myconfig => $myconfig,
692 attribute => 'position',
696 $form->{decimalplaces} *= 1;
698 foreach my $item (@category_cent) {
699 $form->{"$item"} = 0;
701 foreach my $item (@category_euro) {
702 $form->{"$item"} = 0;
704 my $coa_name = coa_get($dbh);
705 $form->{coa} = $coa_name;
707 # Controlvariable for templates
708 $form->{"$coa_name"} = '1';
710 $main::lxdebug->message(LXDebug->DEBUG2(), "COA: '$form->{coa}', \$form->{$coa_name} = 1");
712 &get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate},
715 ###########################################
717 # Nationspecific Modfications
719 ###########################################
723 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU'){
726 # Umordnen der Kennziffern
727 if ( $form->{year} < 2007) {
728 $form->{35} += $form->{81};
729 $form->{36} += $form->{811};
730 $form->{95} += $form->{89};
731 $form->{98} += $form->{891};
732 map { delete $form->{$_} } qw(81 811 89 891);
734 $form->{35} += $form->{51};
735 $form->{36} += $form->{511};
736 $form->{95} += $form->{97};
737 $form->{98} += $form->{971};
738 map { delete $form->{$_} } qw(51 511 97 971);
744 # Fixme: Wird auch noch für Oesterreich gebraucht,
745 # weil kein eigenes Ausgabeformular
746 # sotte aber aus der allgeméinen Steuerberechnung verschwinden
748 # Berechnung der USTVA Formularfelder laut Bogen 207
751 $form->{"51r"} = $form->{"511"};
752 $form->{"86r"} = $form->{"861"};
753 $form->{"97r"} = $form->{"971"};
754 $form->{"93r"} = $form->{"931"};
756 $form->{"Z43"} = $form->{"511"} + $form->{"811"} + $form->{"861"}
757 + $form->{"36"} + $form->{"80"} + $form->{"971"}
758 + $form->{"891"} + $form->{"931"} + $form->{"96"}
761 $form->{"Z45"} = $form->{"Z43"};
763 $form->{"Z53"} = $form->{"Z45"} + $form->{"53"} + $form->{"74"}
764 + $form->{"85"} + $form->{"65"};
766 $form->{"Z62"} = $form->{"Z43"} - $form->{"66"} - $form->{"61"}
767 - $form->{"62"} - $form->{"67"} - $form->{"63"}
768 - $form->{"64"} - $form->{"59"};
770 $form->{"Z65"} = $form->{"Z62"} - $form->{"69"};
771 $form->{"83"} = $form->{"Z65"} - $form->{"39"};
775 $main::lxdebug->leave_sub();
781 my $form = $main::form;
783 my $query= qq|SELECT coa FROM defaults|;
785 my $sth = $dbh->prepare($query);
787 $sth->execute || $form->dberror($query);
789 my ($ref) = $sth->fetchrow_array;
795 sub get_accounts_ustva {
796 $main::lxdebug->enter_sub();
798 my ($dbh, $last_period, $fromdate, $todate, $form, $category) = @_;
810 my $gltaxkey_where = "(tk.pos_ustva>=59 AND tk.pos_ustva<=66)";
813 if ($form->{method} eq 'cash') {
814 $subwhere .= " AND transdate >= '$fromdate'";
815 $glwhere = " AND ac.transdate >= '$fromdate'";
816 $ARwhere .= " AND acc.transdate >= '$fromdate'";
818 $APwhere .= " AND AP.transdate >= '$fromdate'";
819 $where .= " AND ac.transdate >= '$fromdate'";
823 $where .= " AND ac.transdate <= '$todate'";
824 $ARwhere .= " AND acc.transdate <= '$todate'";
827 my $acc_trans_where = '1=1';
828 if ($fromdate || $todate) {
829 $acc_trans_where = "ac.trans_id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE ";
832 $acc_trans_where .= "transdate >= '$fromdate'";
835 $acc_trans_where .= " AND " if ($fromdate);
836 $acc_trans_where .= "transdate <= '$todate'";
839 $acc_trans_where .= ")";
842 ############################################
843 # Method eq 'cash' = IST Versteuerung
844 ############################################
845 # Betrifft nur die eingenommene Umsatzsteuer
847 ############################################
849 if ($form->{method} eq 'cash') {
853 -- USTVA IST-Versteuerung
855 -- Alle tatsaechlichen _Zahlungseingaenge_
856 -- im Voranmeldezeitraum erfassen
857 -- (Teilzahlungen werden prozentual auf verschiedene Steuern aufgeteilt)
859 -- Bezahlt / Rechnungssumme
861 SELECT SUM(acc.amount)
863 INNER JOIN chart c ON (acc.chart_id = c.id
864 AND c.link like '%AR_paid%')
868 AND acc.trans_id = ac.trans_id
872 SELECT amount FROM ar WHERE id = ac.trans_id
877 LEFT JOIN chart c ON (c.id = ac.chart_id)
878 LEFT JOIN ar ON (ar.id = ac.trans_id)
879 LEFT JOIN taxkeys tk ON (
881 SELECT id FROM taxkeys
882 WHERE chart_id = ac.chart_id
883 -- AND taxkey_id = ac.taxkey
884 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
885 ORDER BY startdate DESC LIMIT 1
890 GROUP BY tk.pos_ustva
893 } elsif ($form->{method} eq 'accrual') {
894 #########################################
895 # Method eq 'accrual' = Soll Versteuerung
896 #########################################
899 -- Alle Einnahmen AR und pos_ustva erfassen
901 - sum(ac.amount) AS amount,
904 JOIN chart c ON (c.id = ac.chart_id)
905 JOIN ar ON (ar.id = ac.trans_id)
908 SELECT id FROM taxkeys
909 WHERE chart_id = ac.chart_id
910 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
911 ORDER BY startdate DESC LIMIT 1
917 GROUP BY tk.pos_ustva
922 $form->error("Unknown tax method: $form->{method}")
926 #########################################
927 # Ausgaben und Gl Buchungen sind gleich
928 # für Ist- und Soll-Versteuerung
929 #########################################
931 UNION -- alle Ausgaben AP erfassen
934 sum(ac.amount) AS amount,
937 JOIN ap ON (ap.id = ac.trans_id )
938 JOIN chart c ON (c.id = ac.chart_id)
939 LEFT JOIN taxkeys tk ON (
941 SELECT id FROM taxkeys
943 AND chart_id=ac.chart_id
944 --AND taxkey_id = ac.taxkey
945 AND startdate <= COALESCE(AP.transdate)
946 ORDER BY startdate DESC LIMIT 1
952 GROUP BY tk.pos_ustva
954 UNION -- Einnahmen direkter gl Buchungen erfassen
957 ( - ac.amount) AS amount,
960 JOIN chart c ON (c.id = ac.chart_id)
961 JOIN gl a ON (a.id = ac.trans_id)
962 LEFT JOIN taxkeys tk ON (
964 SELECT id FROM taxkeys
965 WHERE chart_id=ac.chart_id
966 AND NOT $gltaxkey_where
967 AND startdate <= COALESCE(ac.transdate)
968 ORDER BY startdate DESC LIMIT 1
975 GROUP BY tk.pos_ustva
978 UNION -- Ausgaben direkter gl Buchungen erfassen
981 (ac.amount) AS amount,
984 JOIN chart c ON (c.id = ac.chart_id)
985 JOIN gl a ON (a.id = ac.trans_id)
986 LEFT JOIN taxkeys tk ON (
988 SELECT id FROM taxkeys
989 WHERE chart_id=ac.chart_id
991 AND startdate <= COALESCE(ac.transdate)
992 ORDER BY startdate DESC LIMIT 1
999 GROUP BY tk.pos_ustva
1007 # Show all $query in Debuglevel LXDebug::QUERY
1008 my $callingdetails = (caller (0))[3];
1009 $main::lxdebug->message(LXDebug->QUERY(), "$callingdetails \$query=\n $query");
1011 my $sth = $dbh->prepare($query);
1013 $sth->execute || $form->dberror($query);
1015 while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
1017 $ref->{amount} *= -1;
1018 $form->{ $ref->{$category} } += $ref->{amount};
1023 $main::lxdebug->leave_sub();
1028 $main::lxdebug->enter_sub();
1030 my ($self, $userspath, $filename) = @_;
1032 my $form = $main::form;
1034 $form->error("Missing Parameter: @_") if !$userspath || !$filename;
1036 $filename = "$form->{login}_$filename";
1037 $filename =~ s|.*/||;
1038 $filename = "$userspath/$filename";
1039 open my $FACONF, "<", $filename or do {# Annon Sub
1041 # create file if file does not exist
1042 open my $FANEW, ">", $filename or $form->error("CREATE: $filename : $!");
1043 close $FANEW or $form->error("CLOSE: $filename : $!");
1045 #try again open file
1046 open my $FACONF, "<", $filename or $form->error("OPEN: $filename : $!");
1051 next if (/^(\#|\s)/);
1056 # remove any trailing whitespace
1057 s/^\s*(.*?)\s*$/$1/;
1058 my ($key, $value) = split(/=/, $_, 2);
1060 $form->{$key} = "$value";
1066 $main::lxdebug->leave_sub();