- $error = $self->SUPER::insert;
-
- my $cust_refund =
- qsearchs('cust_refund', { 'refundnum' => $self->refundnum } )
- or do {
- $dbh->rollback if $oldAutoCommit;
- return "unknown cust_refund.refundnum: ". $self->refundnum
- };
-
- my $refund_total = 0;
- $refund_total += $_ foreach map { $_->amount }
- qsearch('cust_credit_refund', { 'refundnum' => $self->refundnum } );
-
- if ( $refund_total > $cust_refund->refund ) {
- $dbh->rollback if $oldAutoCommit;
- return "total cust_credit_refund.amount $refund_total for refundnum ".
- $self->refundnum.
- " greater than cust_refund.refund ". $cust_refund->refund;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-