summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Condition/pkg_balance.pm
blob: 2d4a89c84e6275c28c858a19aae5b24a19ebad80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package FS::part_event::Condition::pkg_balance;

use strict;
use FS::cust_main;

use base qw( FS::part_event::Condition );

sub description { 'Package balance'; }


sub option_fields {
  (
    'balance' => { 'label'      => 'Balance over',
                   'type'       => 'money',
                   'value'      => '0.00', #default
                 },
  );
}

sub eventtable_hashref {
  { 'cust_pkg' => 1, };
}

sub condition {
  my($self, $cust_pkg) = @_;

  my $cust_main = $self->cust_main($cust_pkg);

  my $over = $self->option('balance');
  $over = 0 unless length($over);

  $cust_main->balance_pkgnum($cust_pkg->pkgnum) > $over;
}

1;