X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main.cgi;h=6ece5c2bebeb6a56cbe9d9f2d0156ecb9f8c6e5c;hp=492183d11d6ea0ab76c20df749237ac641a65838;hb=dbfb0ae501d5acba37f9348476d94b99a4c92450;hpb=4f8a0bb6d0c789c7e156a446dc61dbe27938a372 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 @@ <% -# +# 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!

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!)\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!!) : - "") . - "Credit #" . + qq!!. + 'Unapplied credit #' . $cref->{crednum} . ", (Balance \$" . - $credited . ")" . ($credited ? "" : "") . + $credit->credited . ") ". $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(), <