X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=43d8f0ce77edfff0e0f795dfba5513d0679ffd44;hp=9a83099de2a568ba87277c8a7e785138169287dc;hb=2322f0123062b8cf2f52aed0a63bb4634cdbaef1;hpb=a0f5ae295297e1b17ab89640346fc06cfb1e5892 diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 9a83099de..43d8f0ce7 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -3785,9 +3785,17 @@ Returns all the payments (see L) for this customer. sub cust_pay { my $self = shift; - return $self->num_cust_pay unless wantarray; - sort { $a->_date <=> $b->_date } - qsearch( 'cust_pay', { 'custnum' => $self->custnum } ) + my $opt = ref($_[0]) ? shift : { @_ }; + + return $self->num_cust_pay unless wantarray || keys %$opt; + + $opt->{'table'} = 'cust_pay'; + $opt->{'hashref'}{'custnum'} = $self->custnum; + + map { $_ } #behavior of sort undefined in scalar context + sort { $a->_date <=> $b->_date } + qsearch($opt); + } =item num_cust_pay @@ -3805,6 +3813,22 @@ sub num_cust_pay { $sth->fetchrow_arrayref->[0]; } +=item unapplied_cust_pay + +Returns all the unapplied payments (see L) for this customer. + +=cut + +sub unapplied_cust_pay { + my $self = shift; + + $self->cust_pay( + 'extra_sql' => ' AND '. FS::cust_pay->unapplied_sql. ' > 0', + #@_ + ); + +} + =item cust_pay_pkgnum Returns all the payments (see L) for this customer's specific