-
- my $error =
- $nas->insert()
- || $nas->process_m2m('link_table' => 'export_nas',
- 'target_table' => 'part_export',
- 'params' => { $self->options });
+ foreach (FS::nas->fields) {
+ if ( length($svc_broadband->get($_)) ) {
+ $hash{$_} = $svc_broadband->get($_);
+ }
+ }
+ # if there's somehow a completely identical NAS in the table already,
+ # use that one.
+ my $nas = qsearchs('nas', \%hash);
+ my $error;
+ if ($nas) {
+ # propagate the export message
+ foreach my $part_export ($nas->part_export) {
+ $error = $part_export->export_nas_insert($nas);
+ die $error if $error;
+ }
+ } else {
+ $nas = $self->default_nas( %hash );
+ $error = $nas->insert ||
+ $nas->process_m2m('link_table' => 'export_nas',
+ 'target_table' => 'part_export',
+ 'params' => { $self->options });
+ }