250c8304278e78f485043d2130285493d11131b6
[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 use FS::Misc::Invoicing qw( spool_formats );
6
7 sub description { 'Spool CSV invoice data'; }
8
9 sub deprecated { 1; }
10
11 sub eventtable_hashref {
12   { 'cust_bill' => 1 };
13 }
14
15 sub option_fields {
16   (
17     'spoolformat'       => { label   => 'Format',
18                              type    => 'select',
19                              options => [ spool_formats() ],
20                            },
21     'spoolbalanceover'  => { label =>
22                                'If balance (this invoice and previous) over',
23                              type  => 'money',
24                            },
25     'spoolagent_spools' => { label => 'Individual per-agent spools',
26                              type  => 'checkbox',
27                              value => '1',
28                            },
29     'upload_targetnum'  => { label    => 'Upload spool to target',
30                              type     => 'select-table',
31                              table    => 'upload_target',
32                              name_col => 'label',
33                              empty_label => '(do not upload)',
34                              order_by => 'targetnum',
35                            },
36   );
37 }
38
39 sub default_weight { 50; }
40
41 sub do_action {
42   my( $self, $cust_bill, $cust_event ) = @_;
43
44   #my $cust_main = $self->cust_main($cust_bill);
45   my $cust_main = $cust_bill->cust_main;
46
47   $cust_bill->spool_csv(
48     'time'         => $cust_event->_date,
49     'format'       => $self->option('spoolformat'),
50     'balanceover'  => $self->option('spoolbalanceover'),
51     'agent_spools' => $self->option('spoolagent_spools'),
52     'upload_targetnum'=> $self->option('upload_targetnum'),
53   );
54 }
55
56 1;