[freeside-commits] freeside/FS/FS phone_avail.pm,1.16,1.17
Erik Levinson
levinse at wavetail.420.am
Wed Jul 6 18:43:50 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv26862/FS/FS
Modified Files:
phone_avail.pm
Log Message:
various DID inventory changes, RT12754
Index: phone_avail.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/phone_avail.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -d -r1.16 -r1.17
--- phone_avail.pm 21 Jun 2011 03:16:59 -0000 1.16
+++ phone_avail.pm 7 Jul 2011 01:43:48 -0000 1.17
@@ -5,6 +5,8 @@
use FS::Record qw( qsearch qsearchs dbh );
use FS::cust_svc;
use FS::Misc::DateTime qw( parse_datetime );
+use FS::msa;
+use Data::Dumper;
@ISA = qw(FS::cust_main_Mixin FS::Record);
@@ -201,11 +203,23 @@
sub msa2msanum {
my $self = shift;
my $msa = shift;
- my $res = qsearchs('msa', { 'description' => { 'op' => 'ILIKE',
- 'value' => $msa, }
+ my @msas = qsearch('msa', { 'description' => { 'op' => 'ILIKE',
+ 'value' => "%$msa%", }
});
- return 0 unless $res;
- $res->msanum;
+ return 0 unless scalar(@msas);
+ my @msa = grep { $self->msatest($msa,$_->description) } @msas;
+ return 0 unless scalar(@msa) == 1;
+ $msa[0]->msanum;
+}
+
+sub msatest {
+ my $self = shift;
+ my ($their,$our) = (shift,shift);
+ my $a = $our;
+ $a =~ s/,.*?$//;
+ return 1 if $a eq $their;
+ return 1 if ($our =~ /^([\w\s]+)-/ && $1 eq $their);
+ 0;
}
sub process_batch_import {
@@ -223,6 +237,7 @@
my $msasub = sub {
my( $phone_avail, $value ) = @_;
+ return '' if !$value;
my $msanum = $phone_avail->msa2msanum($value);
die "cannot translate MSA ($value) to msanum" unless $msanum;
$phone_avail->msanum($msanum);
More information about the freeside-commits
mailing list