X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main.cgi;h=e84fa07568d5600531622840c85df054703ac2c6;hb=e0d75192ce1eefb05689b08961f5009b71063466;hp=d43575a9af6ca4a2e0029f738e08422833c4b924;hpb=c14a267229fc0d6f2d2afdebab3bd34d825df2ef;p=freeside.git diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index d43575a9a..e84fa0756 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 @@ -361,6 +361,8 @@ print qq!

Payment History!. @history = (); #needed for mod_perl :) +my %target = (); + @bills = qsearch('cust_bill',{'custnum'=>$custnum}); foreach $bill (@bills) { my($bref)=$bill->hashref; @@ -386,9 +388,13 @@ foreach $bill (@bills) { $payment->payinfo, $cust_bill_pay->amount, ); - $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4) if $payby eq 'CARD'; + $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4) + if $payby eq 'CARD'; + my $target = "$payby$payinfo"; + $payby =~ s/^BILL$/Check #/ if $payinfo; + $payby =~ s/^(CARD|COMP)$/$1 /; push @history, - "$date\tPayment, Invoice #$invnum ($payby $payinfo)\t\t$paid\t\t"; + "$date\tPayment, Invoice #$invnum ($payby$payinfo)\t\t$paid\t\t\t$target"; } my(@cust_credit_bill)= @@ -438,12 +444,20 @@ foreach my $refund (@refunds) { my @unapplied_payments = grep { $_->unapplied > 0 } qsearch('cust_pay', { 'custnum' => $custnum } ); foreach my $payment (@unapplied_payments) { + my $payby = $payment->payby; + my $payinfo = $payment->payinfo; + #false laziness w/above + $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4) + if $payby eq 'CARD'; + my $target = "$payby$payinfo"; + $payby =~ s/^BILL$/Check #/ if $payinfo; + $payby =~ s/^(CARD|COMP)$/$1 /; push @history, $payment->_date. "\t". ''. 'Unapplied payment #' . - $payment->paynum . "". - "\t\t" . $payment->unapplied . "\t\t"; + $payment->paynum . " ($payby$payinfo)". + "\t\t" . $payment->unapplied . "\t\t\t$target"; } #formatting @@ -463,15 +477,22 @@ END $balance = 0; foreach $item (sort keyfield_numerically @history) { - my($date,$desc,$charge,$payment,$credit,$refund)=split(/\t/,$item); + my($date,$desc,$charge,$payment,$credit,$refund,$target)=split(/\t/,$item); $charge ||= 0; $payment ||= 0; $credit ||= 0; $refund ||= 0; $balance += $charge - $payment; $balance -= $credit - $refund; - - print "",time2str("%D",$date),"", + $balance = sprintf("%.2f", $balance); + $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp + $target = '' unless defined $target; + + print ""; + print qq!! unless $target && $target{$target}++; + print time2str("%D",$date); + print '' if $target && $target{$target} == 1; + print "", "$desc", "", ( $charge ? "\$".sprintf("%.2f",$charge) : '' ), @@ -485,7 +506,7 @@ foreach $item (sort keyfield_numerically @history) { "", ( $refund ? "\$".sprintf("%.2f",$refund) : '' ), "", - "\$" . sprintf("%.2f",$balance), + "\$" . $balance, "", "\n"; }