import torrus 1.0.9
[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 { 'Spool CSV invoice data'; }
7
8 sub deprecated { 1; }
9
10 sub eventtable_hashref {
11   { 'cust_bill' => 1 };
12 }
13
14 sub option_fields {
15   (
16     'spoolformat'       => { label   => 'Format',
17                              type    => 'select',
18                              options => ['default', 'billco'],
19                              option_labels => { 'default' => 'Default',
20                                                 'billco'  => 'Billco',
21                                               },
22                            },
23     'spooldest'         => { label   => 'For destination',
24                              type    => 'select',
25                              options => [ '', qw( POST EMAIL FAX ) ],
26                              option_labels => { ''      => '(all)',
27                                                 'POST'  => 'Postal Mail',
28                                                 'EMAIL' => 'Email',
29                                                 'FAX'   => 'Fax',
30                                               },
31                            },
32     'spoolbalanceover'  => { label =>
33                                'If balance (this invoice and previous) over',
34                              type  => 'money',
35                            },
36     'spoolagent_spools' => { label => 'Individual per-agent spools',
37                              type  => 'checkbox',
38                              value => '1',
39                            },
40   );
41 }
42
43 sub default_weight { 50; }
44
45 sub do_action {
46   my( $self, $cust_bill ) = @_;
47
48   #my $cust_main = $self->cust_main($cust_bill);
49   my $cust_main = $cust_bill->cust_main;
50
51   $cust_bill->spool_csv(
52     'format'       => $self->option('spoolformat'),
53     'dest'         => $self->option('spooldest'),
54     'balanceover'  => $self->option('spoolbalanceover'),
55     'agent_spools' => $self->option('spoolagent_spools'),
56   );
57 }
58
59 1;