diff options
author | ivan <ivan> | 2002-08-30 23:17:31 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-08-30 23:17:31 +0000 |
commit | 971a48bc316c52aa1471d195d75ba0137c286040 (patch) | |
tree | 40b09295e8a88466eb5f2d4a42927e31ed3e9972 | |
parent | 04af7174c8f52ff484af7851f687e98f4d88670c (diff) |
bill batch imported customers immediately (as of their cust_pkg.bill date) -
setting cust_pkg.bill date directly bypasses setup fee
-rw-r--r-- | FS/FS/cust_main.pm | 24 |
1 files changed, 23 insertions, 1 deletions
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++; } |