[freeside-commits] branch master updated. 09589754a8926ef064ea1d3d474a0fc3a8590101

Jonathan Prykop jonathan at 420.am
Sun May 31 16:18:07 PDT 2015


The branch, master has been updated
       via  09589754a8926ef064ea1d3d474a0fc3a8590101 (commit)
      from  817c1ce0e1cbcfd1f684222c66f46dd13b2d6dd7 (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 09589754a8926ef064ea1d3d474a0fc3a8590101
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Sun May 31 18:17:28 2015 -0500

    RT#17828: Additional invoice fields on invoice view in selfservice portal

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index c57584e..fa2b6ba 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -473,11 +473,13 @@ sub customer_info {
     if ( $session->{'pkgnum'} ) {
       #XXX open invoices in the pkg-balances case
     } else {
+      $return{'money_char'} = $conf->config("money_char") || '$';
       my @open = map {
                        {
-                         invnum => $_->invnum,
-                         date   => time2str("%b %o, %Y", $_->_date),
-                         owed   => $_->owed,
+                         invnum     => $_->invnum,
+                         date       => time2str("%b %o, %Y", $_->_date),
+                         owed       => $_->owed,
+                         charged    => $_->charged,
                        };
                      } $cust_main->open_cust_bill;
       $return{open_invoices} = \@open;
@@ -1589,25 +1591,31 @@ sub list_invoices {
   my @cust_bill = grep ! $_->hide, $cust_main->cust_bill;
 
   my $balance = 0;
+  my $invoices = [
+    map {
+      #not super efficient, we also run cust_bill_pay/cust_credited inside owed
+      my @payments_and_credits = sort {$b->_date <=> $a->_date} ($_->cust_bill_pay,$_->cust_credited);
+      my $owed = $_->owed;
+      $balance += $owed;
+      +{ 'invnum'       => $_->invnum,
+         '_date'        => $_->_date,
+         'date'         => time2str("%b %o, %Y", $_->_date),
+         'date_short'   => time2str("%m-%d-%Y",  $_->_date),
+         'previous'     => sprintf('%.2f', ($_->previous)[0]),
+         'charged'      => sprintf('%.2f', $_->charged),
+         'owed'         => sprintf('%.2f', $owed),
+         'balance'      => sprintf('%.2f', $balance),
+         'lastpay'      => @payments_and_credits 
+                           ? time2str("%b %o, %Y", $payments_and_credits[0]->_date)
+                           : '',
+      }
+    } @cust_bill
+  ];
 
   return  { 'error'       => '',
             'balance'     => $cust_main->balance,
-            'invoices'    => [
-              map {
-                    my $owed = $_->owed;
-                    $balance += $owed;
-                    +{ 'invnum'       => $_->invnum,
-                       '_date'        => $_->_date,
-                       'date'         => time2str("%b %o, %Y", $_->_date),
-                       'date_short'   => time2str("%m-%d-%Y",  $_->_date),
-                       'previous'     => sprintf('%.2f', ($_->previous)[0]),
-                       'charged'      => sprintf('%.2f', $_->charged),
-                       'owed'         => sprintf('%.2f', $owed),
-                       'balance'      => sprintf('%.2f', $balance),
-                     }
-                  }
-                  @cust_bill
-            ],
+            'money_char'  => $conf->config("money_char") || '$',
+            'invoices'    => $invoices,
             'legacy_invoices' => [
               map {
                     +{ 'legacyinvnum' => $_->legacyinvnum,
diff --git a/fs_selfservice/FS-SelfService/cgi/invoices.html b/fs_selfservice/FS-SelfService/cgi/invoices.html
index 7528051..ffc44ec 100644
--- a/fs_selfservice/FS-SelfService/cgi/invoices.html
+++ b/fs_selfservice/FS-SelfService/cgi/invoices.html
@@ -3,24 +3,34 @@
 
 <%=
   if ( @invoices ) {
-    $OUT .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
-            '<TR><TH BGCOLOR="#ff6666" COLSPAN=4>All Invoices</TH></TR>';
-    my $col1 = "ffffff";
-    my $col2 = "dddddd";
+    my $th  = q!<TH STYLE="background: #ff9999; text-align: left; padding: .1em .5em;">!;
+    my $thr = q!<TH STYLE="background: #ff9999; text-align: right; padding: .1em .5em;">!;
+    $OUT .= '<TABLE STYLE="border: 0;" CELLSPACING="0">'.
+            '<TR>'.$th.'Invoice #</TH>'.$th.'Date</TH>'.$thr.'Charges</TH>'
+            .$th.'Date Paid</TH>'.$thr.'Owed</TH></TR>';
+    my $col1 = "#ffffff";
+    my $col2 = "#dddddd";
     my $col = $col1;
 
     foreach my $invoice ( @invoices ) {
-      my $td = qq!<TD BGCOLOR="#$col">!;
+      my $td  = qq!<TD STYLE="background: $col; padding: .1em .5em;">!;
+      my $tdr = qq!<TD STYLE="background: $col; padding: .1em .5em; text-align: right;">!;
       my $a=qq!<A HREF="${url}view_invoice;invnum=!. $invoice->{'invnum'}. '">';
       $OUT .=
-        "<TR>$td${a}Invoice #". $invoice->{'invnum'}. "</A></TD>$td </TD>".
-        "$td$a". $invoice->{'date'}. "</A></TD>$td</TD>".
+        "<TR>".
+        $td . $a . $invoice->{'invnum'}. "</A></TD>" .
+        $td . $a . $invoice->{'date'} . "</A></TD>" .
+        $tdr . $a . $money_char . $invoice->{'charged'} . "</A></TD>" .
+        $td . $a . $invoice->{'lastpay'} . "</A></TD>" .
+        $tdr . $a . $money_char . $invoice->{'owed'} . "</A></TD>" .
         '</TR>';
       $col = $col eq $col1 ? $col2 : $col1;
     }
+    my $tht = '<TH COLSPAN="4" STYLE="background: #ff9999; padding: .1em .5em; text-align: right;">';
+    $OUT .= '<TR>'.$tht.'BALANCE DUE</TH>'.$tht.$money_char.$balance.'</TH></TR>';
     $OUT .= '</TABLE><BR>';
   } else {
-    $OUT .= 'You have no invoices.<BR><BR>';
+    $OUT .= '<P>You have no invoices.</P>';
   }
 %>
 
diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html
index 66e2c69..309021a 100644
--- a/fs_selfservice/FS-SelfService/cgi/myaccount.html
+++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html
@@ -28,28 +28,34 @@ Hello <%= $name %>!<BR><BR>
 } %>
 <%=
   if ( @open_invoices ) {
-    $OUT .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
-            '<TR><TH BGCOLOR="#ff6666" COLSPAN=5>Open Invoices</TH></TR>';
-    my $link = qq!<A HREF="<%= $url %>myaccount!;
-    my $col1 = $stripe1_bgcolor || '#ffffff';
-    my $col2 = $stripe2_bgcolor || '#dddddd';
+    my $th  = q!<TH STYLE="background: #ff9999; text-align: left; padding: .1em .5em;">!;
+    my $thr = q!<TH STYLE="background: #ff9999; text-align: right; padding: .1em .5em;">!;
+    $OUT .= '<TABLE STYLE="border: 0;" CELLSPACING="0">'.
+            '<TR><TH BGCOLOR="#ff6666" COLSPAN="4">Open Invoices</TH></TR>'.
+            '<TR>'.$th.'Invoice #</TH>'.$th.'Date</TH>'.$thr.'Charges</TH>'
+            .$thr.'Owed</TH></TR>';
+    my $col1 = "#ffffff";
+    my $col2 = "#dddddd";
     my $col = $col1;
 
     foreach my $invoice ( @open_invoices ) {
-      my $td = qq!<TD BGCOLOR="$col">!;
+      my $td  = qq!<TD STYLE="background: $col; padding: .1em .5em;">!;
+      my $tdr = qq!<TD STYLE="background: $col; padding: .1em .5em; text-align: right;">!;
       my $a=qq!<A HREF="${url}view_invoice;invnum=!. $invoice->{'invnum'}. '">';
       $OUT .=
-        "<TR>$td${a}Invoice #". $invoice->{'invnum'}. "</A></TD>$td</TD>".
-        "$td$a". $invoice->{'date'}. "</A></TD>$td</TD>".
-        qq!<TD BGCOLOR="$col" ALIGN="right">$a\$!. $invoice->{'owed'}.
-          '</A></TD>'.
+        "<TR>".
+        $td . $a . $invoice->{'invnum'}. "</A></TD>" .
+        $td . $a . $invoice->{'date'} . "</A></TD>" .
+        $tdr . $a . $money_char . $invoice->{'charged'} . "</A></TD>" .
+        $tdr . $a . $money_char . $invoice->{'owed'} . "</A></TD>" .
         '</TR>';
       $col = $col eq $col1 ? $col2 : $col1;
     }
     $OUT .= '</TABLE><BR>';
   } else {
-    $OUT .= 'You have no outstanding invoices.<BR><BR>';
+    $OUT .= '<P>You have no outstanding invoices.</P>';
   }
+
 %>
 
 <%=

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                     |   46 +++++++++++++---------
 fs_selfservice/FS-SelfService/cgi/invoices.html  |   26 ++++++++----
 fs_selfservice/FS-SelfService/cgi/myaccount.html |   28 +++++++------
 3 files changed, 62 insertions(+), 38 deletions(-)




More information about the freeside-commits mailing list