+sub check_ct_shipto {
+ my ($self, $entry) = @_;
+
+ my $object = $entry->{object};
+
+ # Check wether or not shipto ID is valid.
+ if ($object->shipto_id && !$self->ct_shiptos_by->{shipto_id}->{ $object->shipto_id }) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid shipto');
+ return 0;
+ }
+
+ # Check if the shipto belongs to this customer/vendor.
+ my $trans_id = $object->customer_id || $object->vendor_id;
+ if ($object->shipto_id && $trans_id
+ && !$self->ct_shiptos_by->{'trans_id+shipto_id'}->{ $trans_id . '+' . $object->shipto_id } ) {
+ push @{ $entry->{errors} }, $::locale->text('Error: Invalid shipto for this customer/vendor');
+ 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;
+}