-
- my ($bill_hash, $ship_hash);
- foreach my $f (FS::cust_main->location_fields) {
- # avoid having to change this in front-end code
- $bill_hash->{$f} = $opt{"bill_$f"} || $opt{$f};
- $ship_hash->{$f} = $opt{"ship_$f"};
+
+ if ( exists( $opt{'address1'} ) ) {
+ my $bill_location = FS::cust_location->new({
+ map { $_ => $opt{$_} } @location_editable_fields
+ });
+ $bill_location->set('custnum' => $custnum);
+ my $error = $bill_location->find_or_insert;
+ die $error if $error;
+
+ # if this is unchanged from before, cust_main::replace will ignore it
+ $new->set('bill_location' => $bill_location);