event refactor, landing on HEAD!
[freeside.git] / FS / FS / part_event / Action / cust_bill_spool_csv.pm
1 package FS::part_event::Action::cust_bill_spool_csv;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   'Spool CSV invoice data';
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     'spoolformat'       => { label   => 'Format',
21                              type    => 'select',
22                              options => ['default', 'billco'],
23                              option_labels => { 'default' => 'Default',
24                                                 'billco'  => 'Billco',
25                                               },
26                            },
27     'spooldest'         => { label   => 'For destination',
28                              type    => 'select',
29                              options => [ '', qw( POST EMAIL FAX ) ],
30                              option_labels => { ''      => '(all)',
31                                                 'POST'  => 'Postal Mail',
32                                                 'EMAIL' => 'Email',
33                                                 'FAX'   => 'Fax',
34                                               },
35                            },
36     'spoolbalanceover'  => { label =>
37                                'If balance (this invoice and previous) over',
38                              type  => 'money',
39                            },
40     'spoolagent_spools' => { label => 'Individual per-agent spools',
41                              type  => 'checkbox',
42                            },
43   );
44 }
45
46 sub default_weight {
47   50;
48 }
49
50 sub do_action {
51   my( $self, $cust_bill ) = @_;
52
53   #my $cust_main = $self->cust_main($cust_bill);
54   my $cust_main = $cust_bill->cust_main;
55
56   $cust_bill->spool_csv(
57     'format'       => $self->option('spoolformat'),
58     'dest'         => $self->option('spooldest'),
59     'balanceover'  => $self->option('spoolbalanceover'),
60     'agent_spools' => $self->option('spoolagent_spools'),
61   );
62 }
63
64 1;