diff options
author | ivan <ivan> | 2002-06-26 01:35:08 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-06-26 01:35:08 +0000 |
commit | ecb895ccbbf52ed2babc0885c9925022175e33a0 (patch) | |
tree | b7bcc155a0c7f578c2015f3fd77c3180bb3ec462 /FS | |
parent | d17a7cdeed4fbd901084369347b56d3d4f02c11b (diff) |
working one-time charges
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main.pm | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index b39a77fd7..b68bf9e8f 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1743,16 +1743,45 @@ the error, otherwise returns false. sub charge { my ( $self, $amount, $pkg, $comment ) = @_; + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + my $part_pkg = new FS::part_pkg ( { 'pkg' => $pkg || 'One-time charge', - 'comment' => $comment || '$'. sprintf("%.2f".$amount), + 'comment' => $comment || '$'. sprintf("%.2f",$amount), 'setup' => $amount, 'freq' => 0, 'recur' => '0', 'disabled' => 'Y', } ); - $part_pkg->insert; + my $error = $part_pkg->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + my $cust_pkg = new FS::cust_pkg ( { + 'custnum' => $self->custnum, + 'pkgpart' => $part_pkg->pkgpart, + } ); + + $error = $cust_pkg->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; } |