X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=5d31d2cde63ce7a4e5b42979db156187b1e73f0f;hp=dc6bd4020d5b8ad94f10286be430ea503d29612e;hb=eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd;hpb=ca63c29a40e2c7ad13558eb204fbb6764bf7a351 diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index dc6bd4020..5d31d2cde 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -69,7 +69,9 @@ L and L for conversion functions. =item paymask - Masked payinfo (See L for how this works) -=item paybatch - text field for tracking card processing +=item paybatch - text field for tracking card processing or other batch grouping + +=item payunique - Optional unique identifer to prevent duplicate transactions. =item closed - books closed flag, empty or `Y' @@ -162,17 +164,6 @@ sub insert { } } - if ( $self->paybatch =~ /^webui-/ ) { - my @cust_pay = qsearch('cust_pay', { - 'custnum' => $self->custnum, - 'paybatch' => $self->paybatch, - } ); - if ( scalar(@cust_pay) > 1 ) { - $dbh->rollback if $oldAutoCommit; - return "a payment with webui token ". $self->paybatch. " already exists"; - } - } - $dbh->commit or die $dbh->errstr if $oldAutoCommit; #false laziness w/ cust_credit::insert @@ -420,8 +411,11 @@ sub check { # UNIQUE index should catch this too, without race conditions, but this # should give a better error message the other 99.9% of the time... if ( length($self->payunique) - && qsearchs('cust_pay', { 'payunique' => $self->payunique } ) { - return "duplicate transaction"; #well, it *could* be a better error message + && qsearchs('cust_pay', { 'payunique' => $self->payunique } ) ) { + #well, it *could* be a better error message + return "duplicate transaction". + " - a payment with unique identifer ". $self->payunique. + " already exists"; } $self->SUPER::check; @@ -556,6 +550,36 @@ sub cust_main { =back +=head1 CLASS METHODS + +=over 4 + +=item unapplied_sql + +Returns an SQL fragment to retreive the unapplied amount. + +=cut + +sub unapplied_sql { + #my $class = shift; + + "paid + - COALESCE( + ( SELECT SUM(amount) FROM cust_bill_pay + WHERE cust_pay.paynum = cust_bill_pay.paynum ) + ,0 + ) + - COALESCE( + ( SELECT SUM(amount) FROM cust_pay_refund + WHERE cust_pay.paynum = cust_pay_refund.paynum ) + ,0 + ) + "; + +} + +=back + =head1 BUGS Delete and replace methods.