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 sub report_variables {
29 # Get all positions for taxreport out of the database
30 # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl
32 return unless defined wantarray;
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;
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 );
48 FROM tax.report_variables
49 LEFT JOIN tax.report_headings
50 ON (tax.report_variables.heading_id = tax.report_headings.id)
56 $main::lxdebug->message(LXDebug::QUERY, "\$query= \n $query\n");
58 my $dbh = $form->dbconnect($myconfig);
59 my $sth = $dbh->prepare($query);
61 $sth->execute() || $form->dberror($query);
65 while ( my $row_ref = $sth->fetchrow_arrayref() ) {
66 push @positions, @$row_ref; # Copy the array contents
77 sub create_steuernummer {
78 $main::lxdebug->enter_sub();
80 $part = $form->{part};
81 $patterncount = $form->{patterncount};
82 $delimiter = $form->{delimiter};
83 $elster_pattern = $form->{elster_pattern};
85 # rebuild steuernummer and elstersteuernummer
86 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
87 # und die parts und delimiter
92 $steuernummer_new = $part;
93 $elstersteuernummer_new = $elster_FFFF;
94 $elstersteuernummer_new .= '0';
96 for ($h = 1; $h < $patterncount; $h++) {
97 $steuernummer_new .= qq|$delimiter|;
98 for ($i = 1; $i <= length($elster_pattern); $i++) {
99 $steuernummer_new .= $form->{"part_$h\_$i"};
100 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
103 if ($form->{steuernummer} ne $steuernummer_new) {
104 $form->{steuernummer} = $steuernummer_new;
105 $form->{elstersteuernummer} = $elstersteuernummer_new;
106 $form->{steuernummer_new} = $steuernummer_new;
108 $main::lxdebug->leave_sub();
109 return ($steuernummer_new, $elstersteuernummer_new);
112 sub steuernummer_input {
113 $main::lxdebug->enter_sub();
115 my ($self, $elsterland, $elsterFFFF, $steuernummer) = @_;
117 my $steuernummer_input = '';
119 $elster_land = $elsterland;
120 $elster_FFFF = $elsterFFFF;
121 $steuernummer = '0000000000' if ($steuernummer eq '');
123 # $steuernummer formatieren (nur Zahlen) -> $stnr
124 my $stnr = $steuernummer;
127 #Pattern description Elstersteuernummer
128 my %elster_STNRformat = (
129 'Mecklenburg Vorpommern' => 'FFF/BBB/UUUUP', # '/' 3
130 'Hessen' => '0FF BBB UUUUP', # ' ' 3
131 'Nordrhein Westfalen' => 'FFF/BBBB/UUUP', # '/' 3
132 'Schleswig Holstein' => 'FF BBB UUUUP', # ' ' 2
133 'Berlin' => 'FF/BBB/UUUUP', # '/' 3
134 'Thüringen' => 'FFF/BBB/UUUUP', # '/' 3
135 'Sachsen' => 'FFF/BBB/UUUUP', # '/' 3
136 'Hamburg' => 'FF/BBB/UUUUP', # '/' 3
137 'Baden Würtemberg' => 'FF/BBB/UUUUP', # '/' 2
138 'Sachsen Anhalt' => 'FFF/BBB/UUUUP', # '/' 3
139 'Saarland' => 'FFF/BBB/UUUUP', # '/' 3
140 'Bremen' => 'FF BBB UUUUP', # ' ' 3
141 'Bayern' => 'FFF/BBB/UUUUP', # '/' 3
142 'Rheinland Pfalz' => 'FF/BBB/UUUU/P', # '/' 4
143 'Niedersachsen' => 'FF/BBB/UUUUP', # '/' 3
144 'Brandenburg' => 'FFF/BBB/UUUUP', # '/' 3
148 my $elster_pattern = $elster_STNRformat{$elster_land};
149 my @elster_pattern = split(' ', $elster_pattern);
150 my $delimiter = ' ';
151 my $patterncount = @elster_pattern;
152 if ($patterncount < 2) {
153 @elster_pattern = ();
154 @elster_pattern = split('/', $elster_pattern);
156 $patterncount = @elster_pattern;
159 # no we have an array of patternparts and a delimiter
160 # create the first automated and fixed part and delimiter
162 $steuernummer_input .= qq|<b><font size="+1">|;
165 $elster_pattern[0] eq 'FFF' && do {
166 $part = substr($elster_FFFF, 1, 4);
167 $steuernummer_input .= qq|$part|;
170 $elster_pattern[0] eq '0FF' && do {
171 $part = '0' . substr($elster_FFFF, 2, 4);
172 $steuernummer_input .= qq|$part|;
175 $elster_pattern[0] eq 'FF' && do {
176 $part = substr($elster_FFFF, 2, 4);
177 $steuernummer_input .= qq|$part|;
181 $steuernummer_input .= qq|Fehler!|;
186 #now the rest of the Steuernummer ...
187 $steuernummer_input .= qq|</b></font>|;
188 $steuernummer_input .= qq|\n
189 <input type=hidden name="elster_pattern" value="$elster_pattern">
190 <input type=hidden name="patterncount" value="$patterncount">
191 <input type=hidden name="patternlength" value="$patterncount">
192 <input type=hidden name="delimiter" value="$delimiter">
193 <input type=hidden name="part" value="$part">
198 for (my $h = 1; $h < $patterncount; $h++) {
199 $steuernummer_input .= qq| $delimiter \n|;
200 for (my $i = 1; $i <= length($elster_pattern[$h]); $i++) {
201 $steuernummer_input .= qq|<select name="part_$h\_$i">\n|;
203 for (my $j = 0; $j <= 9; $j++) {
204 $steuernummer_input .= qq| <option value="$j"|;
205 if ($steuernummer ne '') {
206 if ($j eq substr($stnr, length($part) + $k, 1)) {
207 $steuernummer_input .= qq| selected|;
210 $steuernummer_input .= qq|>$j</option>\n|;
213 $steuernummer_input .= qq|</select>\n|;
217 $main::lxdebug->leave_sub();
219 return $steuernummer_input;
223 $main::lxdebug->enter_sub();
227 # Referenz wird übergeben, hash of hash wird nicht
228 # in neues Hash kopiert, sondern direkt über die Referenz verändert
229 # Prototyp für diese Konstruktion
231 my ($self, $land, $elsterFFFF, $elster_init) = @_;
234 my $FFFF = $elsterFFFF;
237 $checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
239 #if ($ENV{HTTP_USER_AGENT} =~ /(mozilla|opera|w3m)/i){
240 #$terminal='mozilla';
241 #} elsif ($ENV{HTTP_USER_AGENT} =~ /(links|lynx)/i){
245 #if ( $terminal eq 'mozilla' or $terminal eq 'js' ) {
247 <script language="Javascript">
248 function update_auswahl()
250 var elsterBLAuswahl = document.verzeichnis.elsterland_new;
251 var elsterFAAuswahl = document.verzeichnis.elsterFFFF_new;
253 elsterFAAuswahl.options.length = 0; // dropdown aufräumen
256 foreach $elster_land (sort keys %$elster_init) {
258 if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex].
259 value == "$elster_land")
263 my %elster_land_fa = ();
265 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
266 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
268 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
269 keys(%elster_land_fa)
272 elsterFAAuswahl.options[$j] = new Option("$elster_land_fa{$ffff} ($ffff)","$ffff");|;
288 <select size="1" name="elsterland_new" onchange="update_auswahl()">|;
290 $fa_auswahl .= qq|<option value="Auswahl" $checked>hier auswählen...</option>\n|;
292 foreach $elster_land (sort keys %$elster_init) {
294 <option value="$elster_land"|;
295 if ($elster_land eq $land and $checked eq '') {
296 $fa_auswahl .= qq| selected|;
298 $fa_auswahl .= qq|>$elster_land</option>
306 my $elster_land = '';
307 $elster_land = ($land ne '') ? $land : '';
308 %elster_land_fa = ();
309 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
310 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
318 <select size="1" name="elsterFFFF_new">|;
319 if ($elsterFFFF eq '') {
320 $fa_auswahl .= qq|<option value="Auswahl" $checked>hier auswählen...</option>|;
322 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
323 keys(%elster_land_fa)
327 <option value="$ffff"|;
328 if ($ffff eq $elsterFFFF and $checked eq '') {
329 $fa_auswahl .= qq| selected|;
331 $fa_auswahl .= qq|>$elster_land_fa{$ffff} ($ffff)</option>|;
340 $main::lxdebug->leave_sub();
345 $main::lxdebug->enter_sub();
349 if ($ENV{HTTP_USER_AGENT}) {
352 print qq|<body><h2 class=info>Hinweis</h2>
358 <input type=button value="zurück" onClick="history.go(-1)">
366 if ($form->{error_function}) {
367 &{ $form->{error_function} }($msg);
369 die "Hinweis: $msg\n";
373 $main::lxdebug->leave_sub();
377 $main::lxdebug->enter_sub();
380 # soll mal eine Erinnerungsfunktion für USTVA Abgaben werden, die automatisch
381 # den Termin der nächsten USTVA anzeigt.
384 my ($today, $FA_dauerfrist, $FA_voranmeld) = @_;
389 $today =~ /(\d\d\d\d)(\d\d)(\d\d)/;
395 $yymmdd = "$year$month$day" * 1;
396 $mmdd = "$month$day" * 1;
400 #$ical = '...vcal format';
402 #if ($FA_voranmeld eq 'month'){
404 %liste = ("0110" => 'December',
406 "0310" => 'February',
413 "1010" => 'September',
415 "1210" => 'November');
419 $month += 1 if ($day > 10);
420 $month = sprintf("%02d", $month);
421 $stichtag = $year . $month . "10";
422 $ust_va = $month . "10";
424 foreach $date (%liste) {
425 $ust_va = $liste{$date} if ($date eq $stichtag);
428 #} elsif ($FA_voranmeld eq 'quarter'){
433 #@stichtag = ('10.04.2004', '10.05.2004');
435 #@liste = ['0110', '0210', '0310', '0410', '0510', '0610', '0710', '0810', '0910',
436 # '1010', '1110', '1210', ];
438 #foreach $key (@liste){
439 # #if ($ddmm < ('0110' * 1));
441 # $stichtag = $liste[$key - 1] if ($ddmm > $key);
445 #$stichtag =~ /([\d]\d)(\d\d)$/
446 #$stichtag = "$1.$2.$yy"
448 $main::lxdebug->leave_sub();
449 return ($stichtag, $description, $tage_bis, $ical);
452 sub query_finanzamt {
453 $main::lxdebug->enter_sub();
455 my ($self, $myconfig, $form) = @_;
457 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
459 #Test, if table finanzamt exist
460 my $table = 'finanzamt';
461 my $filename = "sql/$table.sql";
463 my $tst = $dbh->prepare("SELECT * FROM $table");
467 #There is no table, read the table from sql/finanzamt.sql
468 print qq|<p>Bitte warten, Tabelle $table wird einmalig in Datenbank:
469 $myconfig->{dbname} als Benutzer: $myconfig->{dbuser} hinzugefügt...</p>|;
470 process_query($form, $dbh, $filename) || $self->error(DBI->errstr);
472 #execute second last call
473 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
490 'FA_PLZ_Grosskunden', # 9
491 'FA_PLZ_Postfach', # 10
494 'FA_Kontonummer_1', # 13
495 'FA_Bankbezeichnung_1', # 14
496 #'FA_BankIBAN_1', # 15
497 #'FA_BankBIC_1', # 16
498 #'FA_BankInhaber_BUFA_Nr_1', # 17
500 'FA_Kontonummer_2', # 19
501 'FA_Bankbezeichnung_2', # 20
502 #'FA_BankIBAN_2', # 21
503 #'FA_BankBIC_2', # 22
504 #'FA_BankInhaber_BUFA_Nr_2', # 23
505 'FA_Oeffnungszeiten', # 24
508 #'FA_zustaendige_Hauptstelle_BUFA_Nr', # 27
509 #'FA_zustaendige_vorgesetzte_Finanzbehoerde' # 28
512 my $field = join(', ', @vars);
514 my $query = "SELECT $field FROM finanzamt ORDER BY FA_Land_nr";
515 my $sth = $dbh->prepare($query) or $self->error($dbh->errstr);
516 $sth->execute || $form->dberror($query);
517 my $array_ref = $sth->fetchall_arrayref();
519 foreach my $row (@$array_ref) {
520 my $FA_finanzamt = $row;
521 $land = 'Schleswig Holstein' if (@$FA_finanzamt[0] eq '1');
522 $land = 'Hamburg' if (@$FA_finanzamt[0] eq '2');
523 $land = 'Niedersachsen' if (@$FA_finanzamt[0] eq '3');
524 $land = 'Bremen' if (@$FA_finanzamt[0] eq '4');
525 $land = 'Nordrhein Westfalen' if (@$FA_finanzamt[0] eq '5');
526 $land = 'Hessen' if (@$FA_finanzamt[0] eq '6');
527 $land = 'Rheinland Pfalz' if (@$FA_finanzamt[0] eq '7');
528 $land = 'Baden Würtemberg' if (@$FA_finanzamt[0] eq '8');
529 $land = 'Bayern' if (@$FA_finanzamt[0] eq '9');
530 $land = 'Saarland' if (@$FA_finanzamt[0] eq '10');
531 $land = 'Berlin' if (@$FA_finanzamt[0] eq '11');
532 $land = 'Brandenburg' if (@$FA_finanzamt[0] eq '12');
533 $land = 'Mecklenburg Vorpommern' if (@$FA_finanzamt[0] eq '13');
534 $land = 'Sachsen' if (@$FA_finanzamt[0] eq '14');
535 $land = 'Sachsen Anhalt' if (@$FA_finanzamt[0] eq '15');
536 $land = 'Thüringen' if (@$FA_finanzamt[0] eq '16');
538 my $ffff = @$FA_finanzamt[1];
541 $rec->{$land} = $ffff;
546 $finanzamt{$land}{$ffff} = [@$FA_finanzamt];
552 $main::lxdebug->leave_sub();
558 $main::lxdebug->enter_sub();
560 # Copyright D. Simander -> SL::Form under Gnu GPL.
561 my ($form, $dbh, $filename) = @_;
563 # return unless (-f $filename);
565 open(FH, "$filename") or $form->error("$filename : $!\n");
572 # Remove DOS and Unix style line endings.
575 # don't add comments or empty lines
576 next if /^(--.*|\s+)$/;
578 for (my $i = 0; $i < length($_); $i++) {
579 my $char = substr($_, $i, 1);
581 # Are we inside a string?
583 if ($char eq $quote_chars[-1]) {
589 if (($char eq "'") || ($char eq "\"")) {
590 push(@quote_chars, $char);
592 } elsif ($char eq ";") {
594 # Query is complete. Send it.
596 $sth = $dbh->prepare($query);
597 $sth->execute || $form->dberror($query);
611 $main::lxdebug->leave_sub();
615 $main::lxdebug->enter_sub();
617 my ($self, $myconfig, $form) = @_;
619 # connect to database
620 my $dbh = $form->dbconnect($myconfig);
623 my $category = "pos_ustva";
625 my @category_cent = USTVA->report_variables({
626 myconfig => $myconfig,
629 attribute => 'position',
633 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
635 my @category_euro = USTVA->report_variables({
636 myconfig => $myconfig,
639 attribute => 'position',
643 push @category_euro, USTVA->report_variables({
644 myconfig => $myconfig,
647 attribute => 'position',
651 $form->{decimalplaces} *= 1;
653 foreach $item (@category_cent) {
654 $form->{"$item"} = 0;
656 foreach $item (@category_euro) {
657 $form->{"$item"} = 0;
659 my $coa_name = coa_get($dbh);
660 $form->{coa} = $coa_name;
662 # Controlvariable for templates
663 $form->{"$coa_name"} = '1';
665 $main::lxdebug->message(LXDebug::DEBUG2, "COA: '$form->{coa}', \$form->{$coa_name} = 1");
667 &get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate},
670 ###########################################
672 # Nationspecific Modfications
674 ###########################################
678 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU'){
681 # Umordnen der Kennziffern
682 if ( $form->{year} < 2007) {
683 $form->{35} += $form->{81};
684 $form->{36} += $form->{811};
685 $form->{95} += $form->{89};
686 $form->{98} += $form->{891};
687 map { delete $form->{$_} } qw(81 811 89 891);
689 $form->{35} += $form->{51};
690 $form->{36} += $form->{511};
691 $form->{95} += $form->{97};
692 $form->{98} += $form->{971};
693 map { delete $form->{$_} } qw(51 511 97 971);
699 # Fixme: Wird auch noch für Oesterreich gebraucht,
700 # weil kein eigenes Ausgabeformular
701 # sotte aber aus der allgeméinen Steuerberechnung verschwinden
703 # Berechnung der USTVA Formularfelder laut Bogen 207
706 $form->{"51r"} = $form->{"511"};
707 $form->{"86r"} = $form->{"861"};
708 $form->{"97r"} = $form->{"971"};
709 $form->{"93r"} = $form->{"931"};
711 $form->{"Z43"} = $form->{"511"} + $form->{"811"} + $form->{"861"}
712 + $form->{"36"} + $form->{"80"} + $form->{"971"}
713 + $form->{"891"} + $form->{"931"} + $form->{"96"}
716 $form->{"Z45"} = $form->{"Z43"};
718 $form->{"Z53"} = $form->{"Z45"} + $form->{"53"} + $form->{"74"}
719 + $form->{"85"} + $form->{"65"};
721 $form->{"Z62"} = $form->{"Z43"} - $form->{"66"} - $form->{"61"}
722 - $form->{"62"} - $form->{"67"} - $form->{"63"}
723 - $form->{"64"} - $form->{"59"};
725 $form->{"Z65"} = $form->{"Z62"} - $form->{"69"};
726 $form->{"83"} = $form->{"Z65"} - $form->{"39"};
730 $main::lxdebug->leave_sub();
737 my $query= qq|SELECT coa FROM defaults|;
739 my $sth = $dbh->prepare($query);
741 $sth->execute || $form->dberror($query);
743 ($ref) = $sth->fetchrow_array;
749 sub get_accounts_ustva {
750 $main::lxdebug->enter_sub();
752 my ($dbh, $last_period, $fromdate, $todate, $form, $category) = @_;
754 my ($null, $department_id) = split /--/, $form->{department};
768 my $gltaxkey_where = "(tk.pos_ustva>=59 AND tk.pos_ustva<=66)";
771 if ($form->{method} eq 'cash') {
772 $subwhere .= " AND transdate >= '$fromdate'";
773 $glwhere = " AND ac.transdate >= '$fromdate'";
774 $ARwhere .= " AND acc.transdate >= '$fromdate'";
776 $APwhere .= " AND AP.transdate >= '$fromdate'";
777 $where .= " AND ac.transdate >= '$fromdate'";
781 $where .= " AND ac.transdate <= '$todate'";
782 $ARwhere .= " AND acc.transdate <= '$todate'";
785 if ($department_id) {
787 JOIN department t ON (a.department_id = t.id)
790 AND t.id = $department_id
794 if ($form->{project_id}) {
796 AND ac.project_id = $form->{project_id}
799 ############################################
800 # Method eq 'cash' = IST Versteuerung
801 ############################################
802 # Betrifft nur die eingenommene Umsatzsteuer
804 ############################################
806 if ($form->{method} eq 'cash') {
810 -- USTVA IST-Versteuerung
812 -- Alle tatsaechlichen _Zahlungseingaenge_
813 -- im Voranmeldezeitraum erfassen
814 -- (Teilzahlungen werden prozentual auf verschiedene Steuern aufgeteilt)
816 -- Bezahlt / Rechnungssumme
818 SELECT SUM(acc.amount)
820 INNER JOIN chart c ON (acc.chart_id = c.id
821 AND c.link like '%AR_paid%')
825 AND acc.trans_id = ac.trans_id
829 SELECT amount FROM ar WHERE id = ac.trans_id
834 LEFT JOIN chart c ON (c.id = ac.chart_id)
835 LEFT JOIN ar ON (ar.id = ac.trans_id)
836 LEFT JOIN taxkeys tk ON (
838 SELECT id FROM taxkeys
839 WHERE chart_id = ac.chart_id
840 -- AND taxkey_id = ac.taxkey
841 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
842 ORDER BY startdate DESC LIMIT 1
847 -- Here no where, please. All Transactions ever should be
848 -- testet if they are paied in the USTVA report period.
849 GROUP BY tk.pos_ustva
852 } elsif ($form->{method} eq 'accrual') {
853 #########################################
854 # Method eq 'accrual' = Soll Versteuerung
855 #########################################
857 if ($department_id) {
859 JOIN dpt_trans t ON (t.trans_id = ac.trans_id)
862 AND t.department_id = $department_id
868 -- Alle Einnahmen AR und pos_ustva erfassen
870 - sum(ac.amount) AS amount,
873 JOIN chart c ON (c.id = ac.chart_id)
874 JOIN ar ON (ar.id = ac.trans_id)
877 SELECT id FROM taxkeys
878 WHERE chart_id = ac.chart_id
879 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
880 ORDER BY startdate DESC LIMIT 1
888 GROUP BY tk.pos_ustva
893 $self->error("Unknown tax method: $form->{method}")
897 #########################################
898 # Ausgaben und Gl Buchungen sind gleich
899 # für Ist- und Soll-Versteuerung
900 #########################################
902 UNION -- alle Ausgaben AP erfassen
905 sum(ac.amount) AS amount,
908 JOIN ap ON (ap.id = ac.trans_id )
909 JOIN chart c ON (c.id = ac.chart_id)
910 LEFT JOIN taxkeys tk ON (
912 SELECT id FROM taxkeys
914 AND chart_id=ac.chart_id
915 AND taxkey_id = ac.taxkey
916 AND startdate <= COALESCE(AP.transdate)
917 ORDER BY startdate DESC LIMIT 1
925 GROUP BY tk.pos_ustva
927 UNION -- Einnahmen direkter gl Buchungen erfassen
930 ( - ac.amount) AS amount,
933 JOIN chart c ON (c.id = ac.chart_id)
934 JOIN gl a ON (a.id = ac.trans_id)
935 LEFT JOIN taxkeys tk ON (
937 SELECT id FROM taxkeys
938 WHERE chart_id=ac.chart_id
939 AND NOT $gltaxkey_where
940 AND startdate <= COALESCE(ac.transdate)
941 ORDER BY startdate DESC LIMIT 1
950 GROUP BY tk.pos_ustva
953 UNION -- Ausgaben direkter gl Buchungen erfassen
956 (ac.amount) AS amount,
959 JOIN chart c ON (c.id = ac.chart_id)
960 JOIN gl a ON (a.id = ac.trans_id)
961 LEFT JOIN taxkeys tk ON (
963 SELECT id FROM taxkeys
964 WHERE chart_id=ac.chart_id
966 AND startdate <= COALESCE(ac.transdate)
967 ORDER BY startdate DESC LIMIT 1
976 GROUP BY tk.pos_ustva
984 # Show all $query in Debuglevel LXDebug::QUERY
985 $callingdetails = (caller (0))[3];
986 $main::lxdebug->message(LXDebug::QUERY, "$callingdetails \$query=\n $query");
988 my $sth = $dbh->prepare($query);
990 $sth->execute || $form->dberror($query);
992 while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
994 $ref->{amount} *= -1;
995 if ($category eq "pos_bwa") {
997 $form->{ $ref->{$category} }{kumm} += $ref->{amount};
999 $form->{ $ref->{$category} }{jetzt} += $ref->{amount};
1002 $form->{ $ref->{$category} } += $ref->{amount};
1008 $main::lxdebug->leave_sub();
1013 $main::lxdebug->enter_sub();
1015 my ($self, $userpath, $filename) = @_;
1017 my $form = $main::form;
1019 if (!open(FACONF, "$userpath/$form->{login}_$filename")) {
1020 open(FANEW, ">$userpath/$form->{login}_$filename") ||
1021 $form->error("$userpath/$filename : $!");
1023 open(FACONF, "$userpath/$form->{login}_$filename") ||
1024 $form->error("$userpath/$form->{username}_$filename : $!");
1029 next if (/^(\#|\s)/);
1034 # remove any trailing whitespace
1035 s/^\s*(.*?)\s*$/$1/;
1036 my ($key, $value) = split(/=/, $_, 2);
1038 $form->{$key} = "$value";
1044 $main::lxdebug->leave_sub();