$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') {
# mit entsprechender altersstrukturliste (s.a. Bug 1842)
# eine neue variable an der oberfläche eingeführt, somit ist
# todate == freier zeitrau und fordate == stichtag
+ # duedate_where == nur fällige rechnungen anzeigen
- my ($review_of_aging_list, $todate, $fromdate, $fromwhere, $fordate);
+ my ($review_of_aging_list, $todate, $fromdate, $fromwhere, $fordate,
+ $duedate_where);
- if ($form->{reporttype} eq 'custom') { # altersstrukturliste
+ if ($form->{reporttype} eq 'custom') { # altersstrukturliste, nur fällige
# explizit rausschmeissen was man für diesen bericht nicht braucht
delete $form->{fromdate};
$review_of_aging_list = " AND $form->{review_of_aging_list} < (date $fordate) - duedate";
}
}
- } else { # freier zeitraum OHNE review_of_aging_list
+ $duedate_where = " AND (date $fordate) - duedate >= 0 ";
+ } else { # freier zeitraum, nur rechnungsdatum und OHNE review_of_aging_list
$form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
$todate = conv_dateq($form->{todate});
$fromdate = conv_dateq($form->{fromdate});
"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))
AND (${ct}.id = ?)
AND (transdate <= (date $todate) $fromwhere )
$review_of_aging_list
+ $duedate_where
ORDER BY ctid, transdate, invnumber |;
my $sth_details = prepare_query($form, $dbh, $q_details);