summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-04-10 17:48:51 -0700
committerMark Wells <mark@freeside.biz>2012-04-10 17:48:51 -0700
commit89896731e5226f366b4ceed798e68b98141290f7 (patch)
treefbdec56631bd04b283648d87a5cb19ca93fb7473
parent1c56391de209e817c5f922b90a1673bf616d48fa (diff)
add special format for display_custnum prefix, #16815
-rw-r--r--FS/FS/Conf.pm9
-rw-r--r--FS/FS/cust_main.pm17
2 files changed, 24 insertions, 2 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 67e2a7267..a048a1855 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3888,6 +3888,15 @@ and customer address. Include units.',
},
{
+ 'key' => 'cust_main-custnum-display_special',
+ 'section' => 'UI',
+ 'description' => 'Use this customer number prefix format',
+ 'type' => 'select',
+ 'select_hash' => [ '' => '',
+ 'CoStCl' => 'CoStCl (country, state, class name)' ],
+ },
+
+ {
'key' => 'cust_main-custnum-display_length',
'section' => 'UI',
'description' => 'Zero fill the customer number to this many digits for display purposes.',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index d45af5848..997574288 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -3911,12 +3911,25 @@ cust_main-default_agent_custid is set and it has a value, custnum otherwise.
sub display_custnum {
my $self = shift;
+
+ my $prefix = $conf->config('cust_main-custnum-display_prefix') || '';
+ if ( my $special = $conf->config('cust_main-custnum-display_special') ) {
+ if ( $special eq 'CoStCl' ) {
+ $prefix = uc( join('',
+ $self->country,
+ ($self->state =~ /^(..)/),
+ ($self->classnum ? $self->cust_class->classname =~ /^(..)/ : '__')
+ ) );
+ }
+ # add any others here if needed
+ }
+
my $length = $conf->config('cust_main-custnum-display_length');
if ( $conf->exists('cust_main-default_agent_custid') && $self->agent_custid ){
return $self->agent_custid;
- } elsif ( $conf->config('cust_main-custnum-display_prefix') ) {
+ } elsif ( $prefix ) {
$length = 8 if !defined($length);
- return $conf->config('cust_main-custnum-display_prefix').
+ return $prefix .
sprintf('%0'.$length.'d', $self->custnum)
} elsif ( $length ) {
return sprintf('%0'.$length.'d', $self->custnum);