- $error = $cust_main_invoice->delete;
- die "custnum $custnum, cleaning up cust_main_invoice: $error\n" if $error;
-
- } # while $search->fetch
-
- unless ( FS::upgrade_journal->is_done('contact_invoice_dest') ) {
-
- local($skip_fuzzyfiles) = 1;
-
- foreach my $contact (qsearch('contact', {})) {
- my $error = $contact->replace;
- die $error if $error;
+ foreach my $custnum (keys %custnum_dest) {
+ my $dests = $custnum_dest{$custnum};
+ my $cust_main = FS::cust_main->by_key($custnum);
+ my $error = $cust_main->replace( invoicing_list => $dests );
+ if ( $error ) {
+ die "custnum $custnum, creating contact: $error\n";