[freeside-commits] freeside/httemplate/search/elements cust_pay_or_refund.html, 1.11, 1.12 report_cust_pay_or_refund.html, 1.2, 1.3
Mark Wells
mark at wavetail.420.am
Tue Sep 21 17:08:32 PDT 2010
Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv461/search/elements
Modified Files:
cust_pay_or_refund.html report_cust_pay_or_refund.html
Log Message:
unapplied payment/refund/credit reports, RT#7503
Index: report_cust_pay_or_refund.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/report_cust_pay_or_refund.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- report_cust_pay_or_refund.html 31 Aug 2010 17:40:05 -0000 1.2
+++ report_cust_pay_or_refund.html 22 Sep 2010 00:08:30 -0000 1.3
@@ -17,6 +17,7 @@
<FORM ACTION="<% $table %>.html" METHOD="GET">
<INPUT TYPE="hidden" NAME="magic" VALUE="_date">
+<INPUT TYPE="hidden" NAME="unapplied" VALUE="<% $unapplied %>">
<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
@@ -138,8 +139,11 @@
unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
my $void = $cgi->param('void') ? 1 : 0;
+my $unapplied = $cgi->param('unapplied') ? 1 : 0;
-my $title = $void ? "Voided $name_singular report" : "\u$name_singular report";
+my $title = $void ? "Voided $name_singular report" :
+ $unapplied ? "Unapplied $name_singular report" :
+ "\u$name_singular report" ;
$table .= '_void' if $void;
</%init>
Index: cust_pay_or_refund.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/cust_pay_or_refund.html,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -d -r1.11 -r1.12
--- cust_pay_or_refund.html 31 Aug 2010 17:40:05 -0000 1.11
+++ cust_pay_or_refund.html 22 Sep 2010 00:08:30 -0000 1.12
@@ -44,7 +44,7 @@
'name_singular' => $name_singular,
'query' => $sql_query,
'count_query' => $count_query,
- 'count_addl' => [ '$%.2f total '.$opt{name_verb}, ],
+ 'count_addl' => \@count_addl,
'redirect_empty' => $opt{'redirect_empty'},
'header' => \@header,
'fields' => \@fields,
@@ -68,7 +68,10 @@
my $amount_field = $opt{'amount_field'};
my $name_singular = $opt{'name_singular'};
-my $title = "\u$name_singular Search Results";
+my $unapplied = $cgi->param('unapplied');
+my $title = '';
+$title = 'Unapplied ' if $unapplied;
+$title .= "\u$name_singular Search Results";
my $link = '';
if ( ( $curuser->access_right('View invoices') #XXX for now
@@ -143,15 +146,25 @@
push @header, "\u$name_singular",
'Amount',
- 'Date',
;
-$align .= 'rrr';
-push @links, '', '', '';
+$align .= 'rr';
+push @links, '', '';
push @fields, 'payby_payinfo_pretty',
sub { sprintf('$%.2f', shift->$amount_field() ) },
- sub { time2str('%b %d %Y', shift->_date ) },
;
+if ( $unapplied ) {
+ push @header, 'Unapplied';
+ $align .= 'r';
+ push @links, '';
+ push @fields, sub { sprintf('$%.2f', shift->unapplied_amount) };
+}
+
+push @header, 'Date';
+$align .= 'r';
+push @links, '';
+push @fields, sub { time2str('%b %d %Y', shift->_date ) };
+
unless ( $opt{'disable_by'} ) {
push @header, 'By';
$align .= 'c';
@@ -192,10 +205,17 @@
push @fields, @{ $opt{'addl_fields'} }
if $opt{'addl_fields'};
-my( $count_query, $sql_query );
+my( $count_query, $sql_query, @count_addl );
if ( $cgi->param('magic') ) {
my @search = ();
+ my @select = (
+ "$table.*",
+ FS::UI::Web::cust_sql_fields(),
+ 'cust_main.custnum AS cust_main_custnum',
+ );
+ push @select, $tax_names if $tax_names;
+
my $orderby;
if ( $cgi->param('magic') eq '_date' ) {
@@ -328,6 +348,13 @@
die "unknown search magic: ". $cgi->param('magic');
}
+ #unapplied payment/refund
+ if ( $unapplied ) {
+ push @select, '(' . "FS::$table"->unapplied_sql . ') AS unapplied_amount';
+ push @search, "FS::$table"->unapplied_sql . ' > 0';
+
+ }
+
#for the history search
if ( $cgi->param('history_action') =~ /^([\w,]+)$/ ) {
my @history_action = split(/,/, $1);
@@ -374,18 +401,18 @@
my $search = ' WHERE '. join(' AND ', @search);
- $count_query = "SELECT COUNT(*), SUM($amount_field) ".
- "FROM $table $addl_from".
+ $count_query = "SELECT COUNT(*), SUM($amount_field) ";
+ $count_query .= ', SUM(' . "FS::$table"->unapplied_sql . ') '
+ if $unapplied;
+ $count_query .= "FROM $table $addl_from".
"$search $group_by";
+ @count_addl = ( '$%.2f total '.$opt{name_verb} );
+ push @count_addl, '$%.2f unapplied' if $unapplied;
+
$sql_query = {
'table' => $table,
- 'select' => join(', ',
- "$table.*",
- ( $tax_names ? $tax_names : () ),
- 'cust_main.custnum as cust_main_custnum',
- FS::UI::Web::cust_sql_fields(),
- ),
+ 'select' => join(', ', @select),
'hashref' => {},
'extra_sql' => "$search $group_by ORDER BY $orderby",
'addl_from' => $addl_from,
@@ -404,6 +431,7 @@
$count_query = "SELECT COUNT(*), SUM($amount_field) FROM $table".
" WHERE payinfo = '$payinfo' AND payby = '$payby'".
" AND ". $curuser->agentnums_sql;
+ @count_addl = ( '$%.2f total '.$opt{name_verb} );
$sql_query = {
'table' => $table,
@@ -415,4 +443,7 @@
}
+# for consistency
+$title = join('',map {ucfirst} split(/\b/,$title));
+
</%init>
More information about the freeside-commits
mailing list