X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FCA.pm;h=0c2a24f3730156e523d947b4df7674d5352b08eb;hb=e7367fb51e706abc8c54495e1623a5e1d2aca7fa;hp=56036e7dea918251dbba8fd835cb5203e7cffff9;hpb=717d4a1334d916fc77ba09bc17e5999ada617b21;p=kivitendo-erp.git diff --git a/SL/CA.pm b/SL/CA.pm index 56036e7de..0c2a24f37 100644 --- a/SL/CA.pm +++ b/SL/CA.pm @@ -41,7 +41,7 @@ use SL::DBUtils; sub all_accounts { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $form) = @_; + my ($self, $myconfig, $form, $chart_id) = @_; my %amount; @@ -61,26 +61,45 @@ sub all_accounts { } $sth->finish; - $query = - qq!SELECT c.accno, c.id, c.description, c.charttype, c.category, ! . - qq! c.link, c.pos_bwa, c.pos_bilanz, c.pos_eur, c.valid_from, ! . - qq! c.datevautomatik, comma(tk.startdate) AS startdate, ! . - qq! comma(tk.taxkey_id) AS taxkey, ! . - qq! comma(tx.taxdescription || to_char (tx.rate, '99V99' ) || '%') ! . - qq! AS taxdescription, ! . - qq! comma(tx.taxnumber) AS taxaccount, comma(tk.pos_ustva) ! . - qq! AS tk_ustva, ! . - qq! ( SELECT accno FROM chart c2 WHERE c2.id = c.id ) AS new_account ! . - qq!FROM chart c ! . - qq!LEFT JOIN taxkeys tk ON (c.id = tk.chart_id) ! . - qq!LEFT JOIN tax tx ON (tk.tax_id = tx.id) ! . - qq!GROUP BY c.accno, c.id, c.description, c.charttype, ! . - qq! c.category, c.link, c.pos_bwa, c.pos_bilanz, c.pos_eur, ! . - qq! c.valid_from, c.datevautomatik ! . - qq!ORDER BY c.accno!; + my $where = "AND c.id = $chart_id" if ($chart_id ne ''); + + $query = qq{ + SELECT + c.accno, + c.id, + c.description, + c.charttype, + c.category, + c.link, + c.pos_bwa, + c.pos_bilanz, + c.pos_eur, + c.valid_from, + c.datevautomatik, + comma(tk.startdate) AS startdate, + comma(tk.taxkey_id) AS taxkey, + comma(tx.taxdescription || to_char (tx.rate, '99V99' ) || '%') AS taxdescription, + comma(tx.taxnumber) AS taxaccount, + comma(tk.pos_ustva) AS tk_ustva, + ( SELECT accno + FROM chart c2 + WHERE c2.id = c.id + ) AS new_account + FROM chart c + LEFT JOIN taxkeys tk ON (c.id = tk.chart_id) + LEFT JOIN tax tx ON (tk.tax_id = tx.id) + WHERE 1=1 + $where + GROUP BY c.accno, c.id, c.description, c.charttype, c.gifi_accno, + c.category, c.link, c.pos_bwa, c.pos_bilanz, c.pos_eur, c.valid_from, + c.datevautomatik + ORDER BY c.accno + }; + my $sth = prepare_execute_query($form, $dbh, $query); $form->{CA} = []; + while (my $ca = $sth->fetchrow_hashref(NAME_lc)) { $ca->{amount} = $amount{ $ca->{accno} }; if ($ca->{amount} < 0) {