X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FRP.pm;h=80e83d56912249e66349a235015d6e5a38672a4b;hb=844a541e0d8f59644540413f675e8f07cd154cf6;hp=a41c2a8f68827c36e6d4478416472edea758ac43;hpb=cf0a808e57c47f92c7ad05c4f45d0310d502db85;p=kivitendo-erp.git diff --git a/SL/RP.pm b/SL/RP.pm index a41c2a8f6..80e83d569 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -832,14 +832,16 @@ sub trial_balance { if ($form->{fromdate} || $form->{todate}) { if ($form->{fromdate}) { $fromdate = conv_dateq($form->{fromdate}); + my $fiscal_year_startdate = conv_dateq($self->get_balance_starting_date($form->{fromdate})); + # my $date_trunc = "(select date_trunc('year', date $fromdate))"; $tofrom .= " AND (ac.transdate >= $fromdate)"; $subwhere .= " AND (ac.transdate >= $fromdate)"; - $sumsubwhere .= " AND (ac.transdate >= (select date_trunc('year', date $fromdate))) "; - $saldosubwhere .= " AND (ac.transdate >= (select date_trunc('year', date $fromdate))) "; + $sumsubwhere .= " AND (ac.transdate >= $fiscal_year_startdate) "; + $saldosubwhere .= " AND (ac.transdate >= $fiscal_year_startdate) "; $invwhere .= " AND (a.transdate >= $fromdate)"; - $glsaldowhere .= " AND (ac.transdate >= (select date_trunc('year', date $fromdate))) "; + $glsaldowhere .= " AND (ac.transdate >= $fiscal_year_startdate) "; $glwhere = " AND (ac.transdate >= $fromdate)"; - $glsumwhere = " AND (ac.transdate >= (select date_trunc('year', date $fromdate))) "; + $glsumwhere = " AND (ac.transdate >= $fiscal_year_startdate) "; } if ($form->{todate}) { $todate = conv_dateq($form->{todate}); @@ -1296,7 +1298,7 @@ sub aging { phone as customerphone, fax as customerfax, ${ct}number, "invnumber", "transdate", (amount - COALESCE((SELECT sum(amount)*$ml FROM acc_trans WHERE chart_link ilike '%paid%' AND acc_trans.trans_id=${arap}.id AND acc_trans.transdate <= (date $todate)),0)) as "open", "amount", - "duedate", invoice, ${arap}.id, date_part('days', now() - duedate) as overduedays, + "duedate", invoice, ${arap}.id, date_part('days', now() - duedate) as overduedays, datepaid, (amount - paid) as current_open, (SELECT $buysell FROM exchangerate WHERE (${arap}.currency_id = exchangerate.currency_id)