5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch);
37 invoicing_list_emailonly_scalar
43 #Billing Type: Credit Card
44 { 'header' => 'Credit Card number',
45 'callback' => sub { my $c_m = shift;
46 $c_m->payby =~ /^(CARD|DCRD)$/ ? $c_m->payinfo : '' ;
49 { 'header' => 'Expiration on card',
50 'callback' => sub { my $c_m = shift;
51 return '' unless $c_m->payby =~ /^(CARD|DCRD)$/;
52 $c_m->paydate =~ /^(\d{4})-(\d{2})-\d{2}$/ or die;
56 { 'header' => 'Name on card',
57 'callback' => sub { my $c_m = shift;
58 $c_m->payby =~ /^(CARD|DCRD)$/ ? $c_m->paydname : '' ;
62 #Billing Type: Electronic check
63 { 'header' => 'ABA/Routing number',
64 'callback' => sub { my $c_m = shift;
65 return '' unless $c_m->payby =~ /^(CHEK|DCHK)$/;
66 (split('@', $c_m->payinfo))[1];
69 { 'header' => 'Account number',
70 'callback' => sub { my $c_m = shift;
71 return '' unless $c_m->payby =~ /^(CHEK|DCHK)$/;
72 (split('@', $c_m->payinfo))[0];
75 { 'header' => 'Account type',
76 'callback' => sub { my $c_m = shift;
77 $c_m->payby =~ /^(CHEK|DCHK)$/ ? $c_m->paytype : '';
80 { 'header' => 'Bank Name',
81 'callback' => sub { my $c_m = shift;
82 $c_m->payby =~ /^(CHEK|DCHK)$/ ? $c_m->payname : '';
88 my $user = shift or die &usage;
91 my $agentnum = shift or die &usage;
93 my $csv = new Text::CSV_XS;
95 $csv->combine( map { ref($_) ? $_->{'header'} : $_ } @fields ) or die;
96 print $csv->string."\n";
98 my @cust_main = qsearch('cust_main', { 'agentnum'=>$agentnum });
100 foreach my $cust_main( @cust_main ) {
101 $csv->combine( map { ref($_) ? &{$_->{'callback'}}($cust_main)
106 print $csv->string."\n";