X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main%2Fpayment_history.html;h=482136fa10aab2c9fa1f82a784fa88cb97bc6698;hb=b8ec621c59747a1c2fcd7fbd603d0c6de41e7df5;hp=0eef2ad1cf8b628423b104407ae106736c1af9c1;hpb=bbf01f2a628d15c0ca557cf68235f25d6d233ee7;p=freeside.git diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 0eef2ad1c..482136fa1 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -4,6 +4,8 @@ my $conf = new FS::Conf; + my $curuser = $FS::CurrentUser::CurrentUser; + my @payby = grep /\w/, $conf->config('payby'); #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) @@ -16,51 +18,64 @@

Payment History
-<% if ( $payby{'BILL'} ) { %> +<% if ( $payby{'BILL'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> Post check payment <% } %> -<% if ( $payby{'CASH'} ) { %> +<% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> Post cash payment <% } %> -<% if ( $payby{'WEST'} ) { %> +<% if ( $payby{'WEST'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> Post Western Union payment <% } %> -<% if ( $payby{'CARD'} || $payby{'DCRD'} ) { %> +<% if ( ( $payby{'CARD'} || $payby{'DCRD'} ) + && $curuser->access_right('Process payment') + ) { +%> <%= $s++ ? ' | ' : '' %> Process credit card payment <% } %> -<% if ( $payby{'CHEK'} || $payby{'DCHK'} ) { %> +<% if ( ( $payby{'CHEK'} || $payby{'DCHK'} ) + && $curuser->access_right('Process payment') + ) { +%> <%= $s++ ? ' | ' : '' %> Process electronic check (ACH) payment <% } %> -<% if ( $payby{'MCRD'} ) { %> +<% if ( $payby{'MCRD'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> Post manual credit card payment <% } %> -
Post credit
+<% if ( $curuser->access_right('Post credit') ) { %> + + Post credit + +
+ +<% } %> + <% #get payment history my @history = (); @@ -72,11 +87,14 @@ foreach my $cust_bill ($cust_main->cust_bill) { : ''; my $post = ( $cust_bill->owed > 0 ) ? '' : ''; my $invnum = $cust_bill->invnum; + my $link = $curuser->access_right('View invoices') + ? qq!! + : ''; push @history, { 'date' => $cust_bill->_date, - 'desc' => qq!!. $pre. + 'desc' => $link. $pre. "Invoice #$invnum (Balance \$". $cust_bill->owed. ')'. - $post. '', + $post. ( $link ? '' : '' ), 'charge' => $cust_bill->charged, }; } @@ -115,8 +133,10 @@ foreach my $cust_pay ($cust_main->cust_pay) { #completely unapplied $pre = 'Unapplied '; $post = ''; - $apply = qq! (apply)'; + $apply = qq! (apply)!; + } elsif ( scalar(@cust_bill_pay) == 1 && scalar(@cust_pay_refund) == 0 && $cust_pay->unapplied == 0 ) { @@ -141,7 +161,7 @@ foreach my $cust_pay ($cust_main->cust_pay) { } elsif ( $app->isa('FS::cust_pay_refund') ) { $desc .= '  '. '$'. $app->amount. - ' refunded on'. time2str("%D", $app->_date). + ' refunded on '. time2str("%D", $app->_date). '
'; } else { die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund"; @@ -151,8 +171,9 @@ foreach my $cust_pay ($cust_main->cust_pay) { $desc .= '  '. '$'. $cust_pay->unapplied. ' unapplied'. - qq! (apply)'. + qq! (apply)!. '
'; } } @@ -163,6 +184,7 @@ foreach my $cust_pay ($cust_main->cust_pay) { && $cust_pay->payby =~ /^(CARD|CHEK)$/ && time-$cust_pay->_date < $refund_days*86400 && $cust_pay->unrefunded > 0 + && $curuser->access_right('Refund payment') ) { $refund = qq! (cust_pay) { my $void = ''; if ( $cust_pay->closed !~ /^Y/i - && ( $cust_pay->payby ne 'CARD' || $conf->exists('cc-void') ) - && ( $cust_pay->payby ne 'CHEK' || $conf->exists('echeck-void') ) - ) { + && ( ( $cust_pay->payby eq 'CARD' + && $curuser->access_right('Credit card void') + ) + || ( $cust_pay->payby eq 'CHEK' + && $curuser->access_right('Echeck void') + ) + || ( $cust_pay->payby !~ /^(CARD|CHEK)$/ + && $curuser->access_right('Regular void') + ) + ) + ) + { $void = qq! (cust_pay) { } my $delete = ''; - if ( $cust_pay->closed !~ /^Y/i && $conf->exists('deletepayments') ) { + if ( $cust_pay->closed !~ /^Y/i + && $conf->exists('deletepayments') + && $curuser->access_right('Delete payment') + ) + { $delete = qq! (cust_pay) { my $unapply = ''; if ( $cust_pay->closed !~ /^Y/i - && $conf->exists('unapplypayments') - && scalar(@cust_bill_pay) ) { + && scalar(@cust_bill_pay) + && $curuser->access_right('Unapply payment') + ) + { $unapply = qq! (cust_pay_void) { $payby =~ s/^(CARD|COMP)$/$1 /; my $info = $payby ? " ($payby$payinfo)" : ''; + my $unvoid = ''; + if ( $cust_pay_void->closed !~ /^Y/i + && $curuser->access_right('Unvoid') + ) + { + $unvoid = qq! (unvoid)!; + } + push @history, { 'date' => $cust_pay_void->_date, 'desc' => "Payment $info voided ". time2str("%D", $cust_pay_void->void_date). - " by ". $cust_pay_void->otaker. '', + " by ". $cust_pay_void->otaker. ''. $unvoid, 'void_payment' => $cust_pay_void->paid, }; @@ -251,8 +304,9 @@ foreach my $cust_credit ($cust_main->cust_credit) { #completely unapplied $pre = 'Unapplied '; $post = ''; - $apply = qq! (apply)'; + $apply = qq! (apply)!; } elsif ( scalar(@cust_credit_bill) == 1 && scalar(@cust_credit_refund) == 0 && $cust_credit->credited == 0 ) { @@ -277,7 +331,7 @@ foreach my $cust_credit ($cust_main->cust_credit) { } elsif ( $app->isa('FS::cust_credit_refund') ) { $desc .= '  '. '$'. $app->amount. - ' refunded on'. time2str("%D", $app->_date). + ' refunded on '. time2str("%D", $app->_date). '
'; } else { die "$app is not a FS::cust_credit_bill or a FS::cust_credit_refund"; @@ -286,14 +340,23 @@ foreach my $cust_credit ($cust_main->cust_credit) { if ( $cust_credit->credited > 0 ) { $desc .= '  $'. $cust_credit->credited. ' unapplied'. - qq! (apply)'. + qq! (apply)!. '
'; } } # my $delete = ''; - if ( $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') ) { + if ( $cust_credit->closed !~ /^Y/i + + #s'pose deleting a credit isn't bad like deleting a payment + # and this needs to be generally available until we have credit voiding.. + #&& $conf->exists('deletecredits') + + && $curuser->access_right('Delete credit') + ) + { $delete = qq! (!. @@ -302,8 +365,10 @@ foreach my $cust_credit ($cust_main->cust_credit) { my $unapply = ''; if ( $cust_credit->closed !~ /^Y/i - && $conf->exists('unapplycredits') - && scalar(@cust_credit_bill) ) { + && scalar(@cust_credit_bill) + && $curuser->access_right('Unapply credit') + ) + { $unapply = qq! (!. @@ -313,7 +378,10 @@ foreach my $cust_credit ($cust_main->cust_credit) { push @history, { 'date' => $cust_credit->_date, 'desc' => $pre. "Credit$post by ". $cust_credit->otaker. - ' ('. $cust_credit->reason. ')'. + ( $cust_credit->reason + ? ' ('. $cust_credit->reason. ')' + : '' + ). "$desc$apply$delete$unapply", 'credit' => $cust_credit->amount, }; @@ -342,15 +410,21 @@ foreach my $cust_refund ($cust_main->cust_refund) { %> -<%= table() %> +<%= include("/elements/table-grid.html") %> + +<% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor = ''; +%> + - Date - Description - Charge - Payment - In-house
Credit
- Refund - Balance + Date + Description + Charge + Payment + In-house
Credit
+ Refund + Balance <% @@ -360,6 +434,12 @@ my %target; my $balance = 0; foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + my $charge = exists($item->{'charge'}) ? sprintf('$%.2f', $item->{'charge'}) : ''; @@ -388,7 +468,7 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { %> - + <% unless ( !$target || $target{$target}++ ) { %>
<% } %> @@ -398,12 +478,24 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { <% } %> - <%= $item->{'desc'} %> - <%= $charge %> - <%= $payment %> - <%= $credit %> - <%= $refund %> - <%= $showbalance %> + + <%= $item->{'desc'} %> + + + <%= $charge %> + + + <%= $payment %> + + + <%= $credit %> + + + <%= $refund %> + + + <%= $showbalance %> + <% } %>