enable package class condition for invoices, #14499
[freeside.git] / FS / FS / part_event / Condition / pkg_balance.pm
1 package FS::part_event::Condition::pkg_balance;
2
3 use strict;
4 use FS::cust_main;
5
6 use base qw( FS::part_event::Condition );
7
8 sub description { 'Package balance'; }
9
10
11 sub option_fields {
12   (
13     'balance' => { 'label'      => 'Balance over',
14                    'type'       => 'money',
15                    'value'      => '0.00', #default
16                  },
17   );
18 }
19
20 sub eventtable_hashref {
21   { 'cust_pkg' => 1, };
22 }
23
24 sub condition {
25   my($self, $cust_pkg) = @_;
26
27   my $cust_main = $self->cust_main($cust_pkg);
28
29   my $over = $self->option('balance');
30   $over = 0 unless length($over);
31
32   $cust_main->balance_pkgnum($cust_pkg->pkgnum) > $over;
33 }
34
35 1;
36