[freeside-commits] freeside/FS/FS Conf.pm, 1.245, 1.246 cust_main.pm, 1.374, 1.375
Ivan,,,
ivan at wavetail.420.am
Thu Oct 9 18:15:51 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv11362/FS/FS
Modified Files:
Conf.pm cust_main.pm
Log Message:
add options to auto-generate agent_custid and display it as the customer number, RT#4099
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -d -r1.245 -r1.246
--- Conf.pm 30 Sep 2008 20:22:38 -0000 1.245
+++ Conf.pm 10 Oct 2008 01:15:48 -0000 1.246
@@ -2423,6 +2423,23 @@
},
{
+ 'key' => 'cust_main-default_agent_custid',
+ 'section' => 'UI',
+ 'description' => 'Display the agent_custid field instead of the custnum field.',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'cust_main-auto_agent_custid',
+ 'section' => 'UI',
+ 'description' => 'Automatically assign an agent_custid - select format',
+ 'type' => 'select',
+ 'select_hash' => [ '' => 'No',
+ '1YMMXXXXXXXX' => '1YMMXXXXXXXX',
+ ],
+ },
+
+ {
'key' => 'cust_main-default_areacode',
'section' => 'UI',
'description' => 'Default area code for customers.',
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.374
retrieving revision 1.375
diff -u -d -r1.374 -r1.375
--- cust_main.pm 30 Sep 2008 20:22:38 -0000 1.374
+++ cust_main.pm 10 Oct 2008 01:15:49 -0000 1.375
@@ -343,6 +343,9 @@
$self->signupdate(time) unless $self->signupdate;
+ $self->auto_agent_custid()
+ if $conf->config('cust_main-auto_agent_custid') && ! $self->agent_custid;
+
my $error = $self->SUPER::insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
@@ -419,6 +422,35 @@
}
+use File::CounterFile;
+sub auto_agent_custid {
+ my $self = shift;
+
+ my $format = $conf->config('cust_main-auto_agent_custid');
+ my $agent_custid;
+ if ( $format eq '1YMMXXXXXXXX' ) {
+
+ my $counter = new File::CounterFile 'cust_main.agent_custid';
+ $counter->lock;
+
+ my $ym = 100000000000 + time2str('%y%m00000000', time);
+ if ( $ym > $counter->value ) {
+ $counter->{'value'} = $agent_custid = $ym;
+ $counter->{'updated'} = 1;
+ } else {
+ $agent_custid = $counter->inc;
+ }
+
+ $counter->unlock;
+
+ } else {
+ die "Unknown cust_main-auto_agent_custid format: $format";
+ }
+
+ $self->agent_custid($agent_custid);
+
+}
+
sub start_copy_skel {
my $self = shift;
@@ -1233,6 +1265,7 @@
|| $self->ut_textn('stateid_state')
|| $self->ut_textn('invoice_terms')
;
+
#barf. need message catalogs. i18n. etc.
$error .= "Please select an advertising source."
if $error =~ /^Illegal or empty \(numeric\) refnum: /;
@@ -5051,6 +5084,22 @@
qsearch( 'cust_refund', { 'custnum' => $self->custnum } )
}
+=item display_custnum
+
+Returns the displayed customer number for this customer: agent_custid if
+cust_main-default_agent_custid is set and it has a value, custnum otherwise.
+
+=cut
+
+sub display_custnum {
+ my $self = shift;
+ if ( $conf->exists('cust_main-default_agent_custid') && $self->agent_custid ){
+ return $self->agent_custid;
+ } else {
+ return $self->custnum;
+ }
+}
+
=item name
Returns a name string for this customer, either "Company (Last, First)" or
More information about the freeside-commits
mailing list