Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9fa0473d

Von Bernd Bleßmann vor fast 11 Jahren hinzugefügt

  • ID 9fa0473d201f343f6d88580dc75a683578bd03ec
  • Vorgänger c4d248c6
  • Nachfolger 1d78de40

Steuersatz behandeln.

Unterschiede anzeigen:

SL/Controller/CsvImport/Order.pm
14 14
use SL::DB::Department;
15 15
use SL::DB::Project;
16 16
use SL::DB::Shipto;
17
use SL::DB::TaxZone;
17 18
use SL::TransNumber;
18 19

  
19 20
use parent qw(SL::Controller::CsvImport::BaseMulti);
......
21 22

  
22 23
use Rose::Object::MakeMethods::Generic
23 24
(
24
 'scalar --get_set_init' => [ qw(settings languages_by all_parts parts_by all_contacts contacts_by all_departments departments_by all_projects projects_by all_ct_shiptos ct_shiptos_by) ],
25
 'scalar --get_set_init' => [ qw(settings languages_by all_parts parts_by all_contacts contacts_by all_departments departments_by all_projects projects_by all_ct_shiptos ct_shiptos_by all_taxzones taxzones_by) ],
25 26
);
26 27

  
27 28

  
......
79 80
                                 { name => 'language',         description => $::locale->text('Language (name)')                },
80 81
                                 { name => 'payment_id',       description => $::locale->text('Payment terms (database ID)')    },
81 82
                                 { name => 'payment',          description => $::locale->text('Payment terms (name)')           },
82
                                 { name => 'taxzone_id',       description => $::locale->text('Steuersatz')                     },
83
                                 { name => 'taxzone_id',       description => $::locale->text('Steuersatz (database ID')        },
84
                                 { name => 'taxzone',          description => $::locale->text('Steuersatz (description)')       },
83 85
                                 { name => 'cp_id',            description => $::locale->text('Contact Person (database ID)')   },
84 86
                                 { name => 'contact',          description => $::locale->text('Contact Person (name)')          },
85 87
                                 { name => 'department_id',    description => $::locale->text('Department (database ID)')       },
......
173 175
  return $sby;
174 176
}
175 177

  
178
sub init_all_taxzones {
179
  my ($self) = @_;
180

  
181
  return SL::DB::Manager::TaxZone->get_all;
182
}
183

  
184
sub init_taxzones_by {
185
  my ($self) = @_;
186

  
187
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_taxzones } } ) } qw(id description) };
188
}
189

  
176 190
sub check_objects {
177 191
  my ($self) = @_;
178 192

  
......
202 216
      $self->check_department($entry);
203 217
      $self->check_project($entry, global => 1);
204 218
      $self->check_ct_shipto($entry);
219
      $self->check_taxzone($entry);
205 220

  
206 221
      if ($vc_obj) {
207 222
        # copy from customer if not given
......
231 246
  $self->add_info_columns($self->settings->{'order_column'},
232 247
                          { header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
233 248
  $self->add_columns($self->settings->{'order_column'},
234
                     map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw(payment language department globalproject));
249
                     map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw(payment language department globalproject taxzone));
235 250
  $self->add_columns($self->settings->{'order_column'}, 'globalproject_id') if exists $self->controller->data->[0]->{raw_data}->{globalprojectnumber};
236 251

  
237 252
  foreach my $entry (@{ $self->controller->data }) {
......
538 553
  return 1;
539 554
}
540 555

  
556
sub check_taxzone {
557
  my ($self, $entry) = @_;
558

  
559
  my $object = $entry->{object};
560

  
561
  # Check wether or not taxzone ID is valid.
562
  if ($object->taxzone_id && !$self->taxzones_by->{id}->{ $object->taxzone_id }) {
563
    push @{ $entry->{errors} }, $::locale->text('Error: Invalid taxzone');
564
    return 0;
565
  }
566

  
567
  # Map description to ID if given.
568
  if (!$object->taxzone_id && $entry->{raw_data}->{taxzone}) {
569
    my $taxzone = $self->taxzones_by->{description}->{ $entry->{raw_data}->{taxzone} };
570
    if (!$taxzone) {
571
      push @{ $entry->{errors} }, $::locale->text('Error: Invalid taxzone');
572
      return 0;
573
    }
574

  
575
    $object->taxzone_id($taxzone->id);
576
  }
577

  
578
  return 1;
579
}
541 580

  
542 581

  
543 582
sub save_objects {

Auch abrufbar als: Unified diff