payment receipts!
[freeside.git] / FS / FS / cust_credit_bill.pm
index 0bbc656..695df6e 100644 (file)
@@ -38,7 +38,7 @@ FS::cust_credit_bill - Object methods for cust_credit_bill records
 =head1 DESCRIPTION
 
 An FS::cust_credit_bill object represents application of a credit (see
-L<FS::cust_credit>) to an invoice (see L<FS::cust_bill>).  FS::cust_credit
+L<FS::cust_credit>) to an invoice (see L<FS::cust_bill>).  FS::cust_credit_bill
 inherits from FS::Record.  The following fields are currently supported:
 
 =over 4
@@ -74,19 +74,6 @@ sub table { 'cust_credit_bill'; }
 Adds this cust_credit_bill to the database ("Posts" all or part of a credit).
 If there is an error, returns the error, otherwise returns false.
 
-sub insert {
-  my $self = shift;
-  my $error = $self->SUPER::insert(@_);
-  return $error if $error;
-
-  if ( $conf->exists('invoice_send_receipts') ) {
-    my $send_error = $self->cust_bill->send;
-    warn "Error sending receipt: $send_error\n" if $send_error;
-  }
-
-  '';
-}
-
 =item delete
 
 Currently unimplemented.
@@ -94,7 +81,10 @@ Currently unimplemented.
 =cut
 
 sub delete {
-  return "Can't unapply credit!"
+  my $self = shift;
+  return "Can't delete application for closed credit"
+    if $self->cust_credit->closed =~ /^Y/i;
+  $self->SUPER::delete(@_);
 }
 
 =item replace OLD_RECORD