summaryrefslogtreecommitdiff
path: root/FS/FS/cust_pay.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/cust_pay.pm')
-rw-r--r--FS/FS/cust_pay.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 23bcdd9..5d31d2c 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -550,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.