[freeside-commits] freeside/FS/FS qual.pm, 1.11, 1.12 geocode_Mixin.pm, 1.6, 1.7 cust_location.pm, 1.10, 1.11
Ivan,,,
ivan at wavetail.420.am
Mon Mar 21 23:00:56 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv24450/FS/FS
Modified Files:
qual.pm geocode_Mixin.pm cust_location.pm
Log Message:
new customer from prospect qualification, RT#7111
Index: cust_location.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_location.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- cust_location.pm 13 Mar 2011 03:49:25 -0000 1.10
+++ cust_location.pm 22 Mar 2011 06:00:54 -0000 1.11
@@ -203,7 +203,8 @@
=item location_hash
Returns a list of key/value pairs, with the following keys: address1, address2,
-city, county, state, zip, country, geocode.
+city, county, state, zip, country, geocode, location_type, location_number,
+location_kind.
=cut
@@ -271,6 +272,84 @@
return;
}
+=item alternize
+
+Attempts to parse data for location_type and location_number from address1
+and address2.
+
+=cut
+
+sub alternize {
+ my $self = shift;
+
+ return '' if $self->get('location_type')
+ || $self->get('location_number');
+
+ my %parse;
+ if ( 1 ) { #ikano, switch on via config
+ { no warnings 'void';
+ eval { 'use FS::part_export::ikano;' };
+ die $@ if $@;
+ }
+ %parse = FS::part_export::ikano->location_types_parse;
+ } else {
+ %parse = (); #?
+ }
+
+ foreach my $from ('address1', 'address2') {
+ foreach my $parse ( keys %parse ) {
+ my $value = $self->get($from);
+ if ( $value =~ s/(^|\W+)$parse\W+(\w+)\W*$//i ) {
+ $self->set('location_type', $parse{$parse});
+ $self->set('location_number', $2);
+ $self->set($from, $value);
+ return '';
+ }
+ }
+ }
+
+ #nothing matched, no changes
+ $self->get('address2')
+ ? "Can't parse unit type and number from address2"
+ : '';
+}
+
+=item dealternize
+
+Moves data from location_type and location_number to the end of address1.
+
+=cut
+
+sub dealternize {
+ my $self = shift;
+
+ #false laziness w/geocode_Mixin.pm::line
+ my $lt = $self->get('location_type');
+ if ( $lt ) {
+
+ my %location_type;
+ if ( 1 ) { #ikano, switch on via config
+ { no warnings 'void';
+ eval { 'use FS::part_export::ikano;' };
+ die $@ if $@;
+ }
+ %location_type = FS::part_export::ikano->location_types;
+ } else {
+ %location_type = (); #?
+ }
+
+ $self->address1( $self->address1. ' '. $location_type{$lt} || $lt );
+ $self->location_type('');
+ }
+
+ if ( length($self->location_number) ) {
+ $self->address1( $self->address1. ' '. $self->location_number );
+ $self->location_number('');
+ }
+
+ '';
+}
+
=back
=head1 BUGS
Index: qual.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/qual.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -d -r1.11 -r1.12
--- qual.pm 13 Mar 2011 18:56:03 -0000 1.11
+++ qual.pm 22 Mar 2011 06:00:54 -0000 1.12
@@ -185,28 +185,34 @@
'';
}
+sub cust_location {
+ my $self = shift;
+ return '' unless $self->locationnum;
+ qsearchs('cust_location', { 'locationnum' => $self->locationnum } );
+}
+
+sub cust_main {
+ my $self = shift;
+ return '' unless $self->custnum;
+ qsearchs('cust_main', { 'custnum' => $self->custnum } );
+}
+
sub location_hash {
my $self = shift;
- if ( $self->locationnum ) {
- my $l = qsearchs( 'cust_location',
- { 'locationnum' => $self->locationnum });
- if ( $l ) {
+
+ if ( my $l = $self->cust_location ) {
my %loc_hash = $l->location_hash;
$loc_hash{locationnum} = $self->locationnum;
return %loc_hash;
}
- }
- if ( $self->custnum ) {
- my $c = qsearchs( 'cust_main', { 'custnum' => $self->custnum });
- if($c) {
+ if ( my $c = $self->cust_main ) {
# always override location_kind as it would never be known in the
# case of cust_main "default service address"
my %loc_hash = $c->location_hash;
$loc_hash{location_kind} = $c->company ? 'B' : 'R';
return %loc_hash;
}
- }
warn "prospectnum does not imply any particular address! must specify locationnum";
return ();
@@ -226,6 +232,7 @@
if $self->custnum;
return qsearchs('prospect_main', { 'prospectnum' => $self->prospectnum })
if $self->prospectnum;
+ '';
}
sub status_long {
Index: geocode_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/geocode_Mixin.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- geocode_Mixin.pm 13 Mar 2011 19:38:02 -0000 1.6
+++ geocode_Mixin.pm 22 Mar 2011 06:00:54 -0000 1.7
@@ -96,7 +96,8 @@
$notfirst++;
}
- if ( $self->get($prefix.'location_type') ) {
+ my $lt = $self->get($prefix.'location_type');
+ if ( $lt ) {
my %location_type;
if ( 1 ) { #ikano, switch on via config
{ no warnings 'void';
@@ -108,9 +109,7 @@
%location_type = (); #?
}
- $line .= ' '.&$escape( $location_type{ $self->get($prefix.'location_type') }
- || $self->get($prefix.'location_type')
- );
+ $line .= ' '.&$escape( $location_type{$lt} || $lt );
}
$line .= ' '. &$escape($self->get($prefix.'location_number'))
@@ -172,49 +171,6 @@
$geocode;
}
-=item alternize
-
-Attempts to parse data for location_type and location_number from address1
-and address2.
-
-=cut
-
-sub alternize {
- my $self = shift;
- my $prefix = $self->has_ship_address ? 'ship_' : '';
-
- return '' if $self->get($prefix.'location_type')
- || $self->get($prefix.'location_number');
-
- my %parse;
- if ( 1 ) { #ikano, switch on via config
- { no warnings 'void';
- eval { 'use FS::part_export::ikano;' };
- die $@ if $@;
- }
- %parse = FS::part_export::ikano->location_types_parse;
- } else {
- %parse = (); #?
- }
-
- foreach my $from ('address1', 'address2') {
- foreach my $parse ( keys %parse ) {
- my $value = $self->get($prefix.$from);
- if ( $value =~ s/(^|\W+)$parse\W+(\w+)\W*$//i ) {
- $self->set($prefix.'location_type', $parse{$parse});
- $self->set($prefix.'location_number', $2);
- $self->set($prefix.$from, $value);
- return '';
- }
- }
- }
-
- #nothing matched, no changes
- $self->get($prefix.'address2')
- ? "Can't parse unit type and number from ${prefix}address2"
- : '';
-}
-
=back
=head1 BUGS
More information about the freeside-commits
mailing list