diff options
| author | mark <mark> | 2011-12-17 20:12:42 +0000 | 
|---|---|---|
| committer | mark <mark> | 2011-12-17 20:12:42 +0000 | 
| commit | 7f5e32275a5a2674fd1d220cd651b222b9831476 (patch) | |
| tree | 6ab69919ba4c2fdca43e80f78f028b690d50bd72 /FS | |
| parent | 9dd7da8c2e0c7547adf0ef6abefa06b5e951dbf1 (diff) | |
enable package class condition for invoices, #14499
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/part_event/Condition/pkg_class.pm | 21 | 
1 files changed, 16 insertions, 5 deletions
| diff --git a/FS/FS/part_event/Condition/pkg_class.pm b/FS/FS/part_event/Condition/pkg_class.pm index 8c9031c6b..d41ec6ba8 100644 --- a/FS/FS/part_event/Condition/pkg_class.pm +++ b/FS/FS/part_event/Condition/pkg_class.pm @@ -11,8 +11,8 @@ sub description {  }  sub eventtable_hashref { -    { 'cust_main' => 0, -      'cust_bill' => 0, +    { 'cust_main' => 1, +      'cust_bill' => 1,        'cust_pkg'  => 1,      };  } @@ -28,11 +28,22 @@ sub option_fields {  }  sub condition { -  my( $self, $cust_pkg ) = @_; +  my( $self, $object ) = @_; -  #XXX test +  # interpretation depends on the eventtable    my $hashref = $self->option('pkgclass') || {}; -  $hashref->{ $cust_pkg->part_pkg->classnum }; +  if ( $object->isa('FS::cust_pkg') ) { +    # is this package in that class? +    $hashref->{ $object->part_pkg->classnum }; +  } +  elsif ( $object->isa('FS::cust_main') ) { +    # does this customer have an active package in that class? +    grep { $hashref->{ $_->part_pkg->classnum } } $object->ncancelled_pkgs; +  } +  elsif ( $object->isa('FS::cust_bill') ) { +    # does a package of that class appear on this invoice? +    grep { $hashref->{ $_->part_pkg->classnum } } $object->cust_pkg; +  }  }  1; | 
