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 #=====================================================================
32 my ( $self, $form, $myconfig) = @_;
34 my $query = q{ SELECT coa FROM defaults };
36 my $dbh = $form->dbconnect($myconfig);
37 my $sth = $dbh->prepare($query);
38 $sth->execute() || $form->dberror($query);
40 my ($coa) = selectrow_query($form, $dbh, $query);
46 $form->{"COA_$coa"} = '1';
47 $form->{COA_Germany} = '1' if ( $coa eq 'Germany-DATEV-SKR03EU' or $coa eq 'Germany-DATEV-SKR04EU');
53 sub report_variables {
54 # Get all positions for taxreport out of the database
55 # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl
57 return unless defined wantarray;
62 my $myconfig = $arg_ref->{myconfig};
63 my $form = $arg_ref->{form};
64 my $type = $arg_ref->{type}; # 'paied' || 'received' || ''
65 my $attribute = $arg_ref->{attribute}; #
66 my $dec_places = (defined $arg_ref->{dec_places}) ? $arg_ref->{dec_places}:undef;
68 my $where_type = "AND tax.report_headings.type = '$type'" if ( $type );
69 my $where_dcp = "AND tax.report_variables.dec_places = '$dec_places'" if ( defined $dec_places );
73 FROM tax.report_variables
74 LEFT JOIN tax.report_headings
75 ON (tax.report_variables.heading_id = tax.report_headings.id)
81 my $dbh = $form->dbconnect($myconfig);
82 my $sth = $dbh->prepare($query);
84 $sth->execute() || $form->dberror($query);
88 while ( my $row_ref = $sth->fetchrow_arrayref() ) {
89 push @positions, @$row_ref; # Copy the array contents
100 sub create_steuernummer {
101 $main::lxdebug->enter_sub();
103 $part = $form->{part};
104 $patterncount = $form->{patterncount};
105 $delimiter = $form->{delimiter};
106 $elster_pattern = $form->{elster_pattern};
108 # rebuild steuernummer and elstersteuernummer
109 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
110 # und die parts und delimiter
115 $steuernummer_new = $part;
116 $elstersteuernummer_new = $elster_FFFF;
117 $elstersteuernummer_new .= '0';
119 for ($h = 1; $h < $patterncount; $h++) {
120 $steuernummer_new .= qq|$delimiter|;
121 for ($i = 1; $i <= length($elster_pattern); $i++) {
122 $steuernummer_new .= $form->{"part_$h\_$i"};
123 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
126 if ($form->{steuernummer} ne $steuernummer_new) {
127 $form->{steuernummer} = $steuernummer_new;
128 $form->{elstersteuernummer} = $elstersteuernummer_new;
129 $form->{steuernummer_new} = $steuernummer_new;
131 $main::lxdebug->leave_sub();
132 return ($steuernummer_new, $elstersteuernummer_new);
135 sub steuernummer_input {
136 $main::lxdebug->enter_sub();
138 my ($self, $elsterland, $elsterFFFF, $steuernummer) = @_;
140 my $steuernummer_input = '';
142 $elster_land = $elsterland;
143 $elster_FFFF = $elsterFFFF;
144 $steuernummer = '0000000000' if ($steuernummer eq '');
146 # $steuernummer formatieren (nur Zahlen) -> $stnr
147 my $stnr = $steuernummer;
150 #Pattern description Elstersteuernummer
151 my %elster_STNRformat = (
152 'Mecklenburg Vorpommern' => 'FFF/BBB/UUUUP', # '/' 3
153 'Hessen' => '0FF BBB UUUUP', # ' ' 3
154 'Nordrhein Westfalen' => 'FFF/BBBB/UUUP', # '/' 3
155 'Schleswig Holstein' => 'FF BBB UUUUP', # ' ' 2
156 'Berlin' => 'FF/BBB/UUUUP', # '/' 3
157 'Thüringen' => 'FFF/BBB/UUUUP', # '/' 3
158 'Sachsen' => 'FFF/BBB/UUUUP', # '/' 3
159 'Hamburg' => 'FF/BBB/UUUUP', # '/' 3
160 'Baden Würtemberg' => 'FF/BBB/UUUUP', # '/' 2
161 'Sachsen Anhalt' => 'FFF/BBB/UUUUP', # '/' 3
162 'Saarland' => 'FFF/BBB/UUUUP', # '/' 3
163 'Bremen' => 'FF BBB UUUUP', # ' ' 3
164 'Bayern' => 'FFF/BBB/UUUUP', # '/' 3
165 'Rheinland Pfalz' => 'FF/BBB/UUUU/P', # '/' 4
166 'Niedersachsen' => 'FF/BBB/UUUUP', # '/' 3
167 'Brandenburg' => 'FFF/BBB/UUUUP', # '/' 3
171 my $elster_pattern = $elster_STNRformat{$elster_land};
172 my @elster_pattern = split(' ', $elster_pattern);
173 my $delimiter = ' ';
174 my $patterncount = @elster_pattern;
175 if ($patterncount < 2) {
176 @elster_pattern = ();
177 @elster_pattern = split('/', $elster_pattern);
179 $patterncount = @elster_pattern;
182 # no we have an array of patternparts and a delimiter
183 # create the first automated and fixed part and delimiter
185 $steuernummer_input .= qq|<b><font size="+1">|;
188 $elster_pattern[0] eq 'FFF' && do {
189 $part = substr($elster_FFFF, 1, 4);
190 $steuernummer_input .= qq|$part|;
193 $elster_pattern[0] eq '0FF' && do {
194 $part = '0' . substr($elster_FFFF, 2, 4);
195 $steuernummer_input .= qq|$part|;
198 $elster_pattern[0] eq 'FF' && do {
199 $part = substr($elster_FFFF, 2, 4);
200 $steuernummer_input .= qq|$part|;
204 $steuernummer_input .= qq|Fehler!|;
209 #now the rest of the Steuernummer ...
210 $steuernummer_input .= qq|</b></font>|;
211 $steuernummer_input .= qq|\n
212 <input type=hidden name="elster_pattern" value="$elster_pattern">
213 <input type=hidden name="patterncount" value="$patterncount">
214 <input type=hidden name="patternlength" value="$patterncount">
215 <input type=hidden name="delimiter" value="$delimiter">
216 <input type=hidden name="part" value="$part">
221 for (my $h = 1; $h < $patterncount; $h++) {
222 $steuernummer_input .= qq| $delimiter \n|;
223 for (my $i = 1; $i <= length($elster_pattern[$h]); $i++) {
224 $steuernummer_input .= qq|<select name="part_$h\_$i">\n|;
226 for (my $j = 0; $j <= 9; $j++) {
227 $steuernummer_input .= qq| <option value="$j"|;
228 if ($steuernummer ne '') {
229 if ($j eq substr($stnr, length($part) + $k, 1)) {
230 $steuernummer_input .= qq| selected|;
233 $steuernummer_input .= qq|>$j</option>\n|;
236 $steuernummer_input .= qq|</select>\n|;
240 $main::lxdebug->leave_sub();
242 return $steuernummer_input;
246 $main::lxdebug->enter_sub();
250 # Referenz wird übergeben, hash of hash wird nicht
251 # in neues Hash kopiert, sondern direkt über die Referenz verändert
252 # Prototyp für diese Konstruktion
254 my ($self, $land, $elsterFFFF, $elster_init) = @_;
257 my $FFFF = $elsterFFFF;
260 $checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
262 #if ($ENV{HTTP_USER_AGENT} =~ /(mozilla|opera|w3m)/i){
263 #$terminal='mozilla';
264 #} elsif ($ENV{HTTP_USER_AGENT} =~ /(links|lynx)/i){
268 #if ( $terminal eq 'mozilla' or $terminal eq 'js' ) {
270 <script language="Javascript">
271 function update_auswahl()
273 var elsterBLAuswahl = document.verzeichnis.elsterland_new;
274 var elsterFAAuswahl = document.verzeichnis.elsterFFFF_new;
276 elsterFAAuswahl.options.length = 0; // dropdown aufräumen
279 foreach $elster_land (sort keys %$elster_init) {
281 if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex].
282 value == "$elster_land")
286 my %elster_land_fa = ();
288 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
289 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
291 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
292 keys(%elster_land_fa)
295 elsterFAAuswahl.options[$j] = new Option("$elster_land_fa{$ffff} ($ffff)","$ffff");|;
311 <select size="1" name="elsterland_new" onchange="update_auswahl()">|;
313 $fa_auswahl .= qq|<option value="Auswahl" $checked>hier auswählen...</option>\n|;
315 foreach $elster_land (sort keys %$elster_init) {
317 <option value="$elster_land"|;
318 if ($elster_land eq $land and $checked eq '') {
319 $fa_auswahl .= qq| selected|;
321 $fa_auswahl .= qq|>$elster_land</option>
329 my $elster_land = '';
330 $elster_land = ($land ne '') ? $land : '';
331 %elster_land_fa = ();
332 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
333 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
341 <select size="1" name="elsterFFFF_new">|;
342 if ($elsterFFFF eq '') {
343 $fa_auswahl .= qq|<option value="Auswahl" $checked>hier auswählen...</option>|;
345 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
346 keys(%elster_land_fa)
350 <option value="$ffff"|;
351 if ($ffff eq $elsterFFFF and $checked eq '') {
352 $fa_auswahl .= qq| selected|;
354 $fa_auswahl .= qq|>$elster_land_fa{$ffff} ($ffff)</option>|;
363 $main::lxdebug->leave_sub();
368 $main::lxdebug->enter_sub();
372 if ($ENV{HTTP_USER_AGENT}) {
375 print qq|<body><h2 class=info>Hinweis</h2>
381 <input type=button value="zurück" onClick="history.go(-1)">
389 if ($form->{error_function}) {
390 &{ $form->{error_function} }($msg);
392 die "Hinweis: $msg\n";
396 $main::lxdebug->leave_sub();
400 $main::lxdebug->enter_sub();
403 # soll mal eine Erinnerungsfunktion für USTVA Abgaben werden, die automatisch
404 # den Termin der nächsten USTVA anzeigt.
407 my ($today, $FA_dauerfrist, $FA_voranmeld) = @_;
412 $today =~ /(\d\d\d\d)(\d\d)(\d\d)/;
418 $yymmdd = "$year$month$day" * 1;
419 $mmdd = "$month$day" * 1;
423 #$ical = '...vcal format';
425 #if ($FA_voranmeld eq 'month'){
427 %liste = ("0110" => 'December',
429 "0310" => 'February',
436 "1010" => 'September',
438 "1210" => 'November');
442 $month += 1 if ($day > 10);
443 $month = sprintf("%02d", $month);
444 $stichtag = $year . $month . "10";
445 $ust_va = $month . "10";
447 foreach $date (%liste) {
448 $ust_va = $liste{$date} if ($date eq $stichtag);
451 #} elsif ($FA_voranmeld eq 'quarter'){
456 #@stichtag = ('10.04.2004', '10.05.2004');
458 #@liste = ['0110', '0210', '0310', '0410', '0510', '0610', '0710', '0810', '0910',
459 # '1010', '1110', '1210', ];
461 #foreach $key (@liste){
462 # #if ($ddmm < ('0110' * 1));
464 # $stichtag = $liste[$key - 1] if ($ddmm > $key);
468 #$stichtag =~ /([\d]\d)(\d\d)$/
469 #$stichtag = "$1.$2.$yy"
471 $main::lxdebug->leave_sub();
472 return ($stichtag, $description, $tage_bis, $ical);
475 sub query_finanzamt {
476 $main::lxdebug->enter_sub();
478 my ($self, $myconfig, $form) = @_;
480 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
482 #Test, if table finanzamt exist
483 my $table = 'finanzamt';
484 my $filename = "sql/$table.sql";
486 my $tst = $dbh->prepare("SELECT * FROM $table");
490 #There is no table, read the table from sql/finanzamt.sql
491 print qq|<p>Bitte warten, Tabelle $table wird einmalig in Datenbank:
492 $myconfig->{dbname} als Benutzer: $myconfig->{dbuser} hinzugefügt...</p>|;
493 process_query($form, $dbh, $filename) || $self->error(DBI->errstr);
495 #execute second last call
496 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
513 'FA_PLZ_Grosskunden', # 9
514 'FA_PLZ_Postfach', # 10
517 'FA_Kontonummer_1', # 13
518 'FA_Bankbezeichnung_1', # 14
519 #'FA_BankIBAN_1', # 15
520 #'FA_BankBIC_1', # 16
521 #'FA_BankInhaber_BUFA_Nr_1', # 17
523 'FA_Kontonummer_2', # 19
524 'FA_Bankbezeichnung_2', # 20
525 #'FA_BankIBAN_2', # 21
526 #'FA_BankBIC_2', # 22
527 #'FA_BankInhaber_BUFA_Nr_2', # 23
528 'FA_Oeffnungszeiten', # 24
531 #'FA_zustaendige_Hauptstelle_BUFA_Nr', # 27
532 #'FA_zustaendige_vorgesetzte_Finanzbehoerde' # 28
535 my $field = join(', ', @vars);
537 my $query = "SELECT $field FROM finanzamt ORDER BY FA_Land_nr";
538 my $sth = $dbh->prepare($query) or $self->error($dbh->errstr);
539 $sth->execute || $form->dberror($query);
540 my $array_ref = $sth->fetchall_arrayref();
542 foreach my $row (@$array_ref) {
543 my $FA_finanzamt = $row;
544 $land = 'Schleswig Holstein' if (@$FA_finanzamt[0] eq '1');
545 $land = 'Hamburg' if (@$FA_finanzamt[0] eq '2');
546 $land = 'Niedersachsen' if (@$FA_finanzamt[0] eq '3');
547 $land = 'Bremen' if (@$FA_finanzamt[0] eq '4');
548 $land = 'Nordrhein Westfalen' if (@$FA_finanzamt[0] eq '5');
549 $land = 'Hessen' if (@$FA_finanzamt[0] eq '6');
550 $land = 'Rheinland Pfalz' if (@$FA_finanzamt[0] eq '7');
551 $land = 'Baden Würtemberg' if (@$FA_finanzamt[0] eq '8');
552 $land = 'Bayern' if (@$FA_finanzamt[0] eq '9');
553 $land = 'Saarland' if (@$FA_finanzamt[0] eq '10');
554 $land = 'Berlin' if (@$FA_finanzamt[0] eq '11');
555 $land = 'Brandenburg' if (@$FA_finanzamt[0] eq '12');
556 $land = 'Mecklenburg Vorpommern' if (@$FA_finanzamt[0] eq '13');
557 $land = 'Sachsen' if (@$FA_finanzamt[0] eq '14');
558 $land = 'Sachsen Anhalt' if (@$FA_finanzamt[0] eq '15');
559 $land = 'Thüringen' if (@$FA_finanzamt[0] eq '16');
561 my $ffff = @$FA_finanzamt[1];
564 $rec->{$land} = $ffff;
569 $finanzamt{$land}{$ffff} = [@$FA_finanzamt];
575 $main::lxdebug->leave_sub();
581 $main::lxdebug->enter_sub();
583 # Copyright D. Simander -> SL::Form under Gnu GPL.
584 my ($form, $dbh, $filename) = @_;
586 # return unless (-f $filename);
588 open my $FH, "<", "$filename" or $form->error("$filename : $!\n");
595 # Remove DOS and Unix style line endings.
598 # don't add comments or empty lines
599 next if /^(--.*|\s+)$/;
601 for (my $i = 0; $i < length($_); $i++) {
602 my $char = substr($_, $i, 1);
604 # Are we inside a string?
606 if ($char eq $quote_chars[-1]) {
612 if (($char eq "'") || ($char eq "\"")) {
613 push(@quote_chars, $char);
615 } elsif ($char eq ";") {
617 # Query is complete. Send it.
619 $sth = $dbh->prepare($query);
620 $sth->execute || $form->dberror($query);
634 $main::lxdebug->leave_sub();
638 $main::lxdebug->enter_sub();
640 my ($self, $myconfig, $form) = @_;
642 # connect to database
643 my $dbh = $form->dbconnect($myconfig);
646 my $category = "pos_ustva";
648 my @category_cent = USTVA->report_variables({
649 myconfig => $myconfig,
652 attribute => 'position',
656 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
658 my @category_euro = USTVA->report_variables({
659 myconfig => $myconfig,
662 attribute => 'position',
666 push @category_euro, USTVA->report_variables({
667 myconfig => $myconfig,
670 attribute => 'position',
674 $form->{decimalplaces} *= 1;
676 foreach $item (@category_cent) {
677 $form->{"$item"} = 0;
679 foreach $item (@category_euro) {
680 $form->{"$item"} = 0;
682 my $coa_name = coa_get($dbh);
683 $form->{coa} = $coa_name;
685 # Controlvariable for templates
686 $form->{"$coa_name"} = '1';
688 $main::lxdebug->message(LXDebug::DEBUG2, "COA: '$form->{coa}', \$form->{$coa_name} = 1");
690 &get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate},
693 ###########################################
695 # Nationspecific Modfications
697 ###########################################
701 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU'){
704 # Umordnen der Kennziffern
705 if ( $form->{year} < 2007) {
706 $form->{35} += $form->{81};
707 $form->{36} += $form->{811};
708 $form->{95} += $form->{89};
709 $form->{98} += $form->{891};
710 map { delete $form->{$_} } qw(81 811 89 891);
712 $form->{35} += $form->{51};
713 $form->{36} += $form->{511};
714 $form->{95} += $form->{97};
715 $form->{98} += $form->{971};
716 map { delete $form->{$_} } qw(51 511 97 971);
722 # Fixme: Wird auch noch für Oesterreich gebraucht,
723 # weil kein eigenes Ausgabeformular
724 # sotte aber aus der allgeméinen Steuerberechnung verschwinden
726 # Berechnung der USTVA Formularfelder laut Bogen 207
729 $form->{"51r"} = $form->{"511"};
730 $form->{"86r"} = $form->{"861"};
731 $form->{"97r"} = $form->{"971"};
732 $form->{"93r"} = $form->{"931"};
734 $form->{"Z43"} = $form->{"511"} + $form->{"811"} + $form->{"861"}
735 + $form->{"36"} + $form->{"80"} + $form->{"971"}
736 + $form->{"891"} + $form->{"931"} + $form->{"96"}
739 $form->{"Z45"} = $form->{"Z43"};
741 $form->{"Z53"} = $form->{"Z45"} + $form->{"53"} + $form->{"74"}
742 + $form->{"85"} + $form->{"65"};
744 $form->{"Z62"} = $form->{"Z43"} - $form->{"66"} - $form->{"61"}
745 - $form->{"62"} - $form->{"67"} - $form->{"63"}
746 - $form->{"64"} - $form->{"59"};
748 $form->{"Z65"} = $form->{"Z62"} - $form->{"69"};
749 $form->{"83"} = $form->{"Z65"} - $form->{"39"};
753 $main::lxdebug->leave_sub();
760 my $query= qq|SELECT coa FROM defaults|;
762 my $sth = $dbh->prepare($query);
764 $sth->execute || $form->dberror($query);
766 ($ref) = $sth->fetchrow_array;
772 sub get_accounts_ustva {
773 $main::lxdebug->enter_sub();
775 my ($dbh, $last_period, $fromdate, $todate, $form, $category) = @_;
786 my $gltaxkey_where = "(tk.pos_ustva>=59 AND tk.pos_ustva<=66)";
789 if ($form->{method} eq 'cash') {
790 $subwhere .= " AND transdate >= '$fromdate'";
791 $glwhere = " AND ac.transdate >= '$fromdate'";
792 $ARwhere .= " AND acc.transdate >= '$fromdate'";
794 $APwhere .= " AND AP.transdate >= '$fromdate'";
795 $where .= " AND ac.transdate >= '$fromdate'";
799 $where .= " AND ac.transdate <= '$todate'";
800 $ARwhere .= " AND acc.transdate <= '$todate'";
803 ############################################
804 # Method eq 'cash' = IST Versteuerung
805 ############################################
806 # Betrifft nur die eingenommene Umsatzsteuer
808 ############################################
810 if ($form->{method} eq 'cash') {
814 -- USTVA IST-Versteuerung
816 -- Alle tatsaechlichen _Zahlungseingaenge_
817 -- im Voranmeldezeitraum erfassen
818 -- (Teilzahlungen werden prozentual auf verschiedene Steuern aufgeteilt)
820 -- Bezahlt / Rechnungssumme
822 SELECT SUM(acc.amount)
824 INNER JOIN chart c ON (acc.chart_id = c.id
825 AND c.link like '%AR_paid%')
829 AND acc.trans_id = ac.trans_id
833 SELECT amount FROM ar WHERE id = ac.trans_id
838 LEFT JOIN chart c ON (c.id = ac.chart_id)
839 LEFT JOIN ar ON (ar.id = ac.trans_id)
840 LEFT JOIN taxkeys tk ON (
842 SELECT id FROM taxkeys
843 WHERE chart_id = ac.chart_id
844 -- AND taxkey_id = ac.taxkey
845 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
846 ORDER BY startdate DESC LIMIT 1
851 -- Here no where, please. All Transactions ever should be
852 -- testet if they are paied in the USTVA report period.
853 GROUP BY tk.pos_ustva
856 } elsif ($form->{method} eq 'accrual') {
857 #########################################
858 # Method eq 'accrual' = Soll Versteuerung
859 #########################################
862 -- Alle Einnahmen AR und pos_ustva erfassen
864 - sum(ac.amount) AS amount,
867 JOIN chart c ON (c.id = ac.chart_id)
868 JOIN ar ON (ar.id = ac.trans_id)
871 SELECT id FROM taxkeys
872 WHERE chart_id = ac.chart_id
873 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
874 ORDER BY startdate DESC LIMIT 1
880 GROUP BY tk.pos_ustva
885 $self->error("Unknown tax method: $form->{method}")
889 #########################################
890 # Ausgaben und Gl Buchungen sind gleich
891 # für Ist- und Soll-Versteuerung
892 #########################################
894 UNION -- alle Ausgaben AP erfassen
897 sum(ac.amount) AS amount,
900 JOIN ap ON (ap.id = ac.trans_id )
901 JOIN chart c ON (c.id = ac.chart_id)
902 LEFT JOIN taxkeys tk ON (
904 SELECT id FROM taxkeys
906 AND chart_id=ac.chart_id
907 --AND taxkey_id = ac.taxkey
908 AND startdate <= COALESCE(AP.transdate)
909 ORDER BY startdate DESC LIMIT 1
915 GROUP BY tk.pos_ustva
917 UNION -- Einnahmen direkter gl Buchungen erfassen
920 ( - ac.amount) AS amount,
923 JOIN chart c ON (c.id = ac.chart_id)
924 JOIN gl a ON (a.id = ac.trans_id)
925 LEFT JOIN taxkeys tk ON (
927 SELECT id FROM taxkeys
928 WHERE chart_id=ac.chart_id
929 AND NOT $gltaxkey_where
930 AND startdate <= COALESCE(ac.transdate)
931 ORDER BY startdate DESC LIMIT 1
938 GROUP BY tk.pos_ustva
941 UNION -- Ausgaben direkter gl Buchungen erfassen
944 (ac.amount) AS amount,
947 JOIN chart c ON (c.id = ac.chart_id)
948 JOIN gl a ON (a.id = ac.trans_id)
949 LEFT JOIN taxkeys tk ON (
951 SELECT id FROM taxkeys
952 WHERE chart_id=ac.chart_id
954 AND startdate <= COALESCE(ac.transdate)
955 ORDER BY startdate DESC LIMIT 1
962 GROUP BY tk.pos_ustva
970 # Show all $query in Debuglevel LXDebug::QUERY
971 $callingdetails = (caller (0))[3];
972 $main::lxdebug->message(LXDebug::QUERY, "$callingdetails \$query=\n $query");
974 my $sth = $dbh->prepare($query);
976 $sth->execute || $form->dberror($query);
978 while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
980 $ref->{amount} *= -1;
981 $form->{ $ref->{$category} } += $ref->{amount};
986 $main::lxdebug->leave_sub();
991 $main::lxdebug->enter_sub();
993 my ($self, $userspath, $filename) = @_;
995 $form->error("Missing Parameter: @_") if !$userspath || !$filename;
997 my $form = $main::form;
999 $filename = "$form->{login}_$filename";
1000 $filename =~ s|.*/||;
1001 $filename = "$userspath/$filename";
1002 open my $FACONF, "<", $filename or sub {# Annon Sub
1004 # create file if file does not exist
1005 open my $FANEW, ">", $filename or $form->error("CREATE: $filename : $!");
1006 close $FANEW or $form->error("CLOSE: $filename : $!");
1008 #try again open file
1009 open my $FACONF, "<", $filename or $form->error("OPEN: $filename : $!");
1014 next if (/^(\#|\s)/);
1019 # remove any trailing whitespace
1020 s/^\s*(.*?)\s*$/$1/;
1021 my ($key, $value) = split(/=/, $_, 2);
1023 $form->{$key} = "$value";
1029 $main::lxdebug->leave_sub();