diff options
author | Mitch Jackson <mitch@freeside.biz> | 2018-09-11 03:23:52 -0400 |
---|---|---|
committer | Mitch Jackson <mitch@freeside.biz> | 2018-09-19 12:02:19 -0400 |
commit | 94f0030bae0ce3e493b99860901158e30e9651fd (patch) | |
tree | ae3576bdc3073d825a424030275f7ca1918675bd /FS/FS/cust_bill.pm | |
parent | b9bb2b3bc596c18245199cd799c5f50d3e02ea59 (diff) |
RT# 78547 Allow for simulated billing within a transaction
Diffstat (limited to 'FS/FS/cust_bill.pm')
-rw-r--r-- | FS/FS/cust_bill.pm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index dc63fdb..84487d2 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -41,6 +41,7 @@ use FS::cust_bill_void; use FS::reason; use FS::reason_type; use FS::L10N; +use FS::Misc::Savepoint; $DEBUG = 0; $me = '[FS::cust_bill]'; @@ -971,6 +972,9 @@ sub apply_payments_and_credits { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + my $savepoint_label = 'cust_bill__apply_payments_and_credits'; + savepoint_create( $savepoint_label ); + $self->select_for_update; #mutex my @payments = grep { $_->unapplied > 0 } @@ -1059,6 +1063,7 @@ sub apply_payments_and_credits { my $error = $app->insert(%options); if ( $error ) { + savepoint_rollback_and_release( $savepoint_label ); $dbh->rollback if $oldAutoCommit; return "Error inserting ". $app->table. " record: $error"; } @@ -1066,6 +1071,7 @@ sub apply_payments_and_credits { } + savepoint_release( $savepoint_label ); $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; #no error |