X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FLetter.pm;h=0753d67590d42b1f2f42b95b4db56c3b4a41efb2;hb=0ebb8f829ac2d23b65e8d993c7d03aa0b172b637;hp=27b0cff47060aca16e8592f1bfdcb70822f1b2b3;hpb=7196276bca4a155d1bcc3947859bc7d4ec1edcd6;p=kivitendo-erp.git diff --git a/SL/DB/Letter.pm b/SL/DB/Letter.pm index 27b0cff47..0753d6759 100644 --- a/SL/DB/Letter.pm +++ b/SL/DB/Letter.pm @@ -28,4 +28,28 @@ sub new_from_draft { $self; } +sub is_sales { + die 'not an accessor' if @_ > 1; + $_[0]{customer_id} * 1; +} + +sub has_customer_vendor { + my ($self) = @_; + die 'not an accessor' if @_ > 1; + + return $self->is_sales + ? ($self->customer_id && $self->customer) + : ($self->vendor_id && $self->vendor); +} + +sub customer_vendor { + die 'not an accessor' if @_ > 1; + $_[0]->is_sales ? $_[0]->customer : $_[0]->vendor; +} + +sub customer_vendor_id { + die 'not an accessor' if @_ > 1; + $_[0]->customer_id || $_[0]->vendor_id; +} + 1;