diff options
Diffstat (limited to 'FS/FS/part_event/Condition/cust_bill_owed_under.pm')
-rw-r--r-- | FS/FS/part_event/Condition/cust_bill_owed_under.pm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/cust_bill_owed_under.pm b/FS/FS/part_event/Condition/cust_bill_owed_under.pm new file mode 100644 index 0000000..4eb6439 --- /dev/null +++ b/FS/FS/part_event/Condition/cust_bill_owed_under.pm @@ -0,0 +1,49 @@ +package FS::part_event::Condition::cust_bill_owed_under; + +use strict; +use FS::cust_bill; + +use base qw( FS::part_event::Condition ); + +sub description { + 'Amount owed on specific invoice (under)'; +} + +sub eventtable_hashref { + { 'cust_main' => 0, + 'cust_bill' => 1, + 'cust_pkg' => 0, + }; +} + +sub option_fields { + ( + 'owed' => { 'label' => 'Amount owed under (or equal to)', + 'type' => 'money', + 'value' => '0.00', #default + }, + ); +} + +sub condition { + #my($self, $cust_bill, %opt) = @_; + my($self, $cust_bill) = @_; + + my $under = $self->option('owed'); + $under = 0 unless length($under); + + $cust_bill->owed <= $under; + +} + +sub condition_sql { + my( $class, $table ) = @_; + + my $under = $class->condition_sql_option('owed'); + + my $owed_sql = FS::cust_bill->owed_sql; + + "$owed_sql <= CAST( $under AS DECIMAL(10,2) )"; +} + +1; |