fix long package locations showing up as line item on typeset invoices, RT#10093
[freeside.git] / FS / FS / cust_location.pm
index 50d2a18..ab80941 100644 (file)
@@ -1,9 +1,10 @@
 package FS::cust_location;
 
 use strict;
-use base qw( FS::Record );
+use base qw( FS::geocode_Mixin FS::Record );
 use Locale::Country;
 use FS::Record qw( qsearch ); #qsearchs );
+use FS::prospect_main;
 use FS::cust_main;
 use FS::cust_main_county;
 
@@ -119,7 +120,8 @@ sub check {
 
   my $error = 
     $self->ut_numbern('locationnum')
-    || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+    || $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
+    || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
     || $self->ut_text('address1')
     || $self->ut_textn('address2')
     || $self->ut_text('city')
@@ -131,6 +133,9 @@ sub check {
   ;
   return $error if $error;
 
+  return "No prospect or customer!" unless $self->prospectnum || $self->custnum;
+  return "Prospect and customer!"       if $self->prospectnum && $self->custnum;
+
   unless ( qsearch('cust_main_county', {
     'country' => $self->country,
     'state'   => '',
@@ -160,25 +165,33 @@ sub country_full {
 
 =item line
 
-Returns this location on one line
+Synonym for location_label
 
 =cut
 
 sub line {
   my $self = shift;
-  my $cydefault = FS::conf->new->config('countrydefault') || 'US';
+  $self->location_label;
+}
+
+=item has_ship_address
 
-  my $line =       $self->address1;
-  $line   .= ', '. $self->address2              if $self->address2;
-  $line   .= ', '. $self->city;
-  $line   .= ' ('. $self->county. ' county)'    if $self->county;
-  $line   .= ', '. $self->state                 if $self->state;
-  $line   .= '  '. $self->zip                   if $self->zip;
-  $line   .= '  '. code2country($self->country) if $self->country ne $cydefault;
+Returns false since cust_location objects do not have a separate shipping
+address.
+
+=cut
 
-  $line;
+sub has_ship_address {
+  '';
 }
 
+=item location_hash
+
+Returns a list of key/value pairs, with the following keys: address1, address2,
+city, county, state, zip, country, geocode.
+
+=cut
+
 =back
 
 =head1 BUGS