X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCsvImport%2FOrder.pm;h=9188556a4ba3c01d94c7866cd103cd422bce991c;hb=649529bf1cc186b2320c4797b85c411e552a464c;hp=fe7301936a43869ad18a745520bca6a30d120527;hpb=efb9a24f2252104ab4af5c25334119d7c5c70a8c;p=kivitendo-erp.git diff --git a/SL/Controller/CsvImport/Order.pm b/SL/Controller/CsvImport/Order.pm index fe7301936..9188556a4 100644 --- a/SL/Controller/CsvImport/Order.pm +++ b/SL/Controller/CsvImport/Order.pm @@ -25,7 +25,7 @@ use parent qw(SL::Controller::CsvImport::BaseMulti); use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by taxzones_by price_factors_by pricegroups_by) ], + 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by price_factors_by pricegroups_by) ], ); @@ -156,6 +156,7 @@ sub setup_displayable_columns { { name => 'ordnumber', description => $::locale->text('Order Number') }, { name => 'parts_id', description => $::locale->text('Part (database ID)') }, { name => 'partnumber', description => $::locale->text('Part Number') }, + { name => 'position', description => $::locale->text('position') }, { name => 'project_id', description => $::locale->text('Project (database ID)') }, { name => 'projectnumber', description => $::locale->text('Project (number)') }, { name => 'project', description => $::locale->text('Project (description)') }, @@ -226,13 +227,6 @@ sub init_ct_shiptos_by { return $sby; } -sub init_taxzones_by { - my ($self) = @_; - - my $all_taxzones = SL::DB::Manager::TaxZone->get_all; - return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_taxzones } } ) } qw(id description) }; -} - sub init_price_factors_by { my ($self) = @_; @@ -346,7 +340,8 @@ sub handle_salesman { my ($self, $entry) = @_; my $object = $entry->{object}; - my $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id; + my $vc_obj; + $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id; $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if (!$vc_obj && $object->vendor_id); # salesman from customer/vendor or login if not given @@ -431,7 +426,7 @@ sub check_part { my $object = $entry->{object}; - # Check wether or non part ID is valid. + # Check wether or not part ID is valid. if ($object->parts_id && !$self->parts_by->{id}->{ $object->parts_id }) { push @{ $entry->{errors} }, $::locale->text('Error: Invalid part'); return 0; @@ -572,31 +567,6 @@ sub check_ct_shipto { return 1; } -sub check_taxzone { - my ($self, $entry) = @_; - - my $object = $entry->{object}; - - # Check wether or not taxzone ID is valid. - if ($object->taxzone_id && !$self->taxzones_by->{id}->{ $object->taxzone_id }) { - push @{ $entry->{errors} }, $::locale->text('Error: Invalid tax zone'); - return 0; - } - - # Map description to ID if given. - if (!$object->taxzone_id && $entry->{raw_data}->{taxzone}) { - my $taxzone = $self->taxzones_by->{description}->{ $entry->{raw_data}->{taxzone} }; - if (!$taxzone) { - push @{ $entry->{errors} }, $::locale->text('Error: Invalid tax zone'); - return 0; - } - - $object->taxzone_id($taxzone->id); - } - - return 1; -} - sub check_price_factor { my ($self, $entry) = @_; @@ -654,10 +624,10 @@ sub add_items_to_order { my $order_entry; my @orderitems; foreach my $entry (@{ $self->controller->data }) { - # search first order + # search first/next order if ($entry->{raw_data}->{datatype} eq $self->_order_column) { - # new order entry: add collected orderitems to the previous one + # next order entry: add collected orderitems to the previous one if (defined $order_entry) { $order_entry->{object}->orderitems(@orderitems); @orderitems = (); @@ -684,7 +654,7 @@ sub handle_prices_and_taxes() { foreach my $entry (@{ $self->controller->data }) { next if @{ $entry->{errors} }; - if ($entry->{raw_data}->{datatype} eq $self->_order_column) { + if ($entry->{raw_data}->{datatype} eq $self->_order_column && $entry->{object}->orderitems) { $entry->{object}->calculate_prices_and_taxes;