[freeside-commits] freeside/FS/FS/part_event/Condition pkg_class.pm, 1.1, 1.2
Mark Wells
mark at wavetail.420.am
Sat Dec 17 12:12:36 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition
In directory wavetail.420.am:/tmp/cvs-serv10004/FS/FS/part_event/Condition
Modified Files:
pkg_class.pm
Log Message:
enable package class condition for invoices, #14499
Index: pkg_class.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition/pkg_class.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- pkg_class.pm 1 Aug 2007 22:24:40 -0000 1.1
+++ pkg_class.pm 17 Dec 2011 20:12:33 -0000 1.2
@@ -11,8 +11,8 @@
}
sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
'cust_pkg' => 1,
};
}
@@ -28,11 +28,22 @@
}
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;
More information about the freeside-commits
mailing list