use FS::cust_credit;
use FS::cust_pay;
use FS::cust_pkg;
+use FS::cust_credit_bill;
@ISA = qw( FS::Record );
@cust_pay_objects = $cust_bill->cust_pay;
+ $tax_amount = $record->tax;
+
@lines = $cust_bill->print_text;
@lines = $cust_bill->print_text $time;
=item cust_credit
Returns a list consisting of the total previous credited (see
-L<FS::cust_credit>) for this customer, followed by the previous outstanding
-credits (FS::cust_credit objects).
+L<FS::cust_credit>) and unapplied for this customer, followed by the previous
+outstanding credits (FS::cust_credit objects).
=cut
;
}
+=item cust_credited
+
+Returns all applied credits (see L<FS::cust_credit_bill>) 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<FS::cust_bill_pkg>) for this invoice.
+
+=cut
+
+sub tax {
+ my $self = shift;
+ my $total = 0;
+ my @taxlines = qsearch( 'cust_bill_pkg', { 'invnum' => $self->invnum ,
+ 'pkgnum' => 0 } );
+ foreach (@taxlines) { $total += $_->setup; }
+ $total;
+}
+
=item owed
Returns the amount owed (still outstanding) on this invoice, which is charged
-minus all payments (see L<FS::cust_pay>).
+minus all payments (see L<FS::cust_pay>) and applied credits
+(see L<FS::cust_credit_bill>).
=cut
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];
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) .")",
=head1 VERSION
-$Id: cust_bill.pm,v 1.7 2001-04-09 23:05:15 ivan Exp $
+$Id: cust_bill.pm,v 1.9 2001-09-01 21:52:19 jeff Exp $
=head1 BUGS