[freeside-commits] branch master updated. bc6770012b72baee61e86c54e959ac8ee234ff86

Mark Wells mark at 420.am
Mon Dec 14 17:04:55 PST 2015


The branch, master has been updated
       via  bc6770012b72baee61e86c54e959ac8ee234ff86 (commit)
      from  2748aaf4aa3f19e17a37edc07e89ee402108900d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bc6770012b72baee61e86c54e959ac8ee234ff86
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Dec 14 16:26:05 2015 -0800

    show refund reason on report and make it searchable, #39398

diff --git a/httemplate/search/cust_pay_pending.html b/httemplate/search/cust_pay_pending.html
index fe82268..8662d19 100755
--- a/httemplate/search/cust_pay_pending.html
+++ b/httemplate/search/cust_pay_pending.html
@@ -9,6 +9,7 @@
                 'addl_fields'   => [ sub { time2str('%r', shift->_date ) },
                                      $status_sub,
                                    ],
+                'addl_sort_fields' => [ 'status' ],
                 'redirect_empty' => $redirect_empty,
 &>
 <%init>
diff --git a/httemplate/search/cust_pay_void.html b/httemplate/search/cust_pay_void.html
index 5b24736..c639706 100755
--- a/httemplate/search/cust_pay_void.html
+++ b/httemplate/search/cust_pay_void.html
@@ -8,4 +8,5 @@
                 'addl_fields'   => [
                   sub { time2str('%b %d %Y', shift->void_date ) },
                 ],
+                'addl_sort_fields' => [ 'void_date' ],
 &>
diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html
index 1fea67c..ffc6afe 100755
--- a/httemplate/search/elements/cust_pay_or_refund.html
+++ b/httemplate/search/elements/cust_pay_or_refund.html
@@ -26,6 +26,7 @@ Examples:
                'html_init'      => '',
                'addl_header'    => [],
                'addl_fields'    => [],
+               'addl_sort_fields' => [],
                'redirect_empty' => $redirect_empty,
           )
 
@@ -80,6 +81,8 @@ die "access denied"
 
 my $table = $opt{'table'} || 'cust_'.$opt{'thing'};
 
+my $has_reason = dbdef->table($table)->column('reasonnum') ? 1 : 0;
+
 my $amount_field = $opt{'amount_field'};
 my $name_singular = $opt{'name_singular'};
 
@@ -217,6 +220,7 @@ unless ( $opt{'disable_by'} ) {
                       $o = 'customer self-service' if $o eq 'fs_selfservice';
                       $o;
                     };
+  push @sort_fields, '';
 }
 
 if ( $tax_names ) {
@@ -233,6 +237,7 @@ if ( $tax_names ) {
                                    split('\|', shift->tax_names)
                            );
                     };
+  push @sort_fields, '', '';
 }
 
 push @header, FS::UI::Web::cust_header();
@@ -242,11 +247,14 @@ push @links, map { $_ ne 'Cust. Status' ? $cust_link : '' }
 my @color = ( ( map '', @fields ), FS::UI::Web::cust_colors() );
 my @style = ( ( map '', @fields ), FS::UI::Web::cust_styles() );
 push @fields, \&FS::UI::Web::cust_fields;
+push @sort_fields, FS::UI::Web::cust_sort_fields;
 
 push @header, @{ $opt{'addl_header'} }
   if $opt{'addl_header'};
 push @fields, @{ $opt{'addl_fields'} }
   if $opt{'addl_fields'};
+push @sort_fields, @{ $opt{'addl_sort_fields'} }
+  if $opt{'addl_sort_fields'};
 
 my( $count_query, $sql_query, @count_addl );
 if ( $cgi->param('magic') ) {
@@ -432,6 +440,7 @@ if ( $cgi->param('magic') ) {
       push @search, "($table.auth LIKE '$1%') OR ($table.order_number LIKE '$1%')";
       push @fields, 'auth', 'order_number';
       push @header, 'Auth #', 'Transaction #';
+      push @sort_fields, '', '';
       $align .= 'rr';
 
     }
@@ -513,6 +522,18 @@ if ( $cgi->param('magic') ) {
   my $addl_from = FS::UI::Web::join_cust_main($table);
   my $group_by = '';
 
+  # reasons, for refunds and voided payments
+  if ( $has_reason ) {
+    push @select, "reason.reason";
+    $addl_from .= " LEFT JOIN reason USING (reasonnum)\n";
+    push @fields, 'reason';
+    push @sort_fields, 'reason.reason';
+    push @header, emt('Reason');
+    if ( $cgi->param('reasonnum') =~ /^(\d+)$/ ) {
+      push @search, "COALESCE(reasonnum, 0) = $1";
+    }
+  }
+
   if ( $cgi->param('tax_names') ) {
     if ( dbh->{Driver}->{Name} =~ /^Pg/i ) {
 
diff --git a/httemplate/search/elements/report_cust_pay_or_refund.html b/httemplate/search/elements/report_cust_pay_or_refund.html
index 70727c0..a25e696 100644
--- a/httemplate/search/elements/report_cust_pay_or_refund.html
+++ b/httemplate/search/elements/report_cust_pay_or_refund.html
@@ -23,7 +23,7 @@ Examples:
 
   <TR>
     <TH CLASS="background" COLSPAN=2 ALIGN="left">
-      <FONT SIZE="+1"><% mt('Payment search options') |h %></FONT>
+      <FONT SIZE="+1"><% mt('[_1] search options', ucfirst($name_singular)) |h %></FONT>
     </TH>
   </TR>
 
@@ -51,6 +51,20 @@ Examples:
 
   <& /elements/tr-select-user.html &>
 
+% if ( $has_reason ) {
+%   # limit to reasons that are in use for the table being reported on
+%   # (maybe order by count(*) desc?)
+  <& /elements/tr-select-table.html,
+    label       => emt('Reason'),
+    field       => 'reasonnum',
+    id          => 'reasonnum',
+    table       => 'reason',
+    name_col    => 'reason',
+    extra_sql   => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
+    empty_label => emt('any'),
+  &>
+% }
+
   <TR>
     <TD ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TD>
     <TD>
@@ -166,6 +180,8 @@ my $title = $void ? "Voided $name_singular report" :
             "\u$name_singular report" ;
 $table .= '_void' if $void;
 
+my $has_reason = dbdef->table($table)->column('reasonnum');
+
 tie (my %payby, 'Tie::IxHash',
   'CARD-VisaMC'    => 'credit card (Visa/MasterCard)',
   'CARD-Amex'      => 'credit card (American Express)',
diff --git a/httemplate/search/report_cust_refund.html b/httemplate/search/report_cust_refund.html
index fe84cf6..98b31a1 100644
--- a/httemplate/search/report_cust_refund.html
+++ b/httemplate/search/report_cust_refund.html
@@ -1,4 +1,5 @@
 <& elements/report_cust_pay_or_refund.html,
               'thing'          => 'refund',
               'name_singular'  => emt('refund'),
+              'reason_class'   => 'F',
 &>

-----------------------------------------------------------------------

Summary of changes:
 httemplate/search/cust_pay_pending.html            |    1 +
 httemplate/search/cust_pay_void.html               |    1 +
 httemplate/search/elements/cust_pay_or_refund.html |   21 ++++++++++++++++++++
 .../search/elements/report_cust_pay_or_refund.html |   18 ++++++++++++++++-
 httemplate/search/report_cust_refund.html          |    1 +
 5 files changed, 41 insertions(+), 1 deletion(-)




More information about the freeside-commits mailing list