[freeside-commits] freeside/httemplate/search cust_bill.html, 1.19.2.1, 1.19.2.2 report_tax.cgi, 1.34.2.1, 1.34.2.2
Ivan,,,
ivan at wavetail.420.am
Mon Oct 29 03:30:59 PDT 2007
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail:/tmp/cvs-serv24030/httemplate/search
Modified Files:
Tag: FREESIDE_1_7_BRANCH
cust_bill.html report_tax.cgi
Log Message:
mysql has no DISTINCT ON either, sigh
Index: report_tax.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_tax.cgi,v
retrieving revision 1.34.2.1
retrieving revision 1.34.2.2
diff -u -d -r1.34.2.1 -r1.34.2.2
--- report_tax.cgi 22 May 2007 00:34:18 -0000 1.34.2.1
+++ report_tax.cgi 29 Oct 2007 10:30:57 -0000 1.34.2.2
@@ -444,7 +444,20 @@
foreach my $r (
qsearch( 'cust_main_county',
{},
- "DISTINCT ON ( country, state, county, CASE WHEN taxname IS NULL THEN '' ELSE taxname END ) *",
+ "DISTINCT
+ country,
+ state,
+ county,
+ CASE WHEN taxname IS NULL THEN '' ELSE taxname END AS taxname,".
+
+ #a little bit unsure of this part... test?
+ #ah, it looks like it winds up being irrelevant as ->{'tax'}
+ # from $regions is not displayed when show_taxclasses is on
+ ( $cgi->param('show_taxclasses')
+ ? " CASE WHEN taxclass IS NULL THEN '' ELSE taxclass END "
+ : " '' "
+ )." AS taxclass"
+ ,
$gotcust
)
) {
Index: cust_bill.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_bill.html,v
retrieving revision 1.19.2.1
retrieving revision 1.19.2.2
diff -u -d -r1.19.2.1 -r1.19.2.2
--- cust_bill.html 19 Sep 2007 00:12:08 -0000 1.19.2.1
+++ cust_bill.html 29 Oct 2007 10:30:57 -0000 1.19.2.2
@@ -59,7 +59,7 @@
my( $count_query, $sql_query );
my $count_addl = '';
-my $distinct = '';
+#my $distinct = '';
my($begin, $end) = ( '', '' );
my $agentnum = '';
my($open, $days) = ( '', '' );
@@ -141,18 +141,34 @@
push @where, "cust_bill._date < ". (time-86400*$days) if $days;
}
- #here is the agent virtualization
- push @where, $agentnums_sql;
- my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : '';
-
if ( $cgi->param('newest_percust') ) {
$newest_percust = 1;
- $distinct = 'DISTINCT ON ( cust_bill.custnum )';
- $orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC';
+
+ #$distinct = 'DISTINCT ON ( cust_bill.custnum )';
+ #$orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC';
#$count_query = "SELECT 'N/A', 'N/A', 'N/A'"; #XXXXXXX fix
+
+ my @newest_where = map { s/\bcust_bill\./newest_cust_bill./g; }
+ grep ! /^cust_main./, @where;
+ my $newest_where = scalar(@newest_where)
+ ? ' AND '. join(' AND ', @newest_where)
+ : '';
+
+ push @where, "cust_bill._date = (
+ SELECT(MAX(newest_cust_bill._date)) FROM cust_bill AS newest_cust_bill
+ WHERE newest_cust_bill.custnum = cust_bill.custnum
+ $newest_where
+ )";
+
+
$count_query = "SELECT COUNT(DISTINCT cust_bill.custnum), 'N/A', 'N/A'";
}
+ #here is the agent virtualization
+ push @where, $agentnums_sql;
+
+ my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : '';
+
unless ( $count_query ) {
$count_query = "SELECT COUNT(*), sum(charged), sum($owed)";
$count_addl = [ '$%.2f total invoiced',
@@ -165,7 +181,8 @@
'table' => 'cust_bill',
'addl_from' => $join_cust_main,
'hashref' => {},
- 'select' => "$distinct ". join(', ',
+ #'select' => "$distinct ". join(', ',
+ 'select' => join(', ',
'cust_bill.*',
#( map "cust_main.$_", qw(custnum last first company) ),
'cust_main.custnum as cust_main_custnum',
More information about the freeside-commits
mailing list