From: Sven Schöling Date: Mon, 20 Feb 2012 15:58:49 +0000 (+0100) Subject: SL::DB::Shipto: used und detach Methoden X-Git-Tag: release-2.7.0rc1~23 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d6dbee343cd1feeab87638092ae5f8aaec2bfadb;p=kivitendo-erp.git SL::DB::Shipto: used und detach Methoden --- diff --git a/SL/DB/Shipto.pm b/SL/DB/Shipto.pm index eba1b6a6b..2492ac7ec 100644 --- a/SL/DB/Shipto.pm +++ b/SL/DB/Shipto.pm @@ -19,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;