This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_event / Condition / pkg_balance_under.pm
1 package FS::part_event::Condition::pkg_balance_under;
2
3 use strict;
4 use FS::cust_main;
5
6 use base qw( FS::part_event::Condition );
7
8 sub description { 'Package balance (under)'; }
9
10 sub option_fields {
11   (
12     'balance' => { 'label'      => 'Balance under (or equal to)',
13                    'type'       => 'money',
14                    'value'      => '0.00', #default
15                  },
16   );
17 }
18
19 sub eventtable_hashref {
20   { 'cust_pkg' => 1, };
21 }
22
23 sub condition {
24   my($self, $cust_pkg) = @_;
25
26   my $cust_main = $self->cust_main($cust_pkg);
27
28   my $under = $self->option('balance');
29   $under = 0 unless length($under);
30
31   $cust_main->balance_pkgnum($cust_pkg->pkgnum) <= $under;
32 }
33
34 1;
35