diff options
author | ivan <ivan> | 2001-09-02 07:49:52 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-09-02 07:49:52 +0000 |
commit | dbfb0ae501d5acba37f9348476d94b99a4c92450 (patch) | |
tree | 29850d2a9d94808efb9f2a6edcfd4477701ea8f3 | |
parent | 4f8a0bb6d0c789c7e156a446dc61dbe27938a372 (diff) |
things are starting to work again, sorta.
-rw-r--r-- | FS/FS/cust_bill_pay.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_credit_bill.pm | 4 | ||||
-rw-r--r-- | FS/FS/cust_credit_refund.pm | 4 | ||||
-rwxr-xr-x | httemplate/edit/cust_credit_bill.cgi | 6 | ||||
-rwxr-xr-x | httemplate/view/cust_main.cgi | 76 |
5 files changed, 62 insertions, 33 deletions
diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm index ac82c542d..921c0255c 100644 --- a/FS/FS/cust_bill_pay.pm +++ b/FS/FS/cust_bill_pay.pm @@ -162,8 +162,9 @@ sub check { ; return $error if $error; - $self->_date(time) unless $self->_date; + return "amount must be > 0" if $self->amount == 0; + $self->_date(time) unless $self->_date; ''; #no error } @@ -194,7 +195,7 @@ sub cust_bill { =head1 VERSION -$Id: cust_bill_pay.pm,v 1.6 2001-09-02 05:38:13 ivan Exp $ +$Id: cust_bill_pay.pm,v 1.7 2001-09-02 07:49:52 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_credit_bill.pm b/FS/FS/cust_credit_bill.pm index 0892f7984..58cc78965 100644 --- a/FS/FS/cust_credit_bill.pm +++ b/FS/FS/cust_credit_bill.pm @@ -107,6 +107,8 @@ sub check { ; return $error if $error; + return "amount must be > 0" if $self->amount == 0; + return "Unknown credit" unless my $cust_credit = qsearchs( 'cust_credit', { 'crednum' => $self->crednum } ); @@ -141,7 +143,7 @@ sub cust_credit { =head1 VERSION -$Id: cust_credit_bill.pm,v 1.3 2001-09-02 01:27:11 ivan Exp $ +$Id: cust_credit_bill.pm,v 1.4 2001-09-02 07:49:52 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_credit_refund.pm b/FS/FS/cust_credit_refund.pm index 4c5195717..fb09a42d8 100644 --- a/FS/FS/cust_credit_refund.pm +++ b/FS/FS/cust_credit_refund.pm @@ -147,6 +147,8 @@ sub check { ; return $error if $error; + return "amount must be > 0" if $self->amount == 0; + $self->_date(time) unless $self->_date; return "unknown cust_credit.crednum: ". $self->crednum @@ -170,7 +172,7 @@ sub cust_refund { =head1 VERSION -$Id: cust_credit_refund.pm,v 1.3 2001-09-02 05:38:13 ivan Exp $ +$Id: cust_credit_refund.pm,v 1.4 2001-09-02 07:49:52 ivan Exp $ =head1 BUGS diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index df495a668..c4cd34eab 100755 --- a/httemplate/edit/cust_credit_bill.cgi +++ b/httemplate/edit/cust_credit_bill.cgi @@ -1,5 +1,5 @@ <% -#<!-- $Id: cust_credit_bill.cgi,v 1.1 2001-09-01 21:52:20 jeff Exp $ --> +#<!-- $Id: cust_credit_bill.cgi,v 1.2 2001-09-02 07:49:52 ivan Exp $ --> use strict; use vars qw( $cgi $query $custnum $invnum $otaker $p1 $crednum $_date $amount $reason $cust_credit ); @@ -40,7 +40,7 @@ $p1 = popurl(1); print $cgi->header( '-expires' => 'now' ), header("Apply Credit", ''); print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" + "</FONT><BR><BR>" if $cgi->param('error'); print <<END; <FORM ACTION="${p1}process/cust_credit_bill.cgi" METHOD=POST> @@ -52,7 +52,7 @@ die unless $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ); print qq!Credit #<B>!, $crednum, qq!</B><INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!; print qq!\nInvoice # <SELECT NAME="invnum" SIZE=1>!; -foreach $_ (grep $_->owed, qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } ) ) { +foreach $_ (grep $_->owed != 0, qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } ) ) { print "<OPTION", (($_->invnum eq $invnum) ? " SELECTED" : ""), qq! VALUE="! .$_->invnum. qq!">!. $_->invnum. qq! (! . $_->owed . qq!)!; } diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 492183d11..6ece5c2be 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -1,5 +1,5 @@ <% -#<!-- $Id: cust_main.cgi,v 1.6 2001-09-01 21:52:20 jeff Exp $ --> +#<!-- $Id: cust_main.cgi,v 1.7 2001-09-02 07:49:52 ivan Exp $ --> use strict; use vars qw ( $cgi $query $custnum $cust_main $hashref $agent $referral @@ -20,6 +20,8 @@ use FS::part_referral; use FS::agent; use FS::cust_main; use FS::cust_refund; +use FS::cust_bill_pay; +use FS::cust_credit_bill; $cgi = new CGI; &cgisuidsetup($cgi); @@ -329,6 +331,8 @@ print qq!<BR><BR><A NAME="history">Payment History!, # major problem: this whole thing is way too sloppy. # minor problem: the description lines need better formatting. +# SHOULD SHOW UNAPPLIED PAYMENTS (now show unapplied credits) + @history = (); #needed for mod_perl :) @bills = qsearch('cust_bill',{'custnum'=>$custnum}); @@ -340,46 +344,66 @@ foreach $bill (@bills) { qq! (Balance \$! . $bill->owed . qq!)</A>\t! . $bref->{charged} . qq!\t\t\t!; - my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } ); - my($payment); - foreach $payment (@payments) { - my($date,$invnum,$payby,$payinfo,$paid)=($payment->getfield('_date'), - $payment->getfield('invnum'), - $payment->getfield('payby'), - $payment->getfield('payinfo'), - $payment->getfield('paid'), + my(@cust_bill_pay)=qsearch('cust_bill_pay',{'invnum'=> $bref->{invnum} } ); +# my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } ); +# my($payment); +# foreach $payment (@payments) { + foreach my $cust_bill_pay (@cust_bill_pay) { + my $payment = $cust_bill_pay->cust_pay; + my($date,$invnum,$payby,$payinfo,$paid)=($payment->_date, + $cust_bill_pay->invnum, + $payment->payby, + $payment->payinfo, + $cust_bill_pay->amount, ); push @history, "$date\tPayment, Invoice #$invnum ($payby $payinfo)\t\t$paid\t\t"; } + + my(@cust_credit_bill)= + qsearch('cust_credit_bill', { 'invnum'=> $bref->{invnum} } ); + foreach my $cust_credit_bill (@cust_credit_bill) { + my $cust_credit = $cust_credit_bill->cust_credit; + my($date, $invnum, $crednum, $amount, $reason ) = ( + $cust_credit->_date, + $cust_credit_bill->invnum, + $cust_credit_bill->crednum, + $cust_credit_bill->amount, + $cust_credit->reason, + ); + push @history, + "$date\tCredit #$crednum, Invoice #$invnum $reason\t\t\t$amount\t"; + } } -@credits = qsearch('cust_credit',{'custnum'=>$custnum}); +@credits = grep $_->credited, qsearch('cust_credit',{'custnum'=>$custnum}); foreach $credit (@credits) { my($cref)=$credit->hashref; - my($credited)=$credit->credited; push @history, $cref->{_date} . "\t" . - ($credited ? - (qq!<A HREF="! . popurl(2). qq!edit/cust_credit_bill.cgi?!. $cref->{crednum} . qq!">!) : - "") . - "Credit #" . + qq!<A HREF="! . popurl(2). qq!edit/cust_credit_bill.cgi?!. $cref->{crednum} . qq!">!. + '<font color="#ff0000">Unapplied credit #' . $cref->{crednum} . ", (Balance \$" . - $credited . ")" . ($credited ? "</A>" : "") . + $credit->credited . ")</font></A> ". $cref->{reason} . "\t\t\t" . $cref->{amount} . "\t"; +} - my(@refunds)=qsearch('cust_refund',{'crednum'=> $cref->{crednum} } ); - my($refund); - foreach $refund (@refunds) { - my($rref)=$refund->hashref; - push @history, - $rref->{_date} . "\tRefund, Credit #" . $rref->{crednum} . " (" . - $rref->{payby} . " " . $rref->{payinfo} . ") by " . - $rref->{otaker} . " - ". $rref->{reason} . "\t\t\t\t" . - $rref->{refund}; - } +my(@refunds)=qsearch('cust_refund',{'custnum'=> $custnum } ); +my($refund); +foreach $refund (@refunds) { + my($rref)=$refund->hashref; + my($refundnum) = ( + $refund->refundnum, + ); + + push @history, + $rref->{_date} . "\tRefund #$refundnum, (" . + $rref->{payby} . " " . $rref->{payinfo} . ") by " . + $rref->{otaker} . " - ". $rref->{reason} . "\t\t\t\t" . + $rref->{refund}; } + #formatting print &table(), <<END; <TR> |