X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FRP.pm;h=c4a95039b3ff591991e447e2f172b1302e0ac877;hb=73a58f3dceeb378343ceb151942828eea686b75a;hp=1afd180e396c033afbb0ac28484e810bbb658432;hpb=a7041228dd1face28a082f5f747c02468ed0bb5a;p=kivitendo-erp.git diff --git a/SL/RP.pm b/SL/RP.pm index 1afd180e3..c4a95039b 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -211,13 +211,25 @@ sub get_accounts { $sth->finish; + # filter for opening and closing bookings # if l_ob is selected l_cb is always ignored - if ( $form->{l_ob} ) { - $where .= ' AND ac.ob_transaction is true ' - } elsif ( not $form->{l_cb} ) { - $where .= ' AND ac.cb_transaction is false '; + if ( $last_period ) { + # ob/cb-settings for "compared to" balance + if ( $form->{l_ob_compared} ) { + $where .= ' AND ac.ob_transaction is true ' + } elsif ( not $form->{l_cb_compared} ) { + $where .= ' AND ac.cb_transaction is false '; + }; + } else { + # ob/cb-settings for "as of" balance + if ( $form->{l_ob} ) { + $where .= ' AND ac.ob_transaction is true ' + } elsif ( not $form->{l_cb} ) { + $where .= ' AND ac.cb_transaction is false '; + }; }; + if ($fromdate) { $fromdate = conv_dateq($fromdate); if ($form->{method} eq 'cash') { @@ -519,13 +531,6 @@ sub get_accounts_g { FROM acc_trans ac LEFT JOIN chart c ON (c.id = ac.chart_id) LEFT JOIN ar ON (ar.id = ac.trans_id) - LEFT JOIN taxkeys tk ON (tk.id = ( - SELECT id FROM taxkeys - WHERE chart_id = ac.chart_id - AND startdate <= COALESCE(ar.deliverydate,ar.transdate) - ORDER BY startdate DESC LIMIT 1 - ) - ) WHERE ac.trans_id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE 1=1 $subwhere) GROUP BY c.$category @@ -1226,7 +1231,7 @@ sub aging { "duedate", invoice, ${arap}.id, date_part('days', now() - duedate) as overduedays, (SELECT $buysell FROM exchangerate - WHERE (${arap}.curr = exchangerate.curr) + WHERE (${arap}.currency_id = exchangerate.currency_id) AND (exchangerate.transdate = ${arap}.transdate)) AS exchangerate FROM ${arap}, ${ct} WHERE ((paid != amount) OR (datepaid > (date $todate) AND datepaid is not null))