default to a session cookie instead of setting an explicit timeout, weird timezone...
[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     'skip_nopost' => { label => 'Skip customers without postal billing enabled',
37                        type  => 'checkbox',
38                        value => 'Y',
39                      },
40   );
41 }
42
43 sub default_weight { 50; }
44
45 sub do_action {
46   my( $self, $cust_bill, $cust_event ) = @_;
47
48   #my $cust_main = $self->cust_main($cust_bill);
49   my $cust_main = $cust_bill->cust_main;
50
51   return if $self->option('skip_nopost')
52          && ! grep { $_ eq 'POST' } $cust_main->invoicing_list;
53
54   $cust_bill->spool_csv(
55     'time'         => $cust_event->_date,
56     'format'       => $self->option('spoolformat'),
57     'balanceover'  => $self->option('spoolbalanceover'),
58     'agent_spools' => $self->option('spoolagent_spools'),
59     'upload_targetnum'=> $self->option('upload_targetnum'),
60   );
61 }
62
63 1;