This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_event / Condition / cust_payments.pm
1 package FS::part_event::Condition::cust_payments;
2
3 use strict;
4 use base qw( FS::part_event::Condition );
5
6 sub description { 'Customer total payments (amount)'; }
7
8 sub option_fields {
9   (
10     'over' => { 'label'      => 'Customer total payments at least',
11                 'type'       => 'money',
12                 'value'      => '0.00', #default
13               },
14   );
15 }
16
17 sub condition {
18   my($self, $object) = @_;
19
20   my $cust_main = $self->cust_main($object);
21
22   my $over = $self->option('over');
23   $over = 0 unless length($over);
24
25   $cust_main->total_paid >= $over;
26
27 }
28
29 #XXX add for efficiency.  could use cust_main::total_paid_sql
30 #use FS::cust_main;
31 #sub condition_sql {
32 #  my( $class, $table ) = @_;
33 #
34 #  my $over = $class->condition_sql_option('balance');
35 #
36 #  my $balance_sql = FS::cust_main->balance_sql;
37 #
38 #  "$balance_sql > $over";
39 #
40 #}
41
42 1;
43