X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9f4ef62c42dceef5a27ad3a0d8c8d260ffef9848..c22e188b4d7aabd:/SL/Controller/CsvImport/Base.pm?ds=inline diff --git a/SL/Controller/CsvImport/Base.pm b/SL/Controller/CsvImport/Base.pm index e3c119de2..fe8af336a 100644 --- a/SL/Controller/CsvImport/Base.pm +++ b/SL/Controller/CsvImport/Base.pm @@ -45,8 +45,8 @@ sub run { $self->controller->track_progress(progress => 10); - my $old_numberformat = $::myconfig{numberformat}; - $::myconfig{numberformat} = $self->controller->profile->get('numberformat'); + local $::myconfig{numberformat} = $self->controller->profile->get('numberformat'); + local $::myconfig{dateformat} = $self->controller->profile->get('dateformat'); $self->csv->parse; @@ -83,8 +83,6 @@ sub run { $self->fix_field_lengths; $self->controller->track_progress(progress => 100); - - $::myconfig{numberformat} = $old_numberformat; } sub add_columns { @@ -290,6 +288,9 @@ sub check_vc { sub handle_cvars { my ($self, $entry) = @_; + my $object = $entry->{object_to_save} || $entry->{object}; + return unless $object->can('cvars_by_config'); + my %type_to_column = ( text => 'text_value', textfield => 'text_value', select => 'text_value', @@ -298,6 +299,7 @@ sub handle_cvars { number => 'number_value_as_number', bool => 'bool_value' ); + # autovivify all cvars (cvars_by_config will do that for us) my @cvars; my %changed_cvars; foreach my $config (@{ $self->all_cvar_configs }) { @@ -312,16 +314,13 @@ sub handle_cvars { } # merge existing with new cvars. swap every existing with the imported one, push the rest - if (@cvars) { - my @orig_cvars = ($entry->{object_to_save} || $entry->{object})->custom_variables; - for (@orig_cvars) { - $_ = $changed_cvars{ $_->config->name } if $changed_cvars{ $_->config->name }; - delete $changed_cvars{ $_->config->name }; - } - push @orig_cvars, values %changed_cvars; - - $entry->{object}->custom_variables(\@orig_cvars); + my @orig_cvars = @{ $object->cvars_by_config }; + for (@orig_cvars) { + $_ = $changed_cvars{ $_->config->name } if $changed_cvars{ $_->config->name }; + delete $changed_cvars{ $_->config->name }; } + push @orig_cvars, values %changed_cvars; + $object->custom_variables(\@orig_cvars); } sub init_profile {