From d6dbee343cd1feeab87638092ae5f8aaec2bfadb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 20 Feb 2012 16:58:49 +0100 Subject: [PATCH] SL::DB::Shipto: used und detach Methoden --- SL/DB/Shipto.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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; -- 2.20.1