event refactor, landing on HEAD!
[freeside.git] / FS / FS / part_event / Action / cust_bill_suspend_if_balance.pm
1 package FS::part_event::Action::cust_bill_suspend_if_balance;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   'Suspend if balance (this invoice and previous) over';
8 }
9
10 sub deprecated {
11   1;
12 }
13
14 sub eventtable_hashref {
15   { 'cust_bill' => 1 };
16 }
17
18 sub option_fields {
19   ( 
20     'balanceover' => { label=>'Balance over', type=>'money', }, # size=>7 },
21     'reasonnum' => { 'label'        => 'Reason',
22                      'type'         => 'select-reason',
23                      'reason_class' => 'S',
24                    },
25   );
26 };
27
28 sub default_weight {
29   10;
30 }
31
32 sub do_action {
33   my( $self, $cust_bill ) = @_;
34
35   #my $cust_main = $self->cust_main($cust_bill);
36   my $cust_main = $cust_bill->cust_main;
37
38   my @err = $cust_bill->cust_suspend_if_balance_over(
39     $self->option('balanceover'),
40     'reason' => $self->option('reasonnum'),
41   );
42
43   die join(' / ', @err) if scalar(@err);
44
45   '';
46 }
47
48 1;