diff options
| author | ivan <ivan> | 2001-09-02 01:27:11 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2001-09-02 01:27:11 +0000 | 
| commit | 51e148d543a59a3cdec24bfb5ffb839ee7b4ac72 (patch) | |
| tree | 49ef3d509b0af99b7daaa6668d31b2e2065045f6 /FS | |
| parent | 98ddc878969bb39e576e3bd316f96ff7eeedb750 (diff) | |
more udpates for the new world of unapplied stuff.  yay.
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/cust_bill.pm | 97 | ||||
| -rw-r--r-- | FS/FS/cust_bill_pay.pm | 19 | ||||
| -rw-r--r-- | FS/FS/cust_credit.pm | 33 | ||||
| -rw-r--r-- | FS/FS/cust_credit_bill.pm | 15 | ||||
| -rw-r--r-- | FS/FS/cust_credit_refund.pm | 19 | ||||
| -rw-r--r-- | FS/FS/cust_main.pm | 5 | ||||
| -rw-r--r-- | FS/FS/cust_refund.pm | 4 | 
7 files changed, 139 insertions, 53 deletions
| 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<FS::cust_credit>) 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<FS::cust_credit>) 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<FS::cust_pay>) for this invoice. +Depreciated.  See the cust_bill_pay method. + +#Returns all payments (see L<FS::cust_pay>) 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<FS::cust_bill_pay>) 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<FS::cust_pay>) and applied credits -(see L<FS::cust_credit_bill>). +minus all payment applications (see L<FS::cust_bill_pay>) and credit +applications (see L<FS::cust_credit_bill>).  =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<FS::Record>, L<FS::cust_main>, L<FS::cust_pay>, L<FS::cust_bill_pkg>, -L<FS::cust_credit>, schema.html from the base documentation. +L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill_pay>, L<FS:;cust_pay>, +L<FS::cust_bill_pkg>, L<FS::cust_bill_credit>, schema.html from the base +documentation.  =cut diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm index e7040d96b..6d08b59c8 100644 --- a/FS/FS/cust_bill_pay.pm +++ b/FS/FS/cust_bill_pay.pm @@ -3,7 +3,8 @@ package cust_bill_pay;  use strict;  use vars qw( @ISA );  use FS::Record qw( qsearch qsearchs dbh ); -#use FS::cust_bill +use FS::cust_bill; +use FS::cust_pay;  @ISA = qw( FS::Record ); @@ -167,17 +168,29 @@ sub check {    ''; #no error  } +=item cust_pay  + +Returns the payment (see L<FS::cust_pay>) + +=cut + +sub cust_pay { +  my $self = shift; +  qsearchs( 'cust_pay', { 'invnum' => $self->invnum } ); +} +  =back  =head1 VERSION -$Id: cust_bill_pay.pm,v 1.2 2001-09-01 21:55:06 jeff Exp $ +$Id: cust_bill_pay.pm,v 1.3 2001-09-02 01:27:11 ivan Exp $  =head1 BUGS  Delete and replace methods. -cust_credit_bill isn't checked yet (uncomment around line 111) +the checks for over-applied payments could be better done like the ones in +cust_bill_credit  =head1 SEE ALSO diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index ec3a7ce26..1f792daa6 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -122,14 +122,32 @@ sub check {  =item cust_refund -Returns all refunds (see L<FS::cust_refund>) for this credit. +Depreciated.  See the cust_credit_refund method. + +#Returns all refunds (see L<FS::cust_refund>) for this credit.  =cut  sub cust_refund { +  use Carp; +  croak "FS::cust_credit->cust_pay depreciated; see ". +        "FS::cust_credit->cust_credit_refund"; +  #my $self = shift; +  #sort { $a->_date <=> $b->_date } +  #  qsearch( 'cust_refund', { 'crednum' => $self->crednum } ) +  #; +} + +=item cust_credit_refund + +Returns all refund applications (see L<FS::cust_credit_refund>) for this credit. + +=cut + +sub cust_credit_refund {    my $self = shift;    sort { $a->_date <=> $b->_date } -    qsearch( 'cust_refund', { 'crednum' => $self->crednum } ) +    qsearch( 'cust_credit_refund', { 'crednum' => $self->crednum } )    ;  } @@ -150,15 +168,15 @@ sub cust_credit_bill {  =item credited  Returns the amount of this credit that is still outstanding; which is -amount minus all refunds (see L<FS::cust_refund>) and applications to -invoices (see L<FS::cust_credit_bill>). +amount minus all refund applications (see L<FS::cust_credit_refund>) and +applications to invoices (see L<FS::cust_credit_bill>).  =cut  sub credited {    my $self = shift;    my $amount = $self->amount; -  $amount -= $_->refund foreach ( $self->cust_refund ); +  $amount -= $_->amount foreach ( $self->cust_credit_refund );    $amount -= $_->amount foreach ( $self->cust_credit_bill );    sprintf( "%.2f", $amount );  } @@ -167,7 +185,7 @@ sub credited {  =head1 VERSION -$Id: cust_credit.pm,v 1.9 2001-09-01 21:52:19 jeff Exp $ +$Id: cust_credit.pm,v 1.11 2001-09-02 07:49:52 ivan Exp $  =head1 BUGS @@ -175,7 +193,8 @@ The delete method.  =head1 SEE ALSO -L<FS::Record>, L<FS::cust_refund>, L<FS::cust_bill>, schema.html from the base +L<FS::Record>, L<FS::cust_credit_refund>, L<FS::cust_refund>, +L<FS::cust_credit_bill> L<FS::cust_bill>, schema.html from the base  documentation.  =cut diff --git a/FS/FS/cust_credit_bill.pm b/FS/FS/cust_credit_bill.pm index d6c4f6c4b..0892f7984 100644 --- a/FS/FS/cust_credit_bill.pm +++ b/FS/FS/cust_credit_bill.pm @@ -5,7 +5,7 @@ use vars qw( @ISA );  use FS::UID qw( getotaker );  use FS::Record qw( qsearch qsearchs );  use FS::cust_main; -use FS::cust_refund; +#use FS::cust_refund;  use FS::cust_credit;  use FS::cust_bill; @@ -126,11 +126,22 @@ sub check {    ''; #no error  } +=item sub cust_credit + +Returns the credit (see L<FS::cust_credit>) + +=cut + +sub cust_credit { +  my $self = shift; +  qsearchs( 'cust_credit', { 'crednum' => $self->crednum } ); +} +  =back  =head1 VERSION -$Id: cust_credit_bill.pm,v 1.2 2001-09-01 22:18:38 ivan Exp $ +$Id: cust_credit_bill.pm,v 1.3 2001-09-02 01:27:11 ivan Exp $  =head1 BUGS diff --git a/FS/FS/cust_credit_refund.pm b/FS/FS/cust_credit_refund.pm index f366eb147..200e34e55 100644 --- a/FS/FS/cust_credit_refund.pm +++ b/FS/FS/cust_credit_refund.pm @@ -4,7 +4,8 @@ use strict;  use vars qw( @ISA );  use FS::Record qw( qsearch qsearchs dbh );  #use FS::UID qw(getotaker); -#use FS::cust_credit +use FS::cust_credit; +use FS::cust_refund;  @ISA = qw( FS::Record ); @@ -154,16 +155,30 @@ sub check {    ''; #no error  } +=item cust_refund + +Returns the refund (see L<FS::cust_refund>) + +=cut + +sub cust_refund { +  my $self = shift; +  qsearchs( 'cust_refund', { 'refundnum' => $self->refundnum } ); +} +  =back  =head1 VERSION -$Id: cust_credit_refund.pm,v 1.1 2001-09-01 20:11:07 ivan Exp $ +$Id: cust_credit_refund.pm,v 1.2 2001-09-02 01:27:11 ivan Exp $  =head1 BUGS  Delete and replace methods. +the checks for over-applied refunds could be better done like the ones in +cust_bill_credit +  =head1 SEE ALSO  L<FS::cust_credit>, L<FS::cust_refund>, L<FS::Record>, schema.html from the diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index bd1f212b3..2158289d8 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -28,7 +28,7 @@ use FS::part_referral;  use FS::cust_main_county;  use FS::agent;  use FS::cust_main_invoice; -use FS::cust_credit_bill; +#use FS::cust_credit_bill;  use FS::prepay_credit;  @ISA = qw( FS::Record ); @@ -956,6 +956,7 @@ sub collect {      next unless $cust_bill->owed > 0; +    # ??????????      next if qsearchs( 'cust_pay_batch', { 'invnum' => $cust_bill->invnum } );      warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ", amount $amount, total_owed $total_owed)" if $Debug; @@ -1450,7 +1451,7 @@ sub rebuild_fuzzyfiles {  =head1 VERSION -$Id: cust_main.pm,v 1.25 2001-09-01 22:28:51 jeff Exp $ +$Id: cust_main.pm,v 1.26 2001-09-02 01:27:11 ivan Exp $  =head1 BUGS diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 8e4ef0d4e..7eeacbfce 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -3,7 +3,7 @@ package FS::cust_refund;  use strict;  use vars qw( @ISA );  use Business::CreditCard; -use FS::Record qw( qsearchs dbh ); +use FS::Record qw( dbh );  use FS::UID qw(getotaker);  use FS::cust_credit;  use FS::cust_credit_refund; @@ -189,7 +189,7 @@ sub check {  =head1 VERSION -$Id: cust_refund.pm,v 1.4 2001-09-01 20:11:07 ivan Exp $ +$Id: cust_refund.pm,v 1.5 2001-09-02 01:27:11 ivan Exp $  =head1 BUGS | 
