selfservice-hide_invoices-pkgclass and add pkg_status to ClientAPI list_svcs, RT...
authorivan <ivan>
Tue, 8 Nov 2011 04:17:02 +0000 (04:17 +0000)
committerivan <ivan>
Tue, 8 Nov 2011 04:17:02 +0000 (04:17 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/Conf.pm

index 784a33f..0af2c3e 100644 (file)
@@ -1236,9 +1236,21 @@ sub list_invoices {
   my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
     or return { 'error' => "unknown custnum $custnum" };
 
-  my @cust_bill = $cust_main->cust_bill;
+  my $conf = new FS::Conf;
+
   my @legacy_cust_bill = $cust_main->legacy_cust_bill;
 
+  my @cust_bill = $cust_main->cust_bill;
+
+  my $hide_taxclass = $conf->config('selfservice-hide_invoices-taxclass');
+  if ( $hide_taxclass ) {
+    @cust_bill = grep { my @cust_bill_pkg = $_->cust_bill_pkg;
+                        my @part_pkg= grep $_, map $_->part_pkg, @cust_bill_pkg;
+                        grep { $_->taxclass ne $hide_taxclass } @part_pkg;
+                      }
+                   @cust_bill;
+  }
+
   my $balance = 0;
 
   return  { 'error'       => '',
@@ -1434,13 +1446,15 @@ sub list_svcs {
             my $svc_x = $_->svc_x;
             my($label, $value) = $_->label;
             my $svcdb = $_->part_svc->svcdb;
-            my $part_pkg = $_->cust_pkg->part_pkg;
+            my $cust_pkg = $_->cust_pkg;
+            my $part_pkg = $cust_pkg->part_pkg;
 
             my %hash = (
-              'svcnum' => $_->svcnum,
-              'svcdb'  => $svcdb,
-              'label'  => $label,
-              'value'  => $value,
+              'svcnum'     => $_->svcnum,
+              'svcdb'      => $svcdb,
+              'label'      => $label,
+              'value'      => $value,
+              'pkg_status' => $cust_pkg->status,
             );
 
             if ( $svcdb eq 'svc_acct' ) {
index dd3af2d..4104fda 100644 (file)
@@ -2485,6 +2485,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'selfservice-hide_invoices-taxclass',
+    'section'     => 'self-service',
+    'description' => 'Hide invoices with only this package tax class from self-service.  Typically set to something like "Previous balance" and used when importing legacy invoices into legacy_cust_bill.',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'selfservice-recent-did-age',
     'section'     => 'self-service',
     'description' => 'If specified, defines "recent", in number of seconds, for "Download recently allocated DIDs" in self-service.',