CSV-Import Waren/DL/Erzeugnisse: Genauerer Beschreibung für make_X, model_X, lastcost_X
[kivitendo-erp.git] / SL / Controller / CsvImport / Shipto.pm
1 package SL::Controller::CsvImport::Shipto;
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 init_class {
15   my ($self) = @_;
16   $self->class('SL::DB::Shipto');
17 }
18
19 sub check_objects {
20   my ($self) = @_;
21
22   foreach my $entry (@{ $self->controller->data }) {
23     $self->check_vc($entry, 'trans_id');
24     $entry->{object}->module('CT');
25   }
26
27   $self->add_info_columns({ header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
28 }
29
30 sub get_duplicate_check_fields {
31   return {
32     shiptoname_and_shiptostreet => {
33       label     => $::locale->text('Name and Street'),
34       default   => 1,
35       maker     => sub {
36         my $o = shift;
37         return join(
38                  '--',
39                  $o->trans_id,
40                  map(
41                    { s/[\s,\.\-]//g; $_ }
42                    $o->shiptoname,
43                    $o->shiptostreet
44                  )
45         );
46       }
47     },
48
49     shiptoname => {
50       label     => $::locale->text('Name'),
51       default   => 1,
52       maker     => sub {
53         my $o = shift;
54         return join(
55                  '--',
56                  $o->trans_id,
57                  map(
58                    { s/[\s,\.\-]//g; $_ }
59                    $o->shiptoname
60                  )
61         );
62       }
63     },
64
65     shiptostreet => {
66       label     => $::locale->text('Street'),
67       default   => 1,
68       maker     => sub {
69         my $o = shift;
70         return join(
71                  '--',
72                  $o->trans_id,
73                  map(
74                    { s/[\s,\.\-]//g; $_ }
75                    $o->shiptostreet
76                  )
77         );
78       }
79     },
80   };
81 }
82
83 sub field_lengths {
84   return ( shiptoname         => 75,
85            shiptodepartment_1 => 75,
86            shiptodepartment_2 => 75,
87            shiptostreet       => 75,
88            shiptozipcode      => 75,
89            shiptocity         => 75,
90            shiptocountry      => 75,
91            shiptocontact      => 75,
92            shiptophone        => 30,
93            shiptofax          => 30,
94          );
95 }
96
97 sub init_profile {
98   my ($self) = @_;
99
100   my $profile = $self->SUPER::init_profile;
101   delete @{$profile}{qw(module)};
102
103   return $profile;
104 }
105
106 sub setup_displayable_columns {
107   my ($self) = @_;
108
109   $self->SUPER::setup_displayable_columns;
110
111   $self->add_displayable_columns({ name => 'shiptocity',         description => $::locale->text('City')                          },
112                                  { name => 'shiptocontact',      description => $::locale->text('Contact')                       },
113                                  { name => 'shiptocountry',      description => $::locale->text('Country')                       },
114                                  { name => 'shiptodepartment_1', description => $::locale->text('Department 1')                  },
115                                  { name => 'shiptodepartment_2', description => $::locale->text('Department 2')                  },
116                                  { name => 'shiptoemail',        description => $::locale->text('E-mail')                        },
117                                  { name => 'shiptofax',          description => $::locale->text('Fax')                           },
118                                  { name => 'shiptoname',         description => $::locale->text('Name')                          },
119                                  { name => 'shiptophone',        description => $::locale->text('Phone')                         },
120                                  { name => 'shiptostreet',       description => $::locale->text('Street')                        },
121                                  { name => 'shiptozipcode',      description => $::locale->text('Zipcode')                       },
122                                  { name => 'trans_id',           description => $::locale->text('Customer/Vendor (database ID)') },
123                                  { name => 'customer',           description => $::locale->text('Customer (name)')               },
124                                  { name => 'customernumber',     description => $::locale->text('Customer Number')               },
125                                  { name => 'vendor',             description => $::locale->text('Vendor (name)')                 },
126                                  { name => 'vendornumber',       description => $::locale->text('Vendor Number')                 },
127                                 );
128 }
129
130 1;