From: Thomas Heck Date: Fri, 17 Aug 2012 11:59:45 +0000 (+0200) Subject: CSV-Kunden-/Lieferantenimport: Verwendung von TransNumber zur Erzeugung von Nummern X-Git-Tag: release-3.0.0beta1~282 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=91e4c0dc7b3e89a6301bdbd698c440ce8776f83d;p=kivitendo-erp.git CSV-Kunden-/Lieferantenimport: Verwendung von TransNumber zur Erzeugung von Nummern implementiert #1972 --- diff --git a/SL/Controller/CsvImport/CustomerVendor.pm b/SL/Controller/CsvImport/CustomerVendor.pm index 02d84836c..e9b2d3931 100644 --- a/SL/Controller/CsvImport/CustomerVendor.pm +++ b/SL/Controller/CsvImport/CustomerVendor.pm @@ -7,6 +7,7 @@ use SL::DB::Business; use SL::DB::CustomVariable; use SL::DB::CustomVariableConfig; use SL::DB::PaymentTerm; +use SL::TransNumber; use parent qw(SL::Controller::CsvImport::Base); @@ -167,7 +168,18 @@ sub save_objects { my $with_number = [ grep { $_->{object}->$numbercolumn ne '####' } @{ $self->controller->data } ]; my $without_number = [ grep { $_->{object}->$numbercolumn eq '####' } @{ $self->controller->data } ]; - map { $_->{object}->$numbercolumn('') } @{ $without_number }; + foreach my $entry (@{$with_number}, @{$without_number}) { + my $object = $entry->{object}; + + my $number = SL::TransNumber->new(type => $self->table(), + number => $object->$numbercolumn(), + business_id => $object->business_id(), + save => 1); + + if ( $object->$numbercolumn eq '####' || !$number->is_unique() ) { + $object->$numbercolumn($number->create_unique()); + } + } $self->SUPER::save_objects(data => $with_number); $self->SUPER::save_objects(data => $without_number);