From 073ee5417d9f7e0d680d2cc7bc912615d3da49a8 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Mon, 29 Jun 2015 11:37:22 +0200 Subject: [PATCH] =?utf8?q?record=20Aliase=20f=C3=BCr=20Items?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- SL/DB/DeliveryOrderItem.pm | 2 ++ SL/DB/InvoiceItem.pm | 8 ++++++++ SL/DB/OrderItem.pm | 3 +++ 3 files changed, 13 insertions(+) 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; -- 2.20.1