1 package FS::part_event::Condition::cust_bill_owed_percent;
6 use base qw( FS::part_event::Condition );
9 'Percentage owed on specific invoice';
12 sub eventtable_hashref {
21 'owed' => { 'label' => 'Percentage of invoice owed over',
22 'type' => 'percentage',
23 'value' => '0', #default
29 #my($self, $cust_bill, %opt) = @_;
30 my($self, $cust_bill) = @_;
32 my $percent = $self->option('owed') || 0;
33 my $over = sprintf('%.2f',
34 $cust_bill->charged * $percent / 100);
36 $cust_bill->owed > $over;
40 my( $class, $table ) = @_;
42 # forces the option to be an integer--do we care?
43 my $percent = $class->condition_sql_option_integer('owed');
45 my $owed_sql = FS::cust_bill->owed_sql;
47 "$owed_sql > CAST( cust_bill.charged * $percent / 100 AS DECIMAL(10,2) )";