projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
65d2909
)
add payunique field and dup checking
author
ivan
<ivan>
Fri, 29 Jun 2007 01:23:00 +0000
(
01:23
+0000)
committer
ivan
<ivan>
Fri, 29 Jun 2007 01:23:00 +0000
(
01:23
+0000)
FS/FS/Schema.pm
patch
|
blob
|
history
FS/FS/cust_pay.pm
patch
|
blob
|
history
diff --git
a/FS/FS/Schema.pm
b/FS/FS/Schema.pm
index
771b88b
..
9d4a054
100644
(file)
--- a/
FS/FS/Schema.pm
+++ b/
FS/FS/Schema.pm
@@
-552,10
+552,11
@@
sub tables_hashref {
'paymask', 'varchar', 'NULL', $char_d, '', '',
'paydate', 'varchar', 'NULL', 10, '', '',
'paybatch', 'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
'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',
'closed', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'paynum',
- 'unique' => [],
+ 'unique' => [
[ 'payunique' ]
],
'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ],
},
'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ],
},
diff --git
a/FS/FS/cust_pay.pm
b/FS/FS/cust_pay.pm
index
30333e0
..
dc6bd40
100644
(file)
--- a/
FS/FS/cust_pay.pm
+++ b/
FS/FS/cust_pay.pm
@@
-403,6
+403,7
@@
sub check {
|| $self->ut_money('paid')
|| $self->ut_numbern('_date')
|| $self->ut_textn('paybatch')
|| $self->ut_money('paid')
|| $self->ut_numbern('_date')
|| $self->ut_textn('paybatch')
+ || $self->ut_textn('payunique')
|| $self->ut_enum('closed', [ '', 'Y' ])
|| $self->payinfo_check()
;
|| $self->ut_enum('closed', [ '', 'Y' ])
|| $self->payinfo_check()
;
@@
-416,6
+417,13
@@
sub check {
$self->_date(time) unless $self->_date;
$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;
}
$self->SUPER::check;
}