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