X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FShipto.pm;h=b8868ab1e15a8af03d1850fd41b551bdbf5ef613;hb=978a03de40e5710c6ca346a3dafb93352ecc7775;hp=eba1b6a6b1b41c2d74d7504beacfaf5fc12dbf3e;hpb=dc04e2cb4bd0d16a34e590ae442775230b3ed28c;p=kivitendo-erp.git diff --git a/SL/DB/Shipto.pm b/SL/DB/Shipto.pm index eba1b6a6b..b8868ab1e 100644 --- a/SL/DB/Shipto.pm +++ b/SL/DB/Shipto.pm @@ -3,11 +3,13 @@ package SL::DB::Shipto; use strict; use SL::DB::MetaSetup::Shipto; +use SL::DB::Manager::Shipto; +use Rose::DB::Object::Helpers qw(clone_and_reset clone); our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2); -__PACKAGE__->meta->make_manager_class; +__PACKAGE__->meta->initialize; sub displayable_id { my $self = shift; @@ -19,4 +21,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;