+ # Map description to ID if given.
+ if (!$object->department_id && $entry->{raw_data}->{department}) {
+ my $dep = $self->departments_by->{description}->{ $entry->{raw_data}->{department} };
+ if (!$dep) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid department');
+ return 0;
+ }
+
+ $object->department_id($dep->id);
+ }
+
+ return 1;
+}
+
+sub check_project {
+ my ($self, $entry, %params) = @_;
+
+ my $id_column = ($params{global} ? 'global' : '') . 'project_id';
+ my $number_column = ($params{global} ? 'global' : '') . 'projectnumber';
+ my $description_column = ($params{global} ? 'global' : '') . 'project';
+
+ my $object = $entry->{object};
+
+ # Check wether or not projetc ID is valid.
+ if ($object->$id_column && !$self->projects_by->{id}->{ $object->$id_column }) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
+ return 0;
+ }
+
+ # Map number to ID if given.
+ if (!$object->$id_column && $entry->{raw_data}->{$number_column}) {
+ my $proj = $self->projects_by->{projectnumber}->{ $entry->{raw_data}->{$number_column} };
+ if (!$proj) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
+ return 0;
+ }
+
+ $object->$id_column($proj->id);
+ }
+
+ # Map description to ID if given.
+ if (!$object->$id_column && $entry->{raw_data}->{$description_column}) {
+ my $proj = $self->projects_by->{description}->{ $entry->{raw_data}->{$description_column} };
+ if (!$proj) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
+ return 0;
+ }
+
+ $object->$id_column($proj->id);
+ }
+
+ return 1;
+}
+
+sub check_ct_shipto {
+ my ($self, $entry) = @_;
+
+ my $object = $entry->{object};
+
+ my $trans_id = $object->customer_id || $object->vendor_id;
+ return 0 unless $trans_id;
+
+ # Check wether or not shipto ID is valid.
+ if ($object->shipto_id && !$self->ct_shiptos_by->{'trans_id+shipto_id'}->{ $trans_id . '+' . $object->shipto_id }) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid shipto');
+ return 0;
+ }
+
+ return 1;
+}
+
+sub check_taxzone {
+ my ($self, $entry) = @_;
+
+ my $object = $entry->{object};
+
+ # Check wether or not taxzone ID is valid.
+ if ($object->taxzone_id && !$self->taxzones_by->{id}->{ $object->taxzone_id }) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid taxzone');
+ return 0;
+ }
+
+ # Map description to ID if given.
+ if (!$object->taxzone_id && $entry->{raw_data}->{taxzone}) {
+ my $taxzone = $self->taxzones_by->{description}->{ $entry->{raw_data}->{taxzone} };
+ if (!$taxzone) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid taxzone');
+ return 0;
+ }
+
+ $object->taxzone_id($taxzone->id);
+ }
+
+ return 1;
+}
+
+
+sub check_price_factor {
+ my ($self, $entry) = @_;
+
+ my $object = $entry->{object};
+
+ # Check wether or not price_factor ID is valid.
+ if ($object->price_factor_id && !$self->price_factors_by->{id}->{ $object->price_factor_id }) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid price factor');
+ return 0;
+ }
+
+ # Map description to ID if given.
+ if (!$object->price_factor_id && $entry->{raw_data}->{price_factor}) {
+ my $price_factor = $self->price_factors_by->{description}->{ $entry->{raw_data}->{price_factor} };
+ if (!$price_factor) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid price factor');
+ return 0;
+ }
+
+ $object->price_factor_id($price_factor->id);