From: Bernd Bleßmann Date: Mon, 22 Apr 2013 13:31:06 +0000 (+0200) Subject: Zeilenkennung und maximaler Differenzbetrag lassen sich an der Oberfläche eingeben. X-Git-Tag: release-3.1.0beta1~22^2~143 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=48da03126f83ad6f3406b8c70a077ab52e18823d;p=kivitendo-erp.git Zeilenkennung und maximaler Differenzbetrag lassen sich an der Oberfläche eingeben. --- diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index a9df5adfe..f21cd2a46 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -387,8 +387,7 @@ sub profile_from_form { } if ($self->type eq 'orders') { - $::form->{settings}->{order_column} = 'Order'; - $::form->{settings}->{item_column} = 'OrderItem'; + $::form->{settings}->{max_amount_diff} = $::form->parse_amount(\%::myconfig, $::form->{settings}->{max_amount_diff}); } delete $::form->{profile}->{id}; diff --git a/SL/Controller/CsvImport/Order.pm b/SL/Controller/CsvImport/Order.pm index d1a1e461b..bcf098da8 100644 --- a/SL/Controller/CsvImport/Order.pm +++ b/SL/Controller/CsvImport/Order.pm @@ -37,7 +37,7 @@ sub init_class { sub init_settings { my ($self) = @_; - return { map { ( $_ => $self->controller->profile->get($_) ) } qw(order_column item_column) }; + return { map { ( $_ => $self->controller->profile->get($_) ) } qw(order_column item_column max_amount_diff) }; } @@ -46,14 +46,25 @@ sub init_profile { my $profile = $self->SUPER::init_profile; + # SUPER::init_profile sets row_ident to the class name + # overwrite it with the user specified settings foreach my $p (@{ $profile }) { - my $prof = $p->{profile}; if ($p->{row_ident} eq 'Order') { + $p->{row_ident} = $self->settings->{'order_column'}; + } + if ($p->{row_ident} eq 'OrderItem') { + $p->{row_ident} = $self->settings->{'item_column'}; + } + } + + foreach my $p (@{ $profile }) { + my $prof = $p->{profile}; + if ($p->{row_ident} eq $self->settings->{'order_column'}) { # no need to handle delete @{$prof}{qw(delivery_customer_id delivery_vendor_id proforma quotation amount netamount)}; - # handable, but not handled by now } - if ($p->{row_ident} eq 'OrderItem') { + if ($p->{row_ident} eq $self->settings->{'item_column'}) { + # no need to handle delete @{$prof}{qw(trans_id)}; } } @@ -67,7 +78,7 @@ sub setup_displayable_columns { $self->SUPER::setup_displayable_columns; - $self->add_displayable_columns('Order', + $self->add_displayable_columns($self->settings->{'order_column'}, { name => 'datatype', description => $::locale->text('Zeilenkennung') }, { name => 'closed', description => $::locale->text('Closed') }, { name => 'curr', description => $::locale->text('Currency') }, @@ -111,7 +122,7 @@ sub setup_displayable_columns { { name => 'shipto_id', description => $::locale->text('Ship to (database ID)') }, ); - $self->add_displayable_columns('OrderItem', + $self->add_displayable_columns($self->settings->{'item_column'}, { name => 'datatype', description => $::locale->text('Zeilenkennung') }, { name => 'cusordnumber', description => $::locale->text('Customer Order Number') }, { name => 'description', description => $::locale->text('Description') }, @@ -353,7 +364,6 @@ sub check_objects { # If amounts are given, show calculated amounts as info and given amounts (verify_xxx). # And throw an error if the differences are too big. - my $max_diff = 0.02; my @to_verify = ( { column => 'amount', raw_column => 'verify_amount', info_header => 'Calc. Amount', @@ -381,7 +391,7 @@ sub check_objects { if ($entry->{raw_data}->{datatype} eq $self->settings->{'order_column'}) { next if !$entry->{raw_data}->{ $tv->{raw_column} }; my $parsed_value = $::form->parse_amount(\%::myconfig, $entry->{raw_data}->{ $tv->{raw_column} }); - if (abs($entry->{object}->${ \$tv->{column} } - $parsed_value) > $max_diff) { + if (abs($entry->{object}->${ \$tv->{column} } - $parsed_value) > $self->settings->{'max_amount_diff'}) { push @{ $entry->{errors} }, $::locale->text($tv->{err_msg}); } } diff --git a/SL/DB/CsvImportProfile.pm b/SL/DB/CsvImportProfile.pm index 21dd4842d..5a79809b4 100644 --- a/SL/DB/CsvImportProfile.pm +++ b/SL/DB/CsvImportProfile.pm @@ -54,6 +54,11 @@ sub set_defaults { default_buchungsgruppe => ($bugru ? $bugru->id : undef), apply_buchungsgruppe => 'all', ); + } elsif ($self->type eq 'orders') { + $self->_set_defaults(order_column => 'Order', + item_column => 'OrderItem', + max_amount_diff => 0.02, + ); } else { $self->_set_defaults(table => 'customer'); } diff --git a/templates/webpages/csv_import/_form_orders.html b/templates/webpages/csv_import/_form_orders.html index 221f22910..728c669f9 100644 --- a/templates/webpages/csv_import/_form_orders.html +++ b/templates/webpages/csv_import/_form_orders.html @@ -3,7 +3,14 @@ [%- LxERP.t8('Order/Item columns') %]: - [% L.input_tag('settings.order_column', SELF.profile.get('order_column'), size => "5") %] - [% L.input_tag('settings.item_column', SELF.profile.get('item_column'), size => "5") %] + [% L.input_tag('settings.order_column', SELF.profile.get('order_column'), size => "10") %] + [% L.input_tag('settings.item_column', SELF.profile.get('item_column'), size => "10") %] + + + + + [%- LxERP.t8('Maximal amount difference') %]: + + [% L.input_tag('settings.max_amount_diff', LxERP.format_amount(SELF.profile.get('max_amount_diff')), size => "5") %]