From 971a48bc316c52aa1471d195d75ba0137c286040 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 30 Aug 2002 23:17:31 +0000 Subject: [PATCH] bill batch imported customers immediately (as of their cust_pkg.bill date) - setting cust_pkg.bill date directly bypasses setup fee --- FS/FS/cust_main.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index eae760bd3..8e47f23d5 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2020,11 +2020,16 @@ sub batch_import { payby => 'BILL', #default paydate => '12/2037', #default ); + my $billtime = time; my %cust_pkg = ( pkgpart => $pkgpart ); foreach my $field ( @fields ) { if ( $field =~ /^cust_pkg\.(setup|bill|susp|expire|cancel)$/ ) { #$cust_pkg{$1} = str2time( shift @$columns ); - $cust_pkg{$1} = str2time( shift @columns ); + if ( $1 eq 'setup' ) { + $billtime = str2time(shift @columns); + } else { + $cust_pkg{$1} = str2time( shift @columns ); + } } else { #$cust_main{$field} = shift @$columns; $cust_main{$field} = shift @columns; @@ -2042,6 +2047,23 @@ sub batch_import { $dbh->rollback if $oldAutoCommit; return "can't insert customer for $line: $error"; } + + #false laziness w/bill.cgi + $error = $cust_main->bill( 'time' => $billtime ); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "can't bill customer for $line: $error"; + } + + $cust_main->apply_payments; + $cust_main->apply_credits; + + $error = $cust_main->collect(); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "can't collect customer for $line: $error"; + } + $imported++; } -- 2.11.0