From df195cb3693e22891c8b36cc9cd913740ee68f6e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 8 Nov 2011 04:17:09 +0000 Subject: [PATCH] selfservice-hide_invoices-pkgclass and add pkg_status to ClientAPI list_svcs, RT#13656 --- FS/FS/ClientAPI/MyAccount.pm | 26 ++++++++++++++++++++------ FS/FS/Conf.pm | 7 +++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 784a33f61..0af2c3e19 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -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' ) { diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index dd3af2dc1..4104fda9c 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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.', -- 2.11.0