[freeside-commits] branch master updated. beff2bed3d06a91072427a15efef08b24c7cc8df

Mark Wells mark at 420.am
Thu Feb 27 17:07:25 PST 2014


The branch, master has been updated
       via  beff2bed3d06a91072427a15efef08b24c7cc8df (commit)
      from  07644a5463751fdaeb0dcd9cc3caf2d19eb877df (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit beff2bed3d06a91072427a15efef08b24c7cc8df
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Feb 27 17:06:41 2014 -0800

    fix payment voiding, fallout from #13971

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 295ddbd..321fb3f 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2235,6 +2235,7 @@ sub tables_hashref {
         'gatewaynum',   'int',     'NULL',  '', '', '',
         #'cust_balance', @money_type,            '', '',
         'paynum',       'int',     'NULL',  '', '', '',
+        'void_paynum',  'int',     'NULL',  '', '', '',
         'jobnum',    'bigint',     'NULL',  '', '', '', 
         'invnum',       'int',     'NULL',  '', '', '',
         'manual',       'char',    'NULL',   1, '', '',
@@ -2257,6 +2258,10 @@ sub tables_hashref {
                           { columns    => [ 'paynum' ],
                             table      => 'cust_pay',
                           },
+                          { columns    => [ 'void_paynum' ],
+                            table      => 'cust_pay_void',
+                            references => [ 'paynum' ],
+                          },
                           { columns    => [ 'jobnum' ],
                             table      => 'queue',
                           },
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 63d7c48..0f643c9 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -414,12 +414,17 @@ sub void {
   } );
   $cust_pay_void->reason(shift) if scalar(@_);
   my $error = $cust_pay_void->insert;
-  if ( $error ) {
-    $dbh->rollback if $oldAutoCommit;
-    return $error;
+
+  my $cust_pay_pending =
+    qsearchs('cust_pay_pending', { paynum => $self->paynum });
+  if ( $cust_pay_pending ) {
+    $cust_pay_pending->set('void_paynum', $self->paynum);
+    $cust_pay_pending->set('paynum', '');
+    $error ||= $cust_pay_pending->replace;
   }
 
-  $error = $self->delete;
+  $error ||= $self->delete;
+
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     return $error;
diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm
index f5de73d..63274b1 100644
--- a/FS/FS/cust_pay_pending.pm
+++ b/FS/FS/cust_pay_pending.pm
@@ -135,6 +135,10 @@ L<FS::payment_gateway> id.
 
 Payment number (L<FS::cust_pay>) of the completed payment.
 
+=item void_paynum
+
+Payment number of the payment if it's been voided.
+
 =item invnum
 
 Invoice number (L<FS::cust_bill>) to try to apply this payment to.
@@ -224,6 +228,7 @@ sub check {
     || $self->ut_foreign_keyn('paynum', 'cust_pay', 'paynum' )
     || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
     || $self->ut_foreign_keyn('invnum', 'cust_bill', 'invnum')
+    || $self->ut_foreign_keyn('void_paynum', 'cust_pay_void', 'paynum' )
     || $self->ut_flag('manual')
     || $self->ut_numbern('discount_term')
     || $self->payinfo_check() #payby/payinfo/paymask/paydate
diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm
index 55b6c67..b2f777b 100644
--- a/FS/FS/cust_pay_void.pm
+++ b/FS/FS/cust_pay_void.pm
@@ -133,12 +133,16 @@ sub unvoid {
     map { $_ => $self->get($_) } fields('cust_pay')
   } );
   my $error = $cust_pay->insert;
-  if ( $error ) {
-    $dbh->rollback if $oldAutoCommit;
-    return $error;
+
+  my $cust_pay_pending =
+    qsearchs('cust_pay_pending', { void_paynum => $self->paynum });
+  if ( $cust_pay_pending ) {
+    $cust_pay_pending->set('paynum', $cust_pay->paynum);
+    $cust_pay_pending->set('void_paynum', '');
+    $error ||= $cust_pay_pending->replace;
   }
 
-  $error = $self->delete;
+  $error ||= $self->delete;
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     return $error;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm           |    5 +++++
 FS/FS/cust_pay.pm         |   13 +++++++++----
 FS/FS/cust_pay_pending.pm |    5 +++++
 FS/FS/cust_pay_void.pm    |   12 ++++++++----
 4 files changed, 27 insertions(+), 8 deletions(-)




More information about the freeside-commits mailing list