X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FShipto.pm;h=5e2813d2fe6eb2ee66d462b1c52239dd9905aadf;hb=c7241bf7c547d63999898dee7b5dd486e4d122d3;hp=eba1b6a6b1b41c2d74d7504beacfaf5fc12dbf3e;hpb=1afeb79d3815487fa4b0a021e9de3b198417f453;p=kivitendo-erp.git diff --git a/SL/DB/Shipto.pm b/SL/DB/Shipto.pm index eba1b6a6b..5e2813d2f 100644 --- a/SL/DB/Shipto.pm +++ b/SL/DB/Shipto.pm @@ -3,11 +3,16 @@ package SL::DB::Shipto; use strict; use SL::DB::MetaSetup::Shipto; +use SL::DB::Manager::Shipto; +use SL::DB::Helper::CustomVariables ( + module => 'ShipTo', + cvars_alias => 1, +); -our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact +our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptogln shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2); -__PACKAGE__->meta->make_manager_class; +__PACKAGE__->meta->initialize; sub displayable_id { my $self = shift; @@ -19,4 +24,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;