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);
35 my @tax_office_information = (
36 { 'id' => 8, 'name' => 'Baden-Württemberg', 'taxbird_nr' => '0', 'elster_format' => 'FF/BBB/UUUUP', },
37 { 'id' => 9, 'name' => 'Bayern', 'taxbird_nr' => '1', 'elster_format' => 'FFF/BBB/UUUUP', },
38 { 'id' => 11, 'name' => 'Berlin', 'taxbird_nr' => '2', 'elster_format' => 'FF/BBB/UUUUP', },
39 { 'id' => 12, 'name' => 'Brandenburg', 'taxbird_nr' => '3', 'elster_format' => 'FFF/BBB/UUUUP', },
40 { 'id' => 4, 'name' => 'Bremen', 'taxbird_nr' => '4', 'elster_format' => 'FF BBB UUUUP', },
41 { 'id' => 2, 'name' => 'Hamburg', 'taxbird_nr' => '5', 'elster_format' => 'FF/BBB/UUUUP', },
42 { 'id' => 6, 'name' => 'Hessen', 'taxbird_nr' => '6', 'elster_format' => '0FF BBB UUUUP', },
43 { 'id' => 13, 'name' => 'Mecklenburg-Vorpommern', 'taxbird_nr' => '7', 'elster_format' => 'FFF/BBB/UUUUP', },
44 { 'id' => 3, 'name' => 'Niedersachsen', 'taxbird_nr' => '8', 'elster_format' => 'FF/BBB/UUUUP', },
45 { 'id' => 5, 'name' => 'Nordrhein-Westfalen', 'taxbird_nr' => '9', 'elster_format' => 'FFF/BBBB/UUUP', },
46 { 'id' => 7, 'name' => 'Rheinland-Pfalz', 'taxbird_nr' => '10', 'elster_format' => 'FF/BBB/UUUU/P', },
47 { 'id' => 10, 'name' => 'Saarland', 'taxbird_nr' => '11', 'elster_format' => 'FFF/BBB/UUUUP', },
48 { 'id' => 14, 'name' => 'Sachsen', 'taxbird_nr' => '12', 'elster_format' => 'FFF/BBB/UUUUP', },
49 { 'id' => 15, 'name' => 'Sachsen-Anhalt', 'taxbird_nr' => '13', 'elster_format' => 'FFF/BBB/UUUUP', },
50 { 'id' => 1, 'name' => 'Schleswig-Holstein', 'taxbird_nr' => '14', 'elster_format' => 'FF BBB UUUUP', },
51 { 'id' => 16, 'name' => 'Thüringen', 'taxbird_nr' => '15', 'elster_format' => 'FFF/BBB/UUUUP', },
69 $self->{tax_office_information} = [];
71 foreach (@tax_office_information) {
73 $entry->{name} = $::locale->{iconv_utf8}->convert($entry->{name});
74 push @{ $self->{tax_office_information} }, $entry;
80 my ( $self, $form ) = @_;
82 my $coa = $::instance_conf->get_coa;
84 $form->{"COA_$coa"} = '1';
85 $form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
91 sub report_variables {
92 # Get all positions for taxreport out of the database
93 # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl
98 my $myconfig = $arg_ref->{myconfig};
99 my $form = $arg_ref->{form};
100 my $type = $arg_ref->{type}; # 'paied' || 'received' || ''
101 my $attribute = $arg_ref->{attribute}; #
102 my $dec_places = (defined $arg_ref->{dec_places}) ? $arg_ref->{dec_places}:undef;
104 my $where_type = $type ? "AND tax.report_headings.type = '$type'" : '';
105 my $where_dcp = defined $dec_places ? "AND tax.report_variables.dec_places = '$dec_places'" : '';
109 FROM tax.report_variables
110 LEFT JOIN tax.report_headings
111 ON (tax.report_variables.heading_id = tax.report_headings.id)
117 my $dbh = $form->dbconnect($myconfig);
118 my $sth = $dbh->prepare($query);
120 $sth->execute() || $form->dberror($query);
124 while ( my $row_ref = $sth->fetchrow_arrayref() ) {
125 push @positions, @$row_ref; # Copy the array contents
136 sub create_steuernummer {
137 $main::lxdebug->enter_sub();
139 my $form = $main::form;
143 my $part = $form->{part};
144 my $patterncount = $form->{patterncount};
145 my $delimiter = $form->{delimiter};
146 my $elster_pattern = $form->{elster_pattern};
148 # rebuild steuernummer and elstersteuernummer
149 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
150 # und die parts und delimiter
155 my $steuernummer_new = $part;
156 my $elstersteuernummer_new = $elster_FFFF;
157 $elstersteuernummer_new .= '0';
159 for ($h = 1; $h < $patterncount; $h++) {
160 $steuernummer_new .= qq|$delimiter|;
161 for ($i = 1; $i <= length($elster_pattern); $i++) {
162 $steuernummer_new .= $form->{"part_$h\_$i"};
163 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
166 if ($form->{steuernummer} ne $steuernummer_new) {
167 $form->{steuernummer} = $steuernummer_new;
168 $form->{elstersteuernummer} = $elstersteuernummer_new;
169 $form->{steuernummer_new} = $steuernummer_new;
171 $main::lxdebug->leave_sub();
172 return ($steuernummer_new, $elstersteuernummer_new);
175 sub steuernummer_input {
176 $main::lxdebug->enter_sub();
178 my ($self, $elsterland, $elsterFFFF, $steuernummer) = @_;
179 our ($elster_FFFF, $elster_land);
181 my $steuernummer_input = '';
183 $elster_land = $elsterland;
184 $elster_FFFF = $elsterFFFF;
185 $steuernummer = '0000000000' if ($steuernummer eq '');
187 # $steuernummer formatieren (nur Zahlen) -> $stnr
188 my $stnr = $steuernummer;
191 #Pattern description Elstersteuernummer
194 my $tax_office = first { $_->{name} eq $elster_land } @{ $self->{tax_office_information} };
195 my $elster_pattern = $tax_office->{elster_format};
196 my @elster_pattern = split(' ', $elster_pattern);
197 my $delimiter = ' ';
198 my $patterncount = @elster_pattern;
199 if ($patterncount < 2) {
200 @elster_pattern = ();
201 @elster_pattern = split('/', $elster_pattern);
203 $patterncount = @elster_pattern;
206 # no we have an array of patternparts and a delimiter
207 # create the first automated and fixed part and delimiter
209 $steuernummer_input .= qq|<b><font size="+1">|;
212 $elster_pattern[0] eq 'FFF' && do {
213 $part = substr($elster_FFFF, 1, 4);
214 $steuernummer_input .= qq|$part|;
217 $elster_pattern[0] eq '0FF' && do {
218 $part = '0' . substr($elster_FFFF, 2, 4);
219 $steuernummer_input .= qq|$part|;
222 $elster_pattern[0] eq 'FF' && do {
223 $part = substr($elster_FFFF, 2, 4);
224 $steuernummer_input .= qq|$part|;
228 $steuernummer_input .= qq|Fehler!|;
233 #now the rest of the Steuernummer ...
234 $steuernummer_input .= qq|</b></font>|;
235 $steuernummer_input .= qq|\n
236 <input type=hidden name="elster_pattern" value="$elster_pattern">
237 <input type=hidden name="patterncount" value="$patterncount">
238 <input type=hidden name="patternlength" value="$patterncount">
239 <input type=hidden name="delimiter" value="$delimiter">
240 <input type=hidden name="part" value="$part">
245 for (my $h = 1; $h < $patterncount; $h++) {
246 $steuernummer_input .= qq| $delimiter \n|;
247 for (my $i = 1; $i <= length($elster_pattern[$h]); $i++) {
248 $steuernummer_input .= qq|<select name="part_$h\_$i">\n|;
250 for (my $j = 0; $j <= 9; $j++) {
251 $steuernummer_input .= qq| <option value="$j"|;
252 if ($steuernummer ne '') {
253 if ($j eq substr($stnr, length($part) + $k, 1)) {
254 $steuernummer_input .= qq| selected|;
257 $steuernummer_input .= qq|>$j</option>\n|;
260 $steuernummer_input .= qq|</select>\n|;
264 $main::lxdebug->leave_sub();
266 return $steuernummer_input;
270 $main::lxdebug->enter_sub();
274 # Referenz wird übergeben, hash of hash wird nicht
275 # in neues Hash kopiert, sondern direkt über die Referenz verändert
276 # Prototyp für diese Konstruktion
278 my ($self, $land, $elsterFFFF, $elster_init) = @_;
281 my $FFFF = $elsterFFFF;
284 $checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
288 <script language="Javascript">
289 function update_auswahl()
291 var elsterBLAuswahl = document.verzeichnis.elsterland_new;
292 var elsterFAAuswahl = document.verzeichnis.elsterFFFF_new;
294 elsterFAAuswahl.options.length = 0; // dropdown aufräumen
297 foreach my $elster_land (sort keys %$elster_init) {
299 if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex].
300 value == "$elster_land")
304 %elster_land_fa = ();
306 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
307 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
309 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
310 keys(%elster_land_fa)
313 elsterFAAuswahl.options[$j] = new Option("$elster_land_fa{$ffff} ($ffff)","$ffff");|;
329 <select size="1" name="elsterland_new" onchange="update_auswahl()">|;
331 $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select federal state...') . qq|</option>\n|;
333 foreach my $elster_land (sort keys %$elster_init) {
335 <option value="$elster_land"|;
336 if ($elster_land eq $land and $checked eq '') {
337 $fa_auswahl .= qq| selected|;
339 $fa_auswahl .= qq|>$elster_land</option>
347 my $elster_land = '';
348 $elster_land = ($land ne '') ? $land : '';
349 %elster_land_fa = ();
350 for $FFFF (keys %{ $elster_init->{$elster_land} }) {
351 $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
359 <select size="1" name="elsterFFFF_new">|;
360 if ($elsterFFFF eq '') {
361 $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select tax office...') . qq|</option>|;
363 foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
364 keys(%elster_land_fa)
368 <option value="$ffff"|;
369 if ($ffff eq $elsterFFFF and $checked eq '') {
370 $fa_auswahl .= qq| selected|;
372 $fa_auswahl .= qq|>$elster_land_fa{$ffff} ($ffff)</option>|;
381 $main::lxdebug->leave_sub();
387 $main::lxdebug->enter_sub();
391 if ($ENV{HTTP_USER_AGENT}) {
394 print qq|<body><h2 class=info>Hinweis</h2>
400 <input type=button value="| . $main::locale->text('Back') . qq|" onClick="history.go(-1)">
408 die "Hinweis: $msg\n";
411 $main::lxdebug->leave_sub();
414 # 20.10.2009 sschoeling: this sub seems to be orphaned.
416 $main::lxdebug->enter_sub();
419 # soll mal eine Erinnerungsfunktion für USTVA Abgaben werden, die automatisch
420 # den Termin der nächsten USTVA anzeigt.
423 my ($today, $FA_dauerfrist, $FA_voranmeld) = @_;
428 $today =~ /(\d\d\d\d)(\d\d)(\d\d)/;
434 my $yymmdd = "$year$month$day" * 1;
435 my $mmdd = "$month$day" * 1;
439 #$ical = '...vcal format';
441 #if ($FA_voranmeld eq 'month'){
444 "0110" => 'December',
446 "0310" => 'February',
453 "1010" => 'September',
455 "1210" => 'November',
460 $month += 1 if ($day > 10);
461 $month = sprintf("%02d", $month);
462 $stichtag = $year . $month . "10";
463 my $ust_va = $month . "10";
465 foreach my $date (%liste) {
466 $ust_va = $liste{$date} if ($date eq $stichtag);
469 #} elsif ($FA_voranmeld eq 'quarter'){
474 #@stichtag = ('10.04.2004', '10.05.2004');
476 #@liste = ['0110', '0210', '0310', '0410', '0510', '0610', '0710', '0810', '0910',
477 # '1010', '1110', '1210', ];
479 #foreach $key (@liste){
480 # #if ($ddmm < ('0110' * 1));
482 # $stichtag = $liste[$key - 1] if ($ddmm > $key);
486 #$stichtag =~ /([\d]\d)(\d\d)$/
487 #$stichtag = "$1.$2.$yy"
489 our $description; # most probably not existent.
490 our $tage_bis; # most probably not existent.
491 our $ical; # most probably not existent.
493 $main::lxdebug->leave_sub();
494 return ($stichtag, $description, $tage_bis, $ical);
497 sub query_finanzamt {
498 $main::lxdebug->enter_sub();
500 my ($self, $myconfig, $form) = @_;
502 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
504 #Test, if table finanzamt exist
505 my $table = 'finanzamt';
506 my $filename = "sql/$table.sql";
508 my $tst = $dbh->prepare("SELECT * FROM $table");
509 $tst->execute || do {
510 #There is no table, read the table from sql/finanzamt.sql
511 print qq|<p>Bitte warten, Tabelle $table wird einmalig in Datenbank:
512 $myconfig->{dbname} als Benutzer: $myconfig->{dbuser} hinzugefügt...</p>|;
513 process_query($form, $dbh, $filename) || $self->error(DBI->errstr);
515 #execute second last call
516 my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
533 'FA_PLZ_Grosskunden', # 9
534 'FA_PLZ_Postfach', # 10
537 'FA_Kontonummer_1', # 13
538 'FA_Bankbezeichnung_1', # 14
539 #'FA_BankIBAN_1', # 15
540 #'FA_BankBIC_1', # 16
541 #'FA_BankInhaber_BUFA_Nr_1', # 17
543 'FA_Kontonummer_2', # 19
544 'FA_Bankbezeichnung_2', # 20
545 #'FA_BankIBAN_2', # 21
546 #'FA_BankBIC_2', # 22
547 #'FA_BankInhaber_BUFA_Nr_2', # 23
548 'FA_Oeffnungszeiten', # 24
551 #'FA_zustaendige_Hauptstelle_BUFA_Nr', # 27
552 #'FA_zustaendige_vorgesetzte_Finanzbehoerde' # 28
555 my $field = join(', ', @vars);
557 my $query = "SELECT $field FROM finanzamt ORDER BY FA_Land_nr";
558 my $sth = $dbh->prepare($query) or $self->error($dbh->errstr);
559 $sth->execute || $form->dberror($query);
560 my $array_ref = $sth->fetchall_arrayref();
563 foreach my $row (@$array_ref) {
564 my $FA_finanzamt = $row;
565 my $tax_office = first { $_->{id} == $FA_finanzamt->[0] } @{ $self->{tax_office_information} };
566 $land = $tax_office->{name};
568 # $land = $main::locale->{iconv}->convert($land);
570 my $ffff = @$FA_finanzamt[1];
573 $rec->{$land} = $ffff;
578 $finanzamt{$land}{$ffff} = [@$FA_finanzamt];
584 $main::lxdebug->leave_sub();
590 $main::lxdebug->enter_sub();
592 # Copyright D. Simander -> SL::Form under Gnu GPL.
593 my ($form, $dbh, $filename) = @_;
595 # return unless (-f $filename);
597 open my $FH, "<", "$filename" or $form->error("$filename : $!\n");
604 # Remove DOS and Unix style line endings.
607 # don't add comments or empty lines
608 next if /^(--.*|\s+)$/;
610 for (my $i = 0; $i < length($_); $i++) {
611 my $char = substr($_, $i, 1);
613 # Are we inside a string?
615 if ($char eq $quote_chars[-1]) {
621 if (($char eq "'") || ($char eq "\"")) {
622 push(@quote_chars, $char);
624 } elsif ($char eq ";") {
626 # Query is complete. Send it.
628 $sth = $dbh->prepare($query);
629 $sth->execute || $form->dberror($query);
643 $main::lxdebug->leave_sub();
647 $main::lxdebug->enter_sub();
649 my ($self, $myconfig, $form) = @_;
651 # connect to database
652 my $dbh = $form->get_standard_dbh;
655 my $category = "pos_ustva";
657 my @category_cent = USTVA->report_variables({
658 myconfig => $myconfig,
661 attribute => 'position',
665 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
667 my @category_euro = USTVA->report_variables({
668 myconfig => $myconfig,
671 attribute => 'position',
675 push @category_euro, USTVA->report_variables({
676 myconfig => $myconfig,
679 attribute => 'position',
683 $form->{decimalplaces} *= 1;
685 foreach my $item (@category_cent) {
686 $form->{"$item"} = 0;
688 foreach my $item (@category_euro) {
689 $form->{"$item"} = 0;
691 my $coa_name = $::instance_conf->get_coa;
692 $form->{coa} = $coa_name;
694 # Controlvariable for templates
695 $form->{"$coa_name"} = '1';
697 $main::lxdebug->message(LXDebug->DEBUG2(), "COA: '$form->{coa}', \$form->{$coa_name} = 1");
699 &get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate},
702 ###########################################
704 # Nationspecific Modfications
706 ###########################################
710 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU'){
713 # Umordnen der Kennziffern
714 if ( $form->{year} < 2007) {
715 $form->{35} += $form->{81};
716 $form->{36} += $form->{811};
717 $form->{95} += $form->{89};
718 $form->{98} += $form->{891};
719 map { delete $form->{$_} } qw(81 811 89 891);
721 $form->{35} += $form->{51};
722 $form->{36} += $form->{511};
723 $form->{95} += $form->{97};
724 $form->{98} += $form->{971};
725 map { delete $form->{$_} } qw(51 511 97 971);
731 # Fixme: Wird auch noch für Oesterreich gebraucht,
732 # weil kein eigenes Ausgabeformular
733 # sotte aber aus der allgeméinen Steuerberechnung verschwinden
735 # Berechnung der USTVA Formularfelder laut Bogen 207
738 $form->{"51r"} = $form->{"511"};
739 $form->{"86r"} = $form->{"861"};
740 $form->{"97r"} = $form->{"971"};
741 $form->{"93r"} = $form->{"931"};
743 $form->{"Z43"} = $form->{"511"} + $form->{"811"} + $form->{"861"}
744 + $form->{"36"} + $form->{"80"} + $form->{"971"}
745 + $form->{"891"} + $form->{"931"} + $form->{"96"}
748 $form->{"Z45"} = $form->{"Z43"};
750 $form->{"Z53"} = $form->{"Z45"} + $form->{"47"} + $form->{"53"} + $form->{"74"}
751 + $form->{"85"} + $form->{"65"};
753 $form->{"Z62"} = $form->{"Z53"} - $form->{"66"} - $form->{"61"}
754 - $form->{"62"} - $form->{"67"} - $form->{"63"}
755 - $form->{"64"} - $form->{"59"};
757 $form->{"Z65"} = $form->{"Z62"} - $form->{"69"};
758 $form->{"83"} = $form->{"Z65"} - $form->{"39"};
762 $main::lxdebug->leave_sub();
765 sub get_accounts_ustva {
766 $main::lxdebug->enter_sub();
768 my ($dbh, $last_period, $fromdate, $todate, $form, $category) = @_;
780 my $gltaxkey_where = "((tk.pos_ustva = 46) OR (tk.pos_ustva>=59 AND tk.pos_ustva<=67) or (tk.pos_ustva>=89 AND tk.pos_ustva<=93))";
783 if ($form->{method} eq 'cash') {
784 $subwhere .= " AND transdate >= '$fromdate'";
785 $glwhere = " AND ac.transdate >= '$fromdate'";
786 $ARwhere .= " AND acc.transdate >= '$fromdate'";
788 $APwhere .= " AND AP.transdate >= '$fromdate'";
789 $where .= " AND ac.transdate >= '$fromdate'";
793 $where .= " AND ac.transdate <= '$todate'";
794 $ARwhere .= " AND acc.transdate <= '$todate'";
797 my $acc_trans_where = '1=1';
798 if ($fromdate || $todate) {
799 $acc_trans_where = "ac.trans_id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE ";
802 $acc_trans_where .= "transdate >= '$fromdate'";
805 $acc_trans_where .= " AND " if ($fromdate);
806 $acc_trans_where .= "transdate <= '$todate'";
809 $acc_trans_where .= ")";
812 ############################################
813 # Method eq 'cash' = IST Versteuerung
814 ############################################
815 # Betrifft nur die eingenommene Umsatzsteuer
817 ############################################
819 if ($form->{method} eq 'cash') {
823 -- USTVA IST-Versteuerung
825 -- Alle tatsaechlichen _Zahlungseingaenge_
826 -- im Voranmeldezeitraum erfassen
827 -- (Teilzahlungen werden prozentual auf verschiedene Steuern aufgeteilt)
829 -- Bezahlt / Rechnungssumme
831 SELECT SUM(acc.amount)
833 INNER JOIN chart c ON (acc.chart_id = c.id
834 AND c.link like '%AR_paid%')
838 AND acc.trans_id = ac.trans_id
842 SELECT amount FROM ar WHERE id = ac.trans_id
847 LEFT JOIN chart c ON (c.id = ac.chart_id)
848 LEFT JOIN ar ON (ar.id = ac.trans_id)
849 LEFT JOIN taxkeys tk ON (
851 SELECT id FROM taxkeys
852 WHERE chart_id = ac.chart_id
853 -- AND taxkey_id = ac.taxkey
854 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
855 ORDER BY startdate DESC LIMIT 1
860 GROUP BY tk.pos_ustva
863 } elsif ($form->{method} eq 'accrual') {
864 #########################################
865 # Method eq 'accrual' = Soll Versteuerung
866 #########################################
869 -- Alle Einnahmen AR und pos_ustva erfassen
871 - sum(ac.amount) AS amount,
874 JOIN chart c ON (c.id = ac.chart_id)
875 JOIN ar ON (ar.id = ac.trans_id)
878 SELECT id FROM taxkeys
879 WHERE chart_id = ac.chart_id
880 AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
881 ORDER BY startdate DESC LIMIT 1
887 GROUP BY tk.pos_ustva
892 $form->error("Unknown tax method: $form->{method}")
896 #########################################
897 # Ausgaben und Gl Buchungen sind gleich
898 # für Ist- und Soll-Versteuerung
899 #########################################
901 UNION -- alle Ausgaben AP erfassen
904 sum(ac.amount) AS amount,
907 JOIN ap ON (ap.id = ac.trans_id )
908 JOIN chart c ON (c.id = ac.chart_id)
909 LEFT JOIN taxkeys tk ON (
911 SELECT id FROM taxkeys
913 AND chart_id=ac.chart_id
914 --AND taxkey_id = ac.taxkey
915 AND startdate <= COALESCE(AP.transdate)
916 ORDER BY startdate DESC LIMIT 1
922 GROUP BY tk.pos_ustva
924 UNION -- Einnahmen direkter gl Buchungen erfassen
927 ( - ac.amount) AS amount,
930 JOIN chart c ON (c.id = ac.chart_id)
931 JOIN gl a ON (a.id = ac.trans_id)
932 LEFT JOIN taxkeys tk ON (
934 SELECT id FROM taxkeys
935 WHERE chart_id=ac.chart_id
936 AND NOT $gltaxkey_where
937 AND startdate <= COALESCE(ac.transdate)
938 ORDER BY startdate DESC LIMIT 1
945 GROUP BY tk.pos_ustva
948 UNION -- Ausgaben direkter gl Buchungen erfassen
951 (ac.amount) AS amount,
954 JOIN chart c ON (c.id = ac.chart_id)
955 JOIN gl a ON (a.id = ac.trans_id)
956 LEFT JOIN taxkeys tk ON (
958 SELECT id FROM taxkeys
959 WHERE chart_id=ac.chart_id
961 AND startdate <= COALESCE(ac.transdate)
962 ORDER BY startdate DESC LIMIT 1
969 GROUP BY tk.pos_ustva
977 # Show all $query in Debuglevel LXDebug::QUERY
978 my $callingdetails = (caller (0))[3];
979 $main::lxdebug->message(LXDebug->QUERY(), "$callingdetails \$query=\n $query");
981 my $sth = $dbh->prepare($query);
983 $sth->execute || $form->dberror($query);
985 while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
987 $ref->{amount} *= -1;
988 $form->{ $ref->{$category} } += $ref->{amount};
993 $main::lxdebug->leave_sub();
998 $main::lxdebug->enter_sub();
1000 my ($self, $userspath, $filename) = @_;
1002 my $form = $main::form;
1004 $form->error("Missing Parameter: @_") if !$userspath || !$filename;
1006 $filename = "$::myconfig{login}_$filename";
1007 $filename =~ s|.*/||;
1008 $filename = "$userspath/$filename";
1009 open my $FACONF, "<", $filename or do {# Annon Sub
1011 # create file if file does not exist
1012 open my $FANEW, ">", $filename or $form->error("CREATE: $filename : $!");
1013 close $FANEW or $form->error("CLOSE: $filename : $!");
1015 #try again open file
1016 open my $FACONF, "<", $filename or $form->error("OPEN: $filename : $!");
1021 next if (/^(\#|\s)/);
1026 # remove any trailing whitespace
1027 s/^\s*(.*?)\s*$/$1/;
1028 my ($key, $value) = split(/=/, $_, 2);
1030 $form->{$key} = "$value";
1036 $main::lxdebug->leave_sub();