use SL::Locale::String;
use SL::SessionFile;
use SL::SessionFile::Random;
+use SL::Controller::CsvImport::AdditionalBillingAddress;
use SL::Controller::CsvImport::Contact;
use SL::Controller::CsvImport::CustomerVendor;
use SL::Controller::CsvImport::Part;
sub check_type {
my ($self) = @_;
- die "Invalid CSV import type" if none { $_ eq $::form->{profile}->{type} } qw(parts inventories customers_vendors addresses contacts projects orders delivery_orders bank_transactions ar_transactions);
+ die "Invalid CSV import type" if none { $_ eq $::form->{profile}->{type} } qw(parts inventories customers_vendors billing_addresses addresses contacts projects orders delivery_orders bank_transactions ar_transactions);
$self->type($::form->{profile}->{type});
}
}
my $title = $self->type eq 'customers_vendors' ? $::locale->text('CSV import: customers and vendors')
+ : $self->type eq 'billing_addresses' ? $::locale->text('CSV import: additional billing addresses')
: $self->type eq 'addresses' ? $::locale->text('CSV import: shipping addresses')
: $self->type eq 'contacts' ? $::locale->text('CSV import: contacts')
: $self->type eq 'parts' ? $::locale->text('CSV import: parts and services')
return $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(@args)
: $self->{type} eq 'contacts' ? SL::Controller::CsvImport::Contact->new(@args)
+ : $self->{type} eq 'billing_addresses' ? SL::Controller::CsvImport::AdditionalBillingAddress->new(@args)
: $self->{type} eq 'addresses' ? SL::Controller::CsvImport::Shipto->new(@args)
: $self->{type} eq 'parts' ? SL::Controller::CsvImport::Part->new(@args)
: $self->{type} eq 'inventories' ? SL::Controller::CsvImport::Inventory->new(@args)
--- /dev/null
+package SL::Controller::CsvImport::AdditionalBillingAddress;
+
+use strict;
+
+use SL::Helper::Csv;
+
+use parent qw(SL::Controller::CsvImport::Base);
+
+use Rose::Object::MakeMethods::Generic
+(
+ scalar => [ qw(table) ],
+);
+
+sub set_profile_defaults {
+};
+
+sub init_class {
+ my ($self) = @_;
+ $self->class('SL::DB::AdditionalBillingAddress');
+}
+
+sub _hash_object {
+ my ($o) = @_;
+ return join('--', map({ s/[\s,\.\-]//g; $_ } ($o->name, $o->street)));
+}
+
+sub check_objects {
+ my ($self) = @_;
+
+ $self->controller->track_progress(phase => 'building data', progress => 0);
+
+ my %existing_by_id_name_street = map { (_hash_object($_) => $_) } @{ $self->existing_objects };
+ my $methods = $self->controller->headers->{methods};
+
+ my $i = 0;
+ my $num_data = scalar @{ $self->controller->data };
+ foreach my $entry (@{ $self->controller->data }) {
+ $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0;
+
+ $self->check_vc($entry, 'customer_id');
+
+ next if @{ $entry->{errors} };
+
+ my $object = $entry->{object};
+ my $idx = _hash_object($object);
+ my $existing = $existing_by_id_name_street{$idx};
+
+ if (!$existing) {
+ $existing_by_id_name_street{$idx} = $object;
+ } else {
+ $entry->{object_to_save} = $existing;
+
+ $existing->$_( $object->$_ ) for @{ $methods };
+
+ push @{ $entry->{information} }, $::locale->text('Updating existing entry in database');
+ }
+
+ } continue {
+ $i++;
+ }
+
+ $self->add_info_columns({ header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
+}
+
+sub setup_displayable_columns {
+ my ($self) = @_;
+
+ $self->SUPER::setup_displayable_columns;
+
+ $self->add_displayable_columns(
+ { name => 'default_address', description => $::locale->text('Default address flag') },
+ { name => 'name', description => $::locale->text('Name') },
+ { name => 'department_1', description => $::locale->text('Department 1') },
+ { name => 'department_2', description => $::locale->text('Department 2') },
+ { name => 'street', description => $::locale->text('Street') },
+ { name => 'zipcode', description => $::locale->text('Zipcode') },
+ { name => 'city', description => $::locale->text('City') },
+ { name => 'country', description => $::locale->text('Country') },
+ { name => 'contact', description => $::locale->text('Contact') },
+ { name => 'email', description => $::locale->text('E-mail') },
+ { name => 'fax', description => $::locale->text('Fax') },
+ { name => 'gln', description => $::locale->text('GLN') },
+ { name => 'phone', description => $::locale->text('Phone') },
+ { name => 'customer_id', description => $::locale->text('Customer') },
+ { name => 'customer', description => $::locale->text('Customer (name)') },
+ { name => 'customernumber', description => $::locale->text('Customer Number') },
+ );
+}
+
+1;
'CSV Export successful!' => 'CSV-Export erfolgreich!',
'CSV export' => 'CSV-Export',
'CSV export -- options' => 'CSV-Export -- Optionen',
+ 'CSV import: additional billing addresses' => 'CSV-Import: zusätzliche Rechnungsadressen',
'CSV import: ar transactions' => 'CSV Import: Debitorenbuchungen',
'CSV import: bank transactions' => 'CSV Import: Bankbewegungen',
'CSV import: contacts' => 'CSV-Import: Ansprechpersonen',
'Default Transfer with services' => 'Ein- /Auslagern von Dienstleistungen über Standard-Lagerplatz',
'Default Warehouse' => 'Standard-Lager',
'Default Warehouse with ignoring onhand' => 'Standard-Lager für Auslagern ohne Prüfung auf Bestand',
+ 'Default address flag' => 'Standard-Adresse-Schalter',
'Default article for converting into quotations and orders' => 'Standardartikel für Konvertierung von Pflichtenheften in Angebote und Aufträge',
'Default booking group' => 'Standardbuchungsgruppe',
'Default client' => 'Standardmandant',