display any pending payments in customer view, RT10270
authorlevinse <levinse>
Fri, 5 Nov 2010 18:46:25 +0000 (18:46 +0000)
committerlevinse <levinse>
Fri, 5 Nov 2010 18:46:25 +0000 (18:46 +0000)
httemplate/view/cust_main/payment_history.html
httemplate/view/cust_main/payment_history/pending_payment.html [new file with mode: 0644]

index 111810e..5586897 100644 (file)
@@ -1,7 +1,7 @@
 %# payment links
 
 % my $s = 0;
-% if ( $payby{'BILL'} && $curuser->access_right(['Post payment', 'Post check payment' ]) ) { 
+% if ( $payby{'BILL'} && $curuser->access_right('Post payment') ) { 
   <% $s++ ? ' | ' : '' %>
   <% include('/elements/popup_link-cust_main.html',
                'label'       => 'Enter check payment',
@@ -14,7 +14,7 @@
   %>
 % } 
 
-% if ( $payby{'CASH'} && $curuser->access_right(['Post payment', 'Post cash payment']) ) { 
+% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { 
   <% $s++ ? ' | ' : '' %>
   <% include('/elements/popup_link-cust_main.html',
                'label'       => 'Enter cash payment',
@@ -33,7 +33,7 @@
 % } 
 
 % if ( ( $payby{'CARD'} || $payby{'DCRD'} )
-%        && $curuser->access_right(['Process payment', 'Process credit card payment'])
+%        && $curuser->access_right('Process payment')
 %        && ! $cust_main->is_encrypted($cust_main->payinfo)
 %      ) {
   <% $s++ ? ' | ' : '' %>
@@ -41,7 +41,7 @@
 % } 
 
 % if ( ( $payby{'CHEK'} || $payby{'DCHK'} )
-%        && $curuser->access_right(['Process payment', 'Process Echeck payment'])
+%        && $curuser->access_right('Process payment')
 %        && ! $cust_main->is_encrypted($cust_main->payinfo)
 %      ) {
   <% $s++ ? ' | ' : '' %>
@@ -73,7 +73,7 @@
 %# refund links
 
 % $s = 0;
-% if ( $payby{'BILL'} && $curuser->access_right(['Post refund', 'Post check refund']) ) { 
+% if ( $payby{'BILL'} && $curuser->access_right('Post refund') ) { 
   <% $s++ ? ' | ' : '' %>
   <% include('/elements/popup_link-cust_main.html',
                'label'       => 'Enter check refund',
@@ -86,7 +86,7 @@
   %>
 % } 
 
-% if ( $payby{'CASH'} && $curuser->access_right(['Post refund', 'Post cash refund']) ) { 
+% if ( $payby{'CASH'} && $curuser->access_right('Post refund') ) { 
   <% $s++ ? ' | ' : '' %>
   <% include('/elements/popup_link-cust_main.html',
                'label'       => 'Enter cash refund',
@@ -412,6 +412,16 @@ foreach my $cust_pay ($cust_main->cust_pay) {
   };
 }
 
+#pending payments 
+foreach my $cust_pay_pending ($cust_main->cust_pay_pending) {
+  push @history, {
+    'date'    => $cust_pay_pending->_date,
+    'desc'    => include('payment_history/pending_payment.html', $cust_pay_pending, %opt ),
+    'void_payment' => $cust_pay_pending->paid, 
+  };
+}
+
+
 #voided payments
 foreach my $cust_pay_void ($cust_main->cust_pay_void) {
   push @history, {
diff --git a/httemplate/view/cust_main/payment_history/pending_payment.html b/httemplate/view/cust_main/payment_history/pending_payment.html
new file mode 100644 (file)
index 0000000..40805b1
--- /dev/null
@@ -0,0 +1,61 @@
+<b><font size="+1" color="#FF0000">Pending payment </font></b> <% "$info $status ($link)" %>
+<%init>
+
+my( $cust_pay_pending, %opt ) = @_;
+
+my $conf = new FS::Conf;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+my $payby = $cust_pay_pending->payby;
+
+my $payinfo;
+if ( $payby eq 'CARD' ) {
+  $payinfo = $cust_pay_pending->paymask;
+} elsif ( $payby eq 'CHEK' ) {
+  my( $account, $aba ) = split('@', $cust_pay_pending->paymask );
+  $payinfo = "ABA $aba, Acct #$account";
+} else {
+  $payinfo = $cust_pay_pending->payinfo;
+}
+
+my $target = "$payby$payinfo";
+$payby =~ s/^BILL$/Check #/ if $payinfo;
+$payby =~ s/^CHEK$/Electronic check /;
+$payby =~ s/^PREP$/Prepaid card /;
+$payby =~ s/^CARD$/Credit card #/; 
+$payby =~ s/^COMP$/Complimentary by /; 
+$payby =~ s/^CASH$/Cash/;
+$payby =~ s/^WEST$/Western Union/;
+$payby =~ s/^MCRD$/Manual credit card/;
+$payby =~ s/^BILL$//;
+my $info = $payby ? "($payby$payinfo)" : '';
+
+my %statusaction = (
+  'new'        => 'delete',
+  'pending'    => 'complete',
+  'captured'   => 'capture',
+);
+
+my $edit_pending =
+  $FS::CurrentUser::CurrentUser->access_right('Edit customer pending payments');
+
+my $status = "Status: ".$cust_pay_pending->status;
+
+my $action = $statusaction{$cust_pay_pending->status};
+
+my $link = "";
+if ( $action && $edit_pending ) {
+    $link = include('/elements/popup_link.html',
+              'action' => $p. 'edit/cust_pay_pending.html'.
+                            '?paypendingnum='. $cust_pay_pending->paypendingnum.
+                            ";action=$action",
+              'label'  => $action,
+              'color'  => '#ff0000',
+              'width'  => 655,
+              'height' => ( $action eq 'delete' ? 480 : 575 ),
+              'actionlabel' => ucfirst($action). ' pending payment',
+           );
+}
+
+</%init>