X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FShipto.pm;h=2492ac7ec7dceee699ed392d6543a7a009c9a9b1;hb=8a40e3dd0f638557b8c666fe708ccbc1ac709c4e;hp=98b7ca139a34ce921f05e3a4a8e9429245418ce3;hpb=82515b2d93dc5632f24d6e0b6f8f05f3fd19fbb0;p=kivitendo-erp.git diff --git a/SL/DB/Shipto.pm b/SL/DB/Shipto.pm index 98b7ca139..2492ac7ec 100644 --- a/SL/DB/Shipto.pm +++ b/SL/DB/Shipto.pm @@ -1,12 +1,11 @@ package SL::DB::Shipto; use strict; -use Readonly; use SL::DB::MetaSetup::Shipto; -Readonly our @SHIPTO_VARIABLES => qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact - shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2); +our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact + shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2); __PACKAGE__->meta->make_manager_class; @@ -20,4 +19,23 @@ sub displayable_id { return $text; } +sub used { + my ($self) = @_; + + return unless $self->shipto_id; + + require SL::DB::Order; + require SL::DB::Invoice; + require SL::DB::DeliveryOrder; + + return SL::DB::Manager::Order->get_all_count(query => [ shipto_id => $self->shipto_id ]) + || SL::DB::Manager::Invoice->get_all_count(query => [ shipto_id => $self->shipto_id ]) + || SL::DB::Manager::DeliveryOrder->get_all_count(query => [ shipto_id => $self->shipto_id ]); +} + +sub detach { + $_[0]->trans_id(undef); + $_[0]; +} + 1;