my $error =
$self->ut_numbern('paypendingnum')
- || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+ || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
|| $self->ut_money('paid')
|| $self->ut_numbern('_date')
|| $self->ut_textn('payunique')
;
return $error if $error;
+ if (!$self->custnum and !$self->get('custnum_pending')) {
+ return 'custnum required';
+ }
+
$self->_date(time) unless $self->_date;
# UNIQUE index should catch this too, without race conditions, but this