From: Bernd Bleßmann Date: Sun, 19 Mar 2017 16:46:17 +0000 (+0100) Subject: CsvImport: Kunden/Lieferanten auch nach GLN suchen können. X-Git-Tag: release-3.5.4~1175 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d8b09e08865f37d0cbdbb59d6778afc9d18b06fc;p=kivitendo-erp.git CsvImport: Kunden/Lieferanten auch nach GLN suchen können. Für die Imports, die die Angabe eines Kunden oder Lieferanten brauchen und check_vc verwenden (Aufträge, Ansprchpersonen, Lieferanschriften, Debitorenbuchungen), kann neben Id, Nummer oder Name auch die GLN verwendet werden. --- diff --git a/SL/Controller/CsvImport/ARTransaction.pm b/SL/Controller/CsvImport/ARTransaction.pm index ca16a012f..4018b78cb 100644 --- a/SL/Controller/CsvImport/ARTransaction.pm +++ b/SL/Controller/CsvImport/ARTransaction.pm @@ -108,6 +108,7 @@ sub setup_displayable_columns { { name => 'taxincluded', description => $::locale->text('Tax Included') }, { name => 'customer', description => $::locale->text('Customer (name)') }, { name => 'customernumber', description => $::locale->text('Customer Number') }, + { name => 'customer_gln', description => $::locale->text('Customer GLN') }, { name => 'customer_id', description => $::locale->text('Customer (database ID)') }, { name => 'language_id', description => $::locale->text('Language (database ID)') }, { name => 'language', description => $::locale->text('Language (name)') }, @@ -251,11 +252,11 @@ sub handle_invoice { $object->transactions( [] ); # initialise transactions for ar object so methods work on unsaved transactions my $vc_obj; - if (any { $entry->{raw_data}->{$_} } qw(customer customernumber customer_id)) { + if (any { $entry->{raw_data}->{$_} } qw(customer customernumber customer_gln customer_id)) { $self->check_vc($entry, 'customer_id'); # check_vc only sets customer_id, but we need vc_obj later for customer defaults $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id; - } elsif (any { $entry->{raw_data}->{$_} } qw(vendor vendornumber vendor_id)) { + } elsif (any { $entry->{raw_data}->{$_} } qw(vendor vendornumber vendor_gln vendor_id)) { $self->check_vc($entry, 'vendor_id'); $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if $object->vendor_id; } else { diff --git a/SL/Controller/CsvImport/Base.pm b/SL/Controller/CsvImport/Base.pm index 2deae4571..e0e60e474 100644 --- a/SL/Controller/CsvImport/Base.pm +++ b/SL/Controller/CsvImport/Base.pm @@ -188,10 +188,13 @@ sub init_vc_by { vendors => { map { ( $_->vendornumber => $_ ) } @{ $self->all_vc->{vendors} } } ); my %by_name = ( customers => { map { ( $_->name => $_ ) } @{ $self->all_vc->{customers} } }, vendors => { map { ( $_->name => $_ ) } @{ $self->all_vc->{vendors} } } ); + my %by_gln = ( customers => { map { ( $_->gln => $_ ) } @{ $self->all_vc->{customers} } }, + vendors => { map { ( $_->gln => $_ ) } @{ $self->all_vc->{vendors} } } ); return { id => \%by_id, number => \%by_number, - name => \%by_name, }; + name => \%by_name, + gln => \%by_gln }; } sub check_vc { @@ -208,8 +211,14 @@ sub check_vc { } if (!$entry->{object}->$id_column) { - my $vc = $self->vc_by->{name}->{customers}->{ $entry->{raw_data}->{customer} } - || $self->vc_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} }; + my $vc = ($entry->{raw_data}->{customer} && $self->vc_by->{name}->{customers}->{ $entry->{raw_data}->{customer} }) + || ($entry->{raw_data}->{vendor} && $self->vc_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} }); + $entry->{object}->$id_column($vc->id) if $vc; + } + + if (!$entry->{object}->$id_column) { + my $vc = ($entry->{raw_data}->{customer_gln} && $self->vc_by->{gln}->{customers}->{ $entry->{raw_data}->{customer_gln} }) + || ($entry->{raw_data}->{vendor_gln} && $self->vc_by->{gln}->{vendors}->{ $entry->{raw_data}->{vendor_gln} } ); $entry->{object}->$id_column($vc->id) if $vc; } diff --git a/SL/Controller/CsvImport/Contact.pm b/SL/Controller/CsvImport/Contact.pm index adaa85ce6..81fa0e80d 100644 --- a/SL/Controller/CsvImport/Contact.pm +++ b/SL/Controller/CsvImport/Contact.pm @@ -158,8 +158,10 @@ sub setup_displayable_columns { { name => 'customer', description => $::locale->text('Customer (name)') }, { name => 'customernumber', description => $::locale->text('Customer Number') }, + { name => 'customer_gln', description => $::locale->text('Customer GLN') }, { name => 'vendor', description => $::locale->text('Vendor (name)') }, { name => 'vendornumber', description => $::locale->text('Vendor Number') }, + { name => 'vendor_gln', description => $::locale->text('Vendor GLN') }, ); } diff --git a/SL/Controller/CsvImport/Order.pm b/SL/Controller/CsvImport/Order.pm index c3c5c5c87..0d5494413 100644 --- a/SL/Controller/CsvImport/Order.pm +++ b/SL/Controller/CsvImport/Order.pm @@ -133,9 +133,11 @@ sub setup_displayable_columns { { name => 'taxincluded', description => $::locale->text('Tax Included') }, { name => 'customer', description => $::locale->text('Customer (name)') }, { name => 'customernumber', description => $::locale->text('Customer Number') }, + { name => 'customer_gln', description => $::locale->text('Customer GLN') }, { name => 'customer_id', description => $::locale->text('Customer (database ID)') }, { name => 'vendor', description => $::locale->text('Vendor (name)') }, { name => 'vendornumber', description => $::locale->text('Vendor Number') }, + { name => 'vendor_gln', description => $::locale->text('Vendor GLN') }, { name => 'vendor_id', description => $::locale->text('Vendor (database ID)') }, { name => 'language_id', description => $::locale->text('Language (database ID)') }, { name => 'language', description => $::locale->text('Language (name)') }, @@ -300,10 +302,10 @@ sub handle_order { my $object = $entry->{object}; my $vc_obj; - if (any { $entry->{raw_data}->{$_} } qw(customer customernumber customer_id)) { + if (any { $entry->{raw_data}->{$_} } qw(customer customernumber customer_gln customer_id)) { $self->check_vc($entry, 'customer_id'); $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id; - } elsif (any { $entry->{raw_data}->{$_} } qw(vendor vendornumber vendor_id)) { + } elsif (any { $entry->{raw_data}->{$_} } qw(vendor vendornumber vendor_gln vendor_id)) { $self->check_vc($entry, 'vendor_id'); $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if $object->vendor_id; } else { diff --git a/SL/Controller/CsvImport/Shipto.pm b/SL/Controller/CsvImport/Shipto.pm index 6c01a1426..b4d9e0041 100644 --- a/SL/Controller/CsvImport/Shipto.pm +++ b/SL/Controller/CsvImport/Shipto.pm @@ -120,8 +120,10 @@ sub setup_displayable_columns { { name => 'trans_id', description => $::locale->text('Customer/Vendor (database ID)') }, { name => 'customer', description => $::locale->text('Customer (name)') }, { name => 'customernumber', description => $::locale->text('Customer Number') }, + { name => 'customer_gln', description => $::locale->text('Customer GLN') }, { name => 'vendor', description => $::locale->text('Vendor (name)') }, { name => 'vendornumber', description => $::locale->text('Vendor Number') }, + { name => 'vendor_gln', description => $::locale->text('Vendor GLN') }, ); } diff --git a/locale/de/all b/locale/de/all index b677f0fa0..3c5eb163d 100755 --- a/locale/de/all +++ b/locale/de/all @@ -331,7 +331,7 @@ $self->{texts} = { 'Assume Tax Consultant Data in Tax Computation?' => 'Beraterdaten in UStVA übernehmen?', 'At least' => 'Mindestens', 'At least one Perl module that kivitendo ERP requires for running is not installed on your system.' => 'Mindestes ein Perl-Modul, das kivitendo ERP zur Ausführung benötigt, ist auf Ihrem System nicht installiert.', - 'At least one of the columns #1, customer, customernumber, vendor, vendornumber (depending on the target table) is required for matching the entry to an existing customer or vendor.' => 'Mindestens eine der Spalten #1, customer, customernumber, vendor, vendornumber (von Zieltabelle abhängig) wird benötigt, um einen Eintrag einem bestehenden Kunden bzw. Lieferanten zuzuordnen.', + 'At least one of the columns #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (depending on the target table) is required for matching the entry to an existing customer or vendor.' => 'Mindestens eine der Spalten #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (von Zieltabelle abhängig) wird benötigt, um einen Eintrag einem bestehenden Kunden bzw. Lieferanten zuzuordnen.', 'At most' => 'Höchstens', 'At the moment the transaction looks like this:' => 'Aktuell sieht die Buchung wie folgt aus:', 'Attach PDF:' => 'PDF anhängen', @@ -768,6 +768,7 @@ $self->{texts} = { 'Customer (database ID)' => 'Kunde (Datenbank-ID)', 'Customer (name)' => 'Kunde (Name)', 'Customer Discount' => 'Kundenrabatt', + 'Customer GLN' => 'GLN des Kunden', 'Customer Master Data' => 'Kundenstammdaten', 'Customer Name' => 'Kundenname', 'Customer Number' => 'Kundennummer', @@ -3468,6 +3469,7 @@ $self->{texts} = { 'Vendor (database ID)' => 'Lieferant (Datenbank-ID)', 'Vendor (name)' => 'Lieferant (Name)', 'Vendor Discount' => 'Lieferantenrabatt', + 'Vendor GLN' => 'GLN des Lieferanten', 'Vendor Invoice' => 'Einkaufsrechnung', 'Vendor Invoices & AP Transactions' => 'Einkaufsrechnungen & Kreditorenbuchungen', 'Vendor Master Data' => 'Lieferantenstammdaten', diff --git a/locale/en/all b/locale/en/all index b2e9a001a..5eae4eedd 100644 --- a/locale/en/all +++ b/locale/en/all @@ -323,7 +323,7 @@ $self->{texts} = { 'Assume Tax Consultant Data in Tax Computation?' => '', 'At least' => '', 'At least one Perl module that kivitendo ERP requires for running is not installed on your system.' => '', - 'At least one of the columns #1, customer, customernumber, vendor, vendornumber (depending on the target table) is required for matching the entry to an existing customer or vendor.' => '', + 'At least one of the columns #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (depending on the target table) is required for matching the entry to an existing customer or vendor.' => '', 'At most' => '', 'At the moment the transaction looks like this:' => '', 'Attach PDF:' => '', @@ -768,6 +768,7 @@ $self->{texts} = { 'Customer (database ID)' => '', 'Customer (name)' => '', 'Customer Discount' => '', + 'Customer GLN' => '', 'Customer Master Data' => '', 'Customer Name' => '', 'Customer Number' => '', @@ -3422,6 +3423,7 @@ $self->{texts} = { 'Vendor (database ID)' => '', 'Vendor (name)' => '', 'Vendor Discount' => '', + 'Vendor GLN' => '', 'Vendor Invoice' => '', 'Vendor Invoices & AP Transactions' => '', 'Vendor Master Data' => '', diff --git a/templates/webpages/csv_import/form.html b/templates/webpages/csv_import/form.html index ebe5616e6..a1ca61c7a 100644 --- a/templates/webpages/csv_import/form.html +++ b/templates/webpages/csv_import/form.html @@ -108,12 +108,12 @@ [%- IF SELF.type == 'contacts' %]

[%- LxERP.t8("You can update existing contacts by providing the 'cp_id' column with their database IDs. Otherwise: ") %] - [%- LxERP.t8('At least one of the columns #1, customer, customernumber, vendor, vendornumber (depending on the target table) is required for matching the entry to an existing customer or vendor.', 'cp_cv_id') %] + [%- LxERP.t8('At least one of the columns #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (depending on the target table) is required for matching the entry to an existing customer or vendor.', 'cp_cv_id') %]

[%- ELSIF SELF.type == 'addresses' %]

- [%- LxERP.t8('At least one of the columns #1, customer, customernumber, vendor, vendornumber (depending on the target table) is required for matching the entry to an existing customer or vendor.', 'trans_id') %] + [%- LxERP.t8('At least one of the columns #1, customer, customernumber, customer_gln, vendor, vendornumber, vendor_gln (depending on the target table) is required for matching the entry to an existing customer or vendor.', 'trans_id') %]

[%- ELSIF SELF.type == 'parts' %]