freeside/FS/FS cust_main.pm,1.92.2.43,1.92.2.44 cust_bill.pm,1.41.2.45,1.41.2.46
ivan
ivan at pouncequick.420.am
Tue Mar 30 08:45:50 PST 2004
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv28881
Modified Files:
Tag: FREESIDE_1_4_BRANCH
cust_main.pm cust_bill.pm
Log Message:
mutex the bill and collect functions per-customer
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.92.2.43
retrieving revision 1.92.2.44
diff -u -d -r1.92.2.43 -r1.92.2.44
--- cust_main.pm 3 Mar 2004 13:44:27 -0000 1.92.2.43
+++ cust_main.pm 30 Mar 2004 16:45:48 -0000 1.92.2.44
@@ -1082,6 +1082,8 @@
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
+ $self->select_for_update; #mutex
+
# find the packages which are due for billing, find out how much they are
# & generate invoice database.
@@ -1479,6 +1481,8 @@
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
+ $self->select_for_update; #mutex
+
my $balance = $self->balance;
warn "collect customer". $self->custnum. ": balance $balance" if $DEBUG;
unless ( $balance > 0 ) { #redundant?????
@@ -2170,6 +2174,18 @@
my $self = shift;
sort { $a->_date <=> $b->_date }
qsearch( 'cust_refund', { 'custnum' => $self->custnum } )
+}
+
+=item select_for_update
+
+Selects this record with the SQL "FOR UPDATE" command. This can be useful as
+a mutex.
+
+=cut
+
+sub select_for_update {
+ my $self = shift;
+ qsearch('cust_main', { 'custnum' => $self->custnum }, '*', 'FOR UPDATE' );
}
=back
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.41.2.45
retrieving revision 1.41.2.46
diff -u -d -r1.41.2.45 -r1.41.2.46
--- cust_bill.pm 12 Mar 2004 08:17:50 -0000 1.41.2.45
+++ cust_bill.pm 30 Mar 2004 16:45:48 -0000 1.41.2.46
@@ -879,15 +879,20 @@
} );
my $error = $cust_pay->insert;
if ( $error ) {
- # gah, even with transactions.
- my $e = 'WARNING: Card/ACH debited but database not updated - '.
- 'error applying payment, invnum #' . $self->invnum.
- " ($processor): $error";
- warn $e;
- return $e;
- } else {
- return '';
+ $cust_pay->invnum(''); #try again with no specific invnum
+ my $error2 = $cust_pay->insert;
+ if ( $error2 ) {
+ # gah, even with transactions.
+ my $e = 'WARNING: Card/ACH debited but database not updated - '.
+ "error inserting payment ($processor): $error2".
+ ' (previously tried insert with invnum #' . $self->invnum.
+ ": $error )";
+ warn $e;
+ return $e;
+ }
}
+ return ''; #no error
+
#} elsif ( $options{'report_badcard'} ) {
} else {
More information about the freeside-commits
mailing list