epic-ts
[kivitendo-erp.git] / SL / DB / TaxZone.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::TaxZone;
5
6 use strict;
7
8 use SL::DB::MetaSetup::TaxZone;
9 use SL::DB::Manager::TaxZone;
10 use SL::DB::Helper::ActsAsList;
11
12 __PACKAGE__->meta->initialize;
13
14 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
15 #__PACKAGE__->meta->make_manager_class;
16
17 sub validate {
18   my ($self) = @_;
19
20   my @errors;
21   push @errors, $::locale->text('The description is missing.') if !$self->description;
22
23   return @errors;
24 }
25
26 sub orphaned {
27   my ($self) = @_;
28   die 'not an accessor' if @_ > 1;
29
30   my @classes = qw(Customer Vendor Invoice Order DeliveryOrder PurchaseInvoice);
31   foreach my $class ( @classes ) {
32     my $module = 'SL::DB::' . $class;
33     eval "require $module";
34     my $manager = 'SL::DB::Manager::' . $class;
35     return 0 if $manager->get_all_count( query  => [ taxzone_id => $self->id ] );
36   };
37   return 1;
38 }
39
40 1;