$form->{"$item"} = 0;
}
+ $form->{coa} = coa_get($dbh);
+ $main::lxdebug->message(LXDebug::DEBUG2, "COA: $form->{coa}");
+
&get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate},
$form, $category);
+ ###########################################
+ #
+ # Nationspecific Modfications
+ #
+ ###########################################
+
+ # Germany
+
+ if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU'){
+
+ # 16%/19% Umstellung
+ # Umordnen der Kennziffern
+ if ( $form->{year} < 2007) {
+ $form->{35} += $form->{81};
+ $form->{36} += $form->{811};
+ $form->{95} += $form->{89};
+ $form->{98} += $form->{891};
+ map { delete $form->{$_} } qw(81 811 89 891);
+ } else {
+ $form->{35} += $form->{51};
+ $form->{36} += $form->{511};
+ $form->{95} += $form->{97};
+ $form->{98} += $form->{971};
+ map { delete $form->{$_} } qw(51 511 97 971);
+ }
- # 16%/19% Umstellung
- # Umordnen der Kennziffern
- if ( $form->{year} < 2007) {
- $form->{35} += $form->{81};
- $form->{36} += $form->{811};
- $form->{95} += $form->{89};
- $form->{98} += $form->{891};
- map { delete $form->{$_} } qw(81 811 89 891);
- } else {
- $form->{35} += $form->{51};
- $form->{36} += $form->{511};
- $form->{95} += $form->{97};
- $form->{98} += $form->{971};
- map { delete $form->{$_} } qw(51 511 97 971);
}
+ # Fixme: Wird auch noch für Oesterreich gebraucht,
+ # weil kein eigenes Ausgabeformular
+ # sotte aber aus der allgeméinen Steuerberechnung verschwinden
#
# Berechnung der USTVA Formularfelder laut Bogen 207
#
$main::lxdebug->leave_sub();
}
+sub coa_get {
+
+ my ($dbh) = @_;
+
+ my $query= qq|SELECT coa FROM defaults|;
+
+ my $sth = $dbh->prepare($query);
+
+ $sth->execute || $form->dberror($query);
+
+ ($ref) = $sth->fetchrow_array;
+
+ return $ref;
+
+};
+
sub get_accounts_ustva {
$main::lxdebug->enter_sub();
my $arwhere = "";
my $item;
+ my $gltaxkey_where = "(tk.pos_ustva>=59 AND tk.pos_ustva<=66)";
+
if ($fromdate) {
if ($form->{method} eq 'cash') {
$subwhere .= " AND transdate >= '$fromdate'";
$glwhere = " AND ac.transdate >= '$fromdate'";
- $ARwhere .= " AND acc.transdate >= '$fromdate'";
- $APwhere .= " AND AP.transdate >= '$fromdate'";
+ $ARwhere .= " AND acc.transdate >= '$fromdate'";
}
+ $APwhere .= " AND AP.transdate >= '$fromdate'";
$where .= " AND ac.transdate >= '$fromdate'";
}
if ($todate) {
$where .= " AND ac.transdate <= '$todate'";
$ARwhere .= " AND acc.transdate <= '$todate'";
- $subwhere .= " AND transdate <= '$todate'";
- $APwhere .= " AND AP.transdate <= '$todate'";
}
if ($department_id) {
SELECT id FROM taxkeys
WHERE chart_id = ac.chart_id
-- AND taxkey_id = ac.taxkey
- AND startdate <= COALESCE(ar.deliverydate, ar.transdate)
+ AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
ORDER BY startdate DESC LIMIT 1
)
)
tk.id = (
SELECT id FROM taxkeys
WHERE chart_id = ac.chart_id
- AND startdate <= COALESCE(ar.deliverydate, ar.transdate)
+ AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
ORDER BY startdate DESC LIMIT 1
)
)
sum(ac.amount) AS amount,
tk.pos_ustva
FROM acc_trans ac
- JOIN AP ON (AP.id = ac.trans_id )
+ JOIN ap ON (ap.id = ac.trans_id )
JOIN chart c ON (c.id = ac.chart_id)
LEFT JOIN taxkeys tk ON (
tk.id = (
SELECT id FROM taxkeys
WHERE chart_id=ac.chart_id
- --AND taxkey_id=ac.taxkey
+ AND taxkey_id = ac.taxkey
AND startdate <= COALESCE(AP.transdate)
ORDER BY startdate DESC LIMIT 1
)
)
WHERE
1=1
- $APwhere
+ $where
$dpt_where
$project
GROUP BY tk.pos_ustva
- UNION -- alle Ausgaben und Einnahmen direkter gl Buchungen erfassen
+ UNION -- Einnahmen direkter gl Buchungen erfassen
SELECT sum
( - ac.amount) AS amount,
tk.id = (
SELECT id FROM taxkeys
WHERE chart_id=ac.chart_id
- --AND taxkey_id=ac.taxkey
+ AND NOT $gltaxkey_where
AND startdate <= COALESCE(ac.transdate)
ORDER BY startdate DESC LIMIT 1
)
$dpt_from
$project
GROUP BY tk.pos_ustva
+
+
+ UNION -- Ausgaben direkter gl Buchungen erfassen
+
+ SELECT sum
+ (ac.amount) AS amount,
+ tk.pos_ustva
+ FROM acc_trans ac
+ JOIN chart c ON (c.id = ac.chart_id)
+ JOIN gl a ON (a.id = ac.trans_id)
+ LEFT JOIN taxkeys tk ON (
+ tk.id = (
+ SELECT id FROM taxkeys
+ WHERE chart_id=ac.chart_id
+ AND $gltaxkey_where
+ AND startdate <= COALESCE(ac.transdate)
+ ORDER BY startdate DESC LIMIT 1
+ )
+ )
+
+ $dpt_join
+ WHERE 1 = 1
+ $where
+ $dpt_from
+ $project
+ GROUP BY tk.pos_ustva
+
|;
my @accno;
}
+sub get_config {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $userpath, $filename) = @_;
+
+ my $form = $main::form;
+
+ if (!open(FACONF, "$userpath/$form->{login}_$filename")) {
+ open(FANEW, ">$userpath/$form->{login}_$filename") ||
+ $form->error("$userpath/$filename : $!");
+ close(FANEW);
+ open(FACONF, "$userpath/$form->{login}_$filename") ||
+ $form->error("$userpath/$form->{username}_$filename : $!");
+ }
+
+ while (<FACONF>) {
+ last if (/^\[/);
+ next if (/^(\#|\s)/);
+
+ # remove comments
+ s/\s#.*//g;
+
+ # remove any trailing whitespace
+ s/^\s*(.*?)\s*$/$1/;
+ my ($key, $value) = split(/=/, $_, 2);
+
+ $form->{$key} = "$value";
+
+ }
+
+ close(FACONF);
+
+ $main::lxdebug->leave_sub();
+}
1;