better error message when export_links can't find a service
[freeside.git] / FS / FS / cust_svc.pm
index 1fd8406..b608b23 100644 (file)
@@ -335,15 +335,27 @@ sub check {
     ($part_svc) = grep { $_->svcpart == $self->svcpart } $cust_pkg->part_svc;
     return "No svcpart ". $self->svcpart.
            " services in pkgpart ". $cust_pkg->pkgpart
-      unless $part_svc;
+      unless $part_svc || $ignore_quantity;
     return "Already ". $part_svc->get('num_cust_svc'). " ". $part_svc->svc.
            " services for pkgnum ". $self->pkgnum
-      if $part_svc->get('num_avail') == 0 and !$ignore_quantity;
+      if !$ignore_quantity && $part_svc->get('num_avail') <= 0 ;
   }
 
   $self->SUPER::check;
 }
 
+=item display_svcnum 
+
+Returns the displayed service number for this service: agent_svcid if it has a
+value, svcnum otherwise
+
+=cut
+
+sub display_svcnum {
+  my $self = shift;
+  $self->agent_svcid || $self->svcnum;
+}
+
 =item part_svc
 
 Returns the definition for this service, as a FS::part_svc object (see
@@ -449,12 +461,9 @@ sub svc_label_long { shift->_svc_label('label_long', @_); }
 sub _svc_label {
   my( $self, $method, $svc_x ) = ( shift, shift, shift );
 
-  my $identifier = $svc_x->$method(@_);
-  $identifier = '['.$self->agent_svcid.']'. $identifier if $self->agent_svcid;
-
   (
     $self->part_svc->svc,
-    $identifier,
+    $svc_x->$method(@_),
     $self->part_svc->svcdb,
     $self->svcnum
   );
@@ -470,7 +479,7 @@ Returns a listref of html elements associated with this service's exports.
 sub export_links {
   my $self = shift;
   my $svc_x = $self->svc_x
-    or return "can't find ". $self->part_svc->svcdb. '.svcnum '. $self->svcnum;
+    or return [ "can't find ". $self->part_svc->svcdb. '.svcnum '. $self->svcnum ];
 
   $svc_x->export_links;
 }