fix self-service info edit turning off self-service contact access, RT#76209
[freeside.git] / FS / FS / cust_main.pm
index f4990a4..640eee3 100644 (file)
@@ -1509,6 +1509,14 @@ sub replace {
     $implicit_contact->set('emailaddress', $email);
     $implicit_contact->set('invoice_dest', 'Y');
     $implicit_contact->set('custnum', $self->custnum);
+    my $i_cust_contact =
+      qsearchs('cust_contact', {
+                                 contactnum  => $implicit_contact->contactnum,
+                                 custnum     => $self->custnum,
+                               }
+      );
+    $implicit_contact->set($_, $i_cust_contact->$_)
+      foreach qw( classnum selfservice_access comment );
 
     my $error;
     if ( $implicit_contact->contactnum ) {
@@ -3432,6 +3440,20 @@ sub num_cust_attachments_deleted {
   );
 }
 
+=item max_invnum
+
+Returns the most recent invnum (invoice number) for this customer.
+
+=cut
+
+sub max_invnum {
+  my $self = shift;
+  $self->scalar_sql(
+    " SELECT MAX(invnum) FROM cust_bill WHERE custnum = ?",
+    $self->custnum
+  );
+}
+
 =item cust_bill [ OPTION => VALUE... | EXTRA_QSEARCH_PARAMS_HASHREF ]
 
 Returns all the invoices (see L<FS::cust_bill>) for this customer.