suspend event option to skip packages with a start_date, RT#83847
[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 { 'Suspend if balance (this invoice and previous) over'; }
7
8 sub deprecated { 1; }
9
10 sub eventtable_hashref {
11   { 'cust_bill' => 1 };
12 }
13
14 sub option_fields {
15   ( 
16     'balanceover' => { label=>'Balance over', type=>'money', }, # size=>7 },
17     'reasonnum' => { 'label'        => 'Reason',
18                      'type'         => 'select-reason',
19                      'reason_class' => 'S',
20                    },
21   );
22 }
23
24 sub default_weight { 10; }
25
26 sub do_action {
27   my( $self, $cust_bill ) = @_;
28
29   #my $cust_main = $self->cust_main($cust_bill);
30   my $cust_main = $cust_bill->cust_main;
31
32   my @err = $cust_bill->cust_suspend_if_balance_over(
33     $self->option('balanceover'),
34     'reason' => $self->option('reasonnum'),
35   );
36
37   die join(' / ', @err) if scalar(@err);
38
39   '';
40 }
41
42 1;