kaputte Template-Deriktive wieder heile gemacht.
[kivitendo-erp.git] / SL / Helper / Csv / Dispatcher.pm
index ababa01..3a725b5 100644 (file)
@@ -106,21 +106,14 @@ sub is_known {
 sub parse_profile {
   my ($self, %params) = @_;
 
-  my $profile;
-  my $class;
-  my $header;
   my @specs;
 
+  my $csv_profile = $self->_csv->profile;
+  my $h_aref = ($self->_csv->is_multiplexed)? $self->_csv->header : [ $self->_csv->header ];
   my $i = 0;
-  foreach my $h (@{ $self->_csv->header }) {
-    $header = $h;
-    if ($self->_csv->profile) {
-      $profile = $self->_csv->profile->[$i]->{profile};
-      $class   = $self->_csv->profile->[$i]->{class};
-    }
-
-    my $spec = $self->_parse_profile(profile => $profile,
-                                     class   => $class,
+  foreach my $header (@{ $h_aref }) {
+    my $spec = $self->_parse_profile(profile => $csv_profile->[$i]->{profile},
+                                     class   => $csv_profile->[$i]->{class},
                                      header  => $header);
     push @specs, $spec;
     $i++;
@@ -128,6 +121,8 @@ sub parse_profile {
 
   $self->_specs(\@specs);
 
+  $self->_csv->_push_error($self->errors);
+
   return ! $self->errors;
 }
 
@@ -157,8 +152,6 @@ sub _parse_profile {
     }
   }
 
-  $self->_csv->_push_error($self->errors);
-
   return \@specs;
 }