From 0395c0364adb8fde7442c6b11ab064e406fd7776 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Fri, 30 Jan 2015 07:22:59 +0100 Subject: [PATCH] ar/ap/gl - neues Relationship "transactions" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Objekt-Verknüpfung ar/ap/gl zu acc_trans-Objekten: one-to-many Hat man ein ar/ap/gl Objekt kann man sich jetzt alle acc_trans-Einträge dazu holen. Die acc_trans-Objekte werden nach acc_trans_id sortiert zurückgegeben. Die Methode transactions aus Invoice wurde entfernt. --- SL/DB/GLTransaction.pm | 15 ++++++++++++++- SL/DB/Invoice.pm | 18 +++++++++--------- SL/DB/PurchaseInvoice.pm | 7 +++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/SL/DB/GLTransaction.pm b/SL/DB/GLTransaction.pm index 078e2b981..52c8b6e2e 100644 --- a/SL/DB/GLTransaction.pm +++ b/SL/DB/GLTransaction.pm @@ -4,11 +4,24 @@ use strict; use SL::DB::MetaSetup::GLTransaction; -__PACKAGE__->meta->initialize; # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; +__PACKAGE__->meta->add_relationship( + transactions => { + type => 'one to many', + class => 'SL::DB::AccTransaction', + column_map => { id => 'trans_id' }, + manager_args => { + with_objects => [ 'chart' ], + sort_by => 'acc_trans_id ASC', + }, + }, +); + +__PACKAGE__->meta->initialize; + sub abbreviation { my $self = shift; diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 7626793c2..08c580973 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -45,6 +45,15 @@ __PACKAGE__->meta->add_relationship( column_map => { id => 'trans_id' }, query_args => [ module => 'AR' ], }, + transactions => { + type => 'one to many', + class => 'SL::DB::AccTransaction', + column_map => { id => 'trans_id' }, + manager_args => { + with_objects => [ 'chart' ], + sort_by => 'acc_trans_id ASC', + }, + }, ); __PACKAGE__->meta->initialize; @@ -351,15 +360,6 @@ sub customervendor { goto &customer; } -sub transactions { - my ($self) = @_; - - return unless $self->id; - - require SL::DB::AccTransaction; - SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $self->id ]); -} - 1; __END__ diff --git a/SL/DB/PurchaseInvoice.pm b/SL/DB/PurchaseInvoice.pm index a54f1bd4c..d5955c57c 100644 --- a/SL/DB/PurchaseInvoice.pm +++ b/SL/DB/PurchaseInvoice.pm @@ -31,6 +31,13 @@ __PACKAGE__->meta->add_relationship( column_map => { id => 'trans_id' }, query_args => [ module => 'AP' ], }, + transactions => { + type => 'one to many', + class => 'SL::DB::AccTransaction', + column_map => { id => 'trans_id' }, + manager_args => { with_objects => [ 'chart' ], + sort_by => 'acc_trans_id ASC' } + }, ); __PACKAGE__->meta->initialize; -- 2.20.1