Revision 59274d46
Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt
SL/Controller/CsvImport.pm | ||
---|---|---|
13 | 13 |
use SL::Locale::String; |
14 | 14 |
use SL::SessionFile; |
15 | 15 |
use SL::SessionFile::Random; |
16 |
use SL::Controller::CsvImport::AdditionalBillingAddress; |
|
16 | 17 |
use SL::Controller::CsvImport::Contact; |
17 | 18 |
use SL::Controller::CsvImport::CustomerVendor; |
18 | 19 |
use SL::Controller::CsvImport::Part; |
... | ... | |
307 | 308 |
sub check_type { |
308 | 309 |
my ($self) = @_; |
309 | 310 |
|
310 |
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); |
|
311 |
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);
|
|
311 | 312 |
$self->type($::form->{profile}->{type}); |
312 | 313 |
} |
313 | 314 |
|
... | ... | |
348 | 349 |
} |
349 | 350 |
|
350 | 351 |
my $title = $self->type eq 'customers_vendors' ? $::locale->text('CSV import: customers and vendors') |
352 |
: $self->type eq 'billing_addresses' ? $::locale->text('CSV import: additional billing addresses') |
|
351 | 353 |
: $self->type eq 'addresses' ? $::locale->text('CSV import: shipping addresses') |
352 | 354 |
: $self->type eq 'contacts' ? $::locale->text('CSV import: contacts') |
353 | 355 |
: $self->type eq 'parts' ? $::locale->text('CSV import: parts and services') |
... | ... | |
720 | 722 |
|
721 | 723 |
return $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(@args) |
722 | 724 |
: $self->{type} eq 'contacts' ? SL::Controller::CsvImport::Contact->new(@args) |
725 |
: $self->{type} eq 'billing_addresses' ? SL::Controller::CsvImport::AdditionalBillingAddress->new(@args) |
|
723 | 726 |
: $self->{type} eq 'addresses' ? SL::Controller::CsvImport::Shipto->new(@args) |
724 | 727 |
: $self->{type} eq 'parts' ? SL::Controller::CsvImport::Part->new(@args) |
725 | 728 |
: $self->{type} eq 'inventories' ? SL::Controller::CsvImport::Inventory->new(@args) |
SL/Controller/CsvImport/AdditionalBillingAddress.pm | ||
---|---|---|
1 |
package SL::Controller::CsvImport::AdditionalBillingAddress; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::Helper::Csv; |
|
6 |
|
|
7 |
use parent qw(SL::Controller::CsvImport::Base); |
|
8 |
|
|
9 |
use Rose::Object::MakeMethods::Generic |
|
10 |
( |
|
11 |
scalar => [ qw(table) ], |
|
12 |
); |
|
13 |
|
|
14 |
sub set_profile_defaults { |
|
15 |
}; |
|
16 |
|
|
17 |
sub init_class { |
|
18 |
my ($self) = @_; |
|
19 |
$self->class('SL::DB::AdditionalBillingAddress'); |
|
20 |
} |
|
21 |
|
|
22 |
sub _hash_object { |
|
23 |
my ($o) = @_; |
|
24 |
return join('--', map({ s/[\s,\.\-]//g; $_ } ($o->name, $o->street))); |
|
25 |
} |
|
26 |
|
|
27 |
sub check_objects { |
|
28 |
my ($self) = @_; |
|
29 |
|
|
30 |
$self->controller->track_progress(phase => 'building data', progress => 0); |
|
31 |
|
|
32 |
my %existing_by_id_name_street = map { (_hash_object($_) => $_) } @{ $self->existing_objects }; |
|
33 |
my $methods = $self->controller->headers->{methods}; |
|
34 |
|
|
35 |
my $i = 0; |
|
36 |
my $num_data = scalar @{ $self->controller->data }; |
|
37 |
foreach my $entry (@{ $self->controller->data }) { |
|
38 |
$self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0; |
|
39 |
|
|
40 |
$self->check_vc($entry, 'customer_id'); |
|
41 |
|
|
42 |
next if @{ $entry->{errors} }; |
|
43 |
|
|
44 |
my $object = $entry->{object}; |
|
45 |
my $idx = _hash_object($object); |
|
46 |
my $existing = $existing_by_id_name_street{$idx}; |
|
47 |
|
|
48 |
if (!$existing) { |
|
49 |
$existing_by_id_name_street{$idx} = $object; |
|
50 |
} else { |
|
51 |
$entry->{object_to_save} = $existing; |
|
52 |
|
|
53 |
$existing->$_( $object->$_ ) for @{ $methods }; |
|
54 |
|
|
55 |
push @{ $entry->{information} }, $::locale->text('Updating existing entry in database'); |
|
56 |
} |
|
57 |
|
|
58 |
} continue { |
|
59 |
$i++; |
|
60 |
} |
|
61 |
|
|
62 |
$self->add_info_columns({ header => $::locale->text('Customer/Vendor'), method => 'vc_name' }); |
|
63 |
} |
|
64 |
|
|
65 |
sub setup_displayable_columns { |
|
66 |
my ($self) = @_; |
|
67 |
|
|
68 |
$self->SUPER::setup_displayable_columns; |
|
69 |
|
|
70 |
$self->add_displayable_columns( |
|
71 |
{ name => 'default_address', description => $::locale->text('Default address flag') }, |
|
72 |
{ name => 'name', description => $::locale->text('Name') }, |
|
73 |
{ name => 'department_1', description => $::locale->text('Department 1') }, |
|
74 |
{ name => 'department_2', description => $::locale->text('Department 2') }, |
|
75 |
{ name => 'street', description => $::locale->text('Street') }, |
|
76 |
{ name => 'zipcode', description => $::locale->text('Zipcode') }, |
|
77 |
{ name => 'city', description => $::locale->text('City') }, |
|
78 |
{ name => 'country', description => $::locale->text('Country') }, |
|
79 |
{ name => 'contact', description => $::locale->text('Contact') }, |
|
80 |
{ name => 'email', description => $::locale->text('E-mail') }, |
|
81 |
{ name => 'fax', description => $::locale->text('Fax') }, |
|
82 |
{ name => 'gln', description => $::locale->text('GLN') }, |
|
83 |
{ name => 'phone', description => $::locale->text('Phone') }, |
|
84 |
{ name => 'customer_id', description => $::locale->text('Customer') }, |
|
85 |
{ name => 'customer', description => $::locale->text('Customer (name)') }, |
|
86 |
{ name => 'customernumber', description => $::locale->text('Customer Number') }, |
|
87 |
); |
|
88 |
} |
|
89 |
|
|
90 |
1; |
SL/DB/AdditionalBillingAddress.pm | ||
---|---|---|
7 | 7 |
|
8 | 8 |
__PACKAGE__->meta->initialize; |
9 | 9 |
|
10 |
__PACKAGE__->after_save('_after_save_ensure_only_one_marked_as_default_per_customer'); |
|
11 |
|
|
12 |
sub _after_save_ensure_only_one_marked_as_default_per_customer { |
|
13 |
my ($self) = @_; |
|
14 |
|
|
15 |
if ($self->id && $self->customer_id && $self->default_address) { |
|
16 |
SL::DB::Manager::AdditionalBillingAddress->update_all( |
|
17 |
set => { default_address => 0 }, |
|
18 |
where => [ |
|
19 |
customer_id => $self->customer_id, |
|
20 |
'!id' => $self->id, |
|
21 |
], |
|
22 |
); |
|
23 |
} |
|
24 |
|
|
25 |
return 1; |
|
26 |
} |
|
27 |
|
|
10 | 28 |
sub displayable_id { |
11 | 29 |
my $self = shift; |
12 | 30 |
my $text = join('; ', grep { $_ } (map({ $self->$_ } qw(name street)), |
locale/de/all | ||
---|---|---|
538 | 538 |
'CSV Export successful!' => 'CSV-Export erfolgreich!', |
539 | 539 |
'CSV export' => 'CSV-Export', |
540 | 540 |
'CSV export -- options' => 'CSV-Export -- Optionen', |
541 |
'CSV import: additional billing addresses' => 'CSV-Import: zusätzliche Rechnungsadressen', |
|
541 | 542 |
'CSV import: ar transactions' => 'CSV Import: Debitorenbuchungen', |
542 | 543 |
'CSV import: bank transactions' => 'CSV Import: Bankbewegungen', |
543 | 544 |
'CSV import: contacts' => 'CSV-Import: Ansprechpersonen', |
... | ... | |
995 | 996 |
'Default Transfer with services' => 'Ein- /Auslagern von Dienstleistungen über Standard-Lagerplatz', |
996 | 997 |
'Default Warehouse' => 'Standard-Lager', |
997 | 998 |
'Default Warehouse with ignoring onhand' => 'Standard-Lager für Auslagern ohne Prüfung auf Bestand', |
999 |
'Default address flag' => 'Standard-Adresse-Schalter', |
|
998 | 1000 |
'Default article for converting into quotations and orders' => 'Standardartikel für Konvertierung von Pflichtenheften in Angebote und Aufträge', |
999 | 1001 |
'Default booking group' => 'Standardbuchungsgruppe', |
1000 | 1002 |
'Default client' => 'Standardmandant', |
menus/user/00-erp.yaml | ||
---|---|---|
1354 | 1354 |
params: |
1355 | 1355 |
action: CsvImport/new |
1356 | 1356 |
profile.type: contacts |
1357 |
- parent: system_import_csv |
|
1358 |
id: system_import_csv_additional_billing_address |
|
1359 |
name: Additional Billing Addresses |
|
1360 |
order: 250 |
|
1361 |
params: |
|
1362 |
action: CsvImport/new |
|
1363 |
profile.type: billing_addresses |
|
1357 | 1364 |
- parent: system_import_csv |
1358 | 1365 |
id: system_import_csv_shipto |
1359 | 1366 |
name: Shipto |
Auch abrufbar als: Unified diff
CSV-Import von zusätzlichen Rechnungsadressen