X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=2ca4b529a968b728e63388929dbc4133acc2a16b;hp=4c1617f0ef29d30078ea828feb264095e84aa9a1;hb=51e148d543a59a3cdec24bfb5ffb839ee7b4ac72;hpb=98ddc878969bb39e576e3bd316f96ff7eeedb750 diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 4c1617f0e..2ca4b529a 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -204,34 +204,55 @@ sub cust_bill_pkg { =item cust_credit -Returns a list consisting of the total previous credited (see -L) and unapplied for this customer, followed by the previous -outstanding credits (FS::cust_credit objects). +Depreciated. See the cust_credited method. + + #Returns a list consisting of the total previous credited (see + #L) and unapplied for this customer, followed by the previous + #outstanding credits (FS::cust_credit objects). =cut sub cust_credit { - my $self = shift; - my $total = 0; - my @cust_credit = sort { $a->_date <=> $b->_date } - grep { $_->credited != 0 && $_->_date < $self->_date } - qsearch('cust_credit', { 'custnum' => $self->custnum } ) - ; - foreach (@cust_credit) { $total += $_->credited; } - $total, @cust_credit; + use Carp; + croak "FS::cust_bill->cust_credit depreciated; see ". + "FS::cust_bill->cust_credit_bill"; + #my $self = shift; + #my $total = 0; + #my @cust_credit = sort { $a->_date <=> $b->_date } + # grep { $_->credited != 0 && $_->_date < $self->_date } + # qsearch('cust_credit', { 'custnum' => $self->custnum } ) + #; + #foreach (@cust_credit) { $total += $_->credited; } + #$total, @cust_credit; } =item cust_pay -Returns all payments (see L) for this invoice. +Depreciated. See the cust_bill_pay method. + +#Returns all payments (see L) for this invoice. =cut sub cust_pay { + use Carp; + croak "FS::cust_bill->cust_pay depreciated; see FS::cust_bill->cust_bill_pay"; + #my $self = shift; + #sort { $a->_date <=> $b->_date } + # qsearch( 'cust_pay', { 'invnum' => $self->invnum } ) + #; +} + +=item cust_bill_pay + +Returns all payment applications (see L) for this invoice. + +=cut + +sub cust_bill_pay { my $self = shift; - sort { $a->_date <=> $b->_date } - qsearch( 'cust_pay', { 'invnum' => $self->invnum } ) - ; + sort { $a->_date <=> $b->date } + qsearch( 'cust_bill_pay', { 'invnum' => $self->invnum } ); } =item cust_credited @@ -265,15 +286,15 @@ sub tax { =item owed Returns the amount owed (still outstanding) on this invoice, which is charged -minus all payments (see L) and applied credits -(see L). +minus all payment applications (see L) and credit +applications (see L). =cut sub owed { my $self = shift; my $balance = $self->charged; - $balance -= $_->paid foreach ( $self->cust_pay ); + $balance -= $_->amount foreach ( $self->cust_bill_pay ); $balance -= $_->amount foreach ( $self->cust_credited ); $balance = sprintf( "%.2f", $balance); } @@ -299,10 +320,9 @@ sub print_text { unless $cust_main->payname; my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance - my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits - my $balance_due = $self->owed + $pr_total - $cr_total; - - # +# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits + #my $balance_due = $self->owed + $pr_total - $cr_total; + my $balance_due = $self->owed + $pr_total; #my @collect = (); #my($description,$amount); @@ -366,22 +386,28 @@ sub print_text { #credits foreach ( $self->cust_credited ) { + + #something more elaborate if $_->amount ne $_->cust_credit->credited ? + push @buf,[ - "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", + "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")", $money_char. sprintf("%10.2f",$_->amount) ]; } - foreach ( @cr_cust_credit ) { - push @buf,[ - "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", - $money_char. sprintf("%10.2f",$_->credited) - ]; - } + #foreach ( @cr_cust_credit ) { + # push @buf,[ + # "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", + # $money_char. sprintf("%10.2f",$_->credited) + # ]; + #} #get & print payments - foreach ( $self->cust_pay ) { + foreach ( $self->cust_bill_pay ) { + + #something more elaborate if $_->amount ne ->cust_pay->paid ? + push @buf,[ - "Payment received ". time2str("%x",$_->_date ), + "Payment received ". time2str("%x",$_->cust_pay->_date ), $money_char. sprintf("%10.2f",$_->paid ) ]; } @@ -389,7 +415,7 @@ sub print_text { #balance due push @buf,['','-----------']; push @buf,['Balance Due', $money_char. - sprintf("%10.2f",$self->owed + $pr_total - $cr_total ) ]; + sprintf("%10.2f", $balance_due ) ]; #setup template variables @@ -463,7 +489,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.9 2001-09-01 21:52:19 jeff Exp $ +$Id: cust_bill.pm,v 1.10 2001-09-02 01:27:10 ivan Exp $ =head1 BUGS @@ -477,8 +503,9 @@ or something similar so the look can be completely customized?) =head1 SEE ALSO -L, L, L, L, -L, schema.html from the base documentation. +L, L, L, L, +L, L, schema.html from the base +documentation. =cut