X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=4c1617f0ef29d30078ea828feb264095e84aa9a1;hp=4ffb8e210c5769de03d5be24f3596f2a0ab76072;hb=6412f71a3557249225abf5eb2096ebad1729c585;hpb=cdd5aa1d86cd5b266e02bed58570c97c2d7698ba diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 4ffb8e210..4c1617f0e 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -11,6 +11,7 @@ use FS::cust_bill_pkg; use FS::cust_credit; use FS::cust_pay; use FS::cust_pkg; +use FS::cust_credit_bill; @ISA = qw( FS::Record ); @@ -204,8 +205,8 @@ sub cust_bill_pkg { =item cust_credit Returns a list consisting of the total previous credited (see -L) for this customer, followed by the previous outstanding -credits (FS::cust_credit objects). +L) and unapplied for this customer, followed by the previous +outstanding credits (FS::cust_credit objects). =cut @@ -233,6 +234,19 @@ sub cust_pay { ; } +=item cust_credited + +Returns all applied credits (see L) for this invoice. + +=cut + +sub cust_credited { + my $self = shift; + sort { $a->_date <=> $b->_date } + qsearch( 'cust_credit_bill', { 'invnum' => $self->invnum } ) + ; +} + =item tax Returns the tax amount (see L) for this invoice. @@ -251,7 +265,8 @@ sub tax { =item owed Returns the amount owed (still outstanding) on this invoice, which is charged -minus all payments (see L). +minus all payments (see L) and applied credits +(see L). =cut @@ -259,7 +274,8 @@ sub owed { my $self = shift; my $balance = $self->charged; $balance -= $_->paid foreach ( $self->cust_pay ); - $balance; + $balance -= $_->amount foreach ( $self->cust_credited ); + $balance = sprintf( "%.2f", $balance); } =item print_text [TIME]; @@ -349,6 +365,12 @@ sub print_text { push @buf,['','']; #credits + foreach ( $self->cust_credited ) { + push @buf,[ + "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", + $money_char. sprintf("%10.2f",$_->amount) + ]; + } foreach ( @cr_cust_credit ) { push @buf,[ "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", @@ -441,7 +463,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.8 2001-08-03 20:34:28 jeff Exp $ +$Id: cust_bill.pm,v 1.9 2001-09-01 21:52:19 jeff Exp $ =head1 BUGS