From: G. Richardson Date: Mon, 29 Jun 2015 09:37:22 +0000 (+0200) Subject: record Aliase für Items X-Git-Tag: release-3.3.0beta~31^2~49 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=073ee5417d9f7e0d680d2cc7bc912615d3da49a8;p=kivitendo-erp.git record Aliase für Items damit man von DeliveryOrderItem, OrderItem und InvoiceItem direkt auf das entsprechende ar/ap/do/oe Objekte verweisen kann. Beispiel in console: die erste Position aus der ersten Rechnung: my $item = SL::DB::Manager::Invoice->get_first()->items->[0]; alle dorthin verknüpften Items (wenn aus Angebot, Auftrag und Lieferschein generiert) my $linkeditems = $item->linked_records( direction => 'from', recursive => 1 ); in was für records befinden sich diese verknüpften Positionen: foreach ( @$linkeditems ) { print $_->record->type, "\n" }; sales_quotation sales_order sales_delivery_order --- diff --git a/SL/DB/DeliveryOrderItem.pm b/SL/DB/DeliveryOrderItem.pm index fa2281797..de7587cfd 100644 --- a/SL/DB/DeliveryOrderItem.pm +++ b/SL/DB/DeliveryOrderItem.pm @@ -24,4 +24,6 @@ __PACKAGE__->configure_acts_as_list(group_by => [qw(delivery_order_id)]); # methods +sub record { goto &delivery_order } + 1; diff --git a/SL/DB/InvoiceItem.pm b/SL/DB/InvoiceItem.pm index 1a18abc2b..a20f56fc9 100644 --- a/SL/DB/InvoiceItem.pm +++ b/SL/DB/InvoiceItem.pm @@ -36,4 +36,12 @@ __PACKAGE__->meta->add_relationships( __PACKAGE__->meta->initialize; +sub record { + my ($self) = @_; + + return $self->invoice if $self->invoice; + return $self->purchase_invoice if $self->purchase_invoice; + return; +}; + 1; diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index 96ca50555..6ab16ac2a 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -90,4 +90,7 @@ sub taxincluded { return SL::DB::Manager::Order->find_by(id => $self->trans_id)->taxincluded ? $::locale->text('WARN: Tax included value!') : ''; } + +sub record { goto &order } + 1;