From 33aeb33a7fafaf099c679c6d7150b54b99e4810f Mon Sep 17 00:00:00 2001
From: ivan <ivan>
Date: Thu, 6 Oct 2005 07:34:58 +0000
Subject: [PATCH] add cc-void option

---
 FS/FS/Conf.pm                                  |  7 +++++++
 FS/FS/cust_pay_refund.pm                       | 16 ++++++++--------
 httemplate/view/cust_main/payment_history.html |  4 ++--
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 237ab1e58..0bf1afeeb 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1504,6 +1504,13 @@ httemplate/docs/config.html
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'cc-void',
+    'section'     => 'billing',
+    'description' => 'Enable local-only voiding of credit card payments in addition to refunds against the payment gateway',
+    'type'        => 'checkbox',
+  },
+
   {
     'key'         => 'address2-search',
     'section'     => 'UI',
diff --git a/FS/FS/cust_pay_refund.pm b/FS/FS/cust_pay_refund.pm
index af25f1774..15e0e533a 100644
--- a/FS/FS/cust_pay_refund.pm
+++ b/FS/FS/cust_pay_refund.pm
@@ -138,26 +138,26 @@ sub check {
   $self->SUPER::check;
 }
 
-=item sub cust_credit
+=item sub cust_pay
 
-Returns the credit (see L<FS::cust_credit>)
+Returns the payment (see L<FS::cust_pay>)
 
 =cut
 
-sub cust_credit {
+sub cust_pay {
   my $self = shift;
-  qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
+  qsearchs( 'cust_pay', { 'paynum' => $self->paynum } );
 }
 
-=item cust_bill 
+=item cust_refund
 
-Returns the invoice (see L<FS::cust_bill>)
+Returns the refund (see L<FS::cust_refund>)
 
 =cut
 
-sub cust_bill {
+sub cust_refund {
   my $self = shift;
-  qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
+  qsearchs( 'cust_refund', { 'refundnum' => $self->refundnum } );
 }
 
 =back
diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html
index db01ebbcf..6c475c5f2 100644
--- a/httemplate/view/cust_main/payment_history.html
+++ b/httemplate/view/cust_main/payment_history.html
@@ -118,14 +118,14 @@ foreach my $cust_pay ($cust_main->cust_pay) {
 
   my $void = '';
   if (    $cust_pay->closed !~ /^Y/i
-       && $cust_pay->payby ne 'CARD'
+       && ( $cust_pay->payby ne 'CARD' || $conf->exists('cc-void')     )
        && ( $cust_pay->payby ne 'CHEK' || $conf->exists('echeck-void') ) 
      ) {
     $void = qq! (<A HREF="javascript:areyousure('!.
             qq!${p}misc/void-cust_pay.cgi?!. $cust_pay->paynum.
             qq!', 'Are you sure you want to void this payment?')"!.
             qq! TITLE="Void this payment from the database!.
-              ( $cust_pay->payby eq 'CHEK'
+              ( $cust_pay->payby =~ /^(CARD|CHEK)$/
                 ? ' (do not send anything to the payment gateway)'
                 : '' 
               ). '"'.
-- 
2.20.1