diff options
Diffstat (limited to 'FS/FS/cust_refund.pm')
-rw-r--r-- | FS/FS/cust_refund.pm | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 15335a421..74728a60e 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -145,19 +145,21 @@ sub insert { my $dbh = dbh; unless ($self->reasonnum) { - my $result = $self->reason( $self->getfield('reason'), - exists($options{ 'reason_type' }) - ? ('reason_type' => $options{ 'reason_type' }) - : (), - ); - unless($result) { - $dbh->rollback if $oldAutoCommit; - return "failed to set reason for $me"; #: ". $dbh->errstr; + local $@; + if ( $self->get('reason') ) { + my $reason = FS::reason->new_or_existing( + reason => $self->get('reason'), + class => 'F', + type => 'Refund reason', + ); + if ($@) { + return "failed to add refund reason: $@"; + } + $self->set('reasonnum', $reason->get('reasonnum')); + $self->set('reason', ''); } } - $self->setfield('reason', ''); - if ( $self->crednum ) { my $cust_credit = qsearchs('cust_credit', { 'crednum' => $self->crednum } ) or do { |