1 package FS::part_event::Condition::cust_payments_pkg;
4 use base qw( FS::part_event::Condition );
6 sub description { 'Customer total payments (multiplier of package)'; }
8 sub eventtable_hashref {
14 'over_times' => { 'label' => 'Customer total payments as least',
16 'value' => '1', #default
18 'what' => { 'label' => 'Times',
20 #also add some way to specify in the package def, no?
21 'options' => [ qw( base_recur_permonth ) ],
22 'labels' => { 'base_recur_permonth' => 'Base monthly fee', },
28 my($self, $cust_pkg) = @_;
30 my $cust_main = $self->cust_main($cust_pkg);
32 my $part_pkg = $cust_pkg->part_pkg;
34 my $over_times = $self->option('over_times');
35 $over_times = 0 unless length($over_times);
37 my $what = $self->option('what');
39 #false laziness w/Condition/cust_payments_pkg.pm
40 if ( $what eq 'base_recur_permonth' ) { #huh. yuck.
41 if ( $part_pkg->freq !~ /^\d+$/ ) {
42 die 'WARNING: Not crediting customer '. $cust_main->referral_custnum.
43 ' for package '. $cust_pkg->pkgnum.
44 ' ( customer '. $cust_pkg->custnum. ')'.
45 ' - Referral credits not (yet) available for '.
46 ' packages with '. $part_pkg->freq_pretty. ' frequency';
50 $cust_main->total_paid >= $over_times * $part_pkg->$what($cust_pkg);
54 #XXX add for efficiency. could use cust_main::total_paid_sql
57 # my( $class, $table ) = @_;
59 # my $over = $class->condition_sql_option('balance');
61 # my $balance_sql = FS::cust_main->balance_sql;
63 # "$balance_sql > $over";