[freeside-commits] freeside/FS/FS Schema.pm, 1.44.2.8, 1.44.2.9 cust_pay.pm, 1.50, 1.50.2.1

Ivan,,, ivan at wavetail.420.am
Thu Jun 28 18:23:09 PDT 2007


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv26321

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	Schema.pm cust_pay.pm 
Log Message:
add payunique field and dup checking

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.44.2.8
retrieving revision 1.44.2.9
diff -u -d -r1.44.2.8 -r1.44.2.9
--- Schema.pm	26 Jun 2007 15:36:47 -0000	1.44.2.8
+++ Schema.pm	29 Jun 2007 01:23:06 -0000	1.44.2.9
@@ -528,10 +528,11 @@
 	'paymask', 'varchar', 'NULL', $char_d, '', '', 
         'paydate',  'varchar', 'NULL', 10, '', '', 
         'paybatch', 'varchar',   'NULL', $char_d, '', '', #for auditing purposes.
+        'payunique', 'varchar', 'NULL', $char_d, '', '', #separate paybatch "unique" functions from current usage
         'closed',    'char', 'NULL', 1, '', '', 
       ],
       'primary_key' => 'paynum',
-      'unique' => [],
+      'unique' => [ [ 'payunique' ] ],
       'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ],
     },
 

Index: cust_pay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pay.pm,v
retrieving revision 1.50
retrieving revision 1.50.2.1
diff -u -d -r1.50 -r1.50.2.1
--- cust_pay.pm	7 Feb 2007 00:46:28 -0000	1.50
+++ cust_pay.pm	29 Jun 2007 01:23:07 -0000	1.50.2.1
@@ -403,6 +403,7 @@
     || $self->ut_money('paid')
     || $self->ut_numbern('_date')
     || $self->ut_textn('paybatch')
+    || $self->ut_textn('payunique')
     || $self->ut_enum('closed', [ '', 'Y' ])
     || $self->payinfo_check()
   ;
@@ -416,6 +417,13 @@
 
   $self->_date(time) unless $self->_date;
 
+  # UNIQUE index should catch this too, without race conditions, but this
+  # should give a better error message the other 99.9% of the time...
+  if ( length($self->payunique)
+       && qsearchs('cust_pay', { 'payunique' => $self->payunique } ) {
+    return "duplicate transaction"; #well, it *could* be a better error message
+  }
+
   $self->SUPER::check;
 }
 



More information about the freeside-commits mailing list