[freeside-commits] freeside/FS/FS cust_bill.pm, 1.163.2.12, 1.163.2.13
Ivan,,,
ivan at wavetail.420.am
Fri Nov 30 13:08:15 PST 2007
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv31515/FS/FS
Modified Files:
Tag: FREESIDE_1_7_BRANCH
cust_bill.pm
Log Message:
add net vs gross amounts to invoice report; make the "net sales" links on sales/credit/receipts report & graph clickable
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.163.2.12
retrieving revision 1.163.2.13
diff -u -d -r1.163.2.12 -r1.163.2.13
--- cust_bill.pm 30 Nov 2007 18:13:34 -0000 1.163.2.12
+++ cust_bill.pm 30 Nov 2007 21:08:12 -0000 1.163.2.13
@@ -2583,7 +2583,6 @@
sub re_X {
my($method, $job, %param ) = @_;
-# [ 'begin', 'end', 'agentnum', 'open', 'days', 'newest_percust' ],
if ( $DEBUG ) {
warn "re_X $method for job $job with param:\n".
join( '', map { " $_ => ". $param{$_}. "\n" } keys %param );
@@ -2611,15 +2610,12 @@
push @where, "cust_main.agentnum = $1";
}
- my $owed =
- "charged - ( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay
- WHERE cust_bill_pay.invnum = cust_bill.invnum )
- - ( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill
- WHERE cust_credit_bill.invnum = cust_bill.invnum )";
-
- push @where, "0 != $owed"
+ push @where, '0 != '. FS::cust_bill->owed_sql
if $param{'open'};
+ push @where, '0 != '. FS::cust_bill->net_sql
+ if $param{'net'};
+
push @where, "cust_bill._date < ". (time-86400*$param{'days'})
if $param{'days'};
@@ -2676,13 +2672,62 @@
=back
+=head1 CLASS METHODS
+
+=over 4
+
+=item owed_sql
+
+Returns an SQL fragment to retreive the amount owed (charged minus credited and paid).
+
+=cut
+
+sub owed_sql {
+ my $class = shift;
+ 'charged - '. $class->paid_sql. ' - '. $class->credited_sql;
+}
+
+=item net_sql
+
+Returns an SQL fragment to retreive the net amount (charged minus credited).
+
+=cut
+
+sub net_sql {
+ my $class = shift;
+ 'charged - '. $class->credited_sql;
+}
+
+=item paid_sql
+
+Returns an SQL fragment to retreive the amount paid against this invoice.
+
+=cut
+
+sub paid_sql {
+ #my $class = shift;
+ "( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay
+ WHERE cust_bill.invnum = cust_bill_pay.invnum )";
+}
+
+=item credited_sql
+
+Returns an SQL fragment to retreive the amount credited against this invoice.
+
+=cut
+
+sub credited_sql {
+ #my $class = shift;
+ "( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill
+ WHERE cust_bill.invnum = cust_credit_bill.invnum )";
+}
+
+=back
+
=head1 BUGS
The delete method.
-print_text formatting (and some logic :/) is in source, but needs to be
-slurped in from a file. Also number of lines ($=).
-
=head1 SEE ALSO
L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill_pay>, L<FS::cust_pay>,
More information about the freeside-commits
mailing list