X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FDB%2FGLTransaction.pm;h=2ad8e0c0dd24c7da90f220c1b354585e7590a6ee;hb=b269674b6b0e99818c3643d4fc3271a8ce83b8c6;hp=078e2b98154b05d4a08901baebcdc125bbbfc8ae;hpb=f6ed86efee2a0a38b6e88e98fd9d4403fa64ff5e;p=kivitendo-erp.git diff --git a/SL/DB/GLTransaction.pm b/SL/DB/GLTransaction.pm index 078e2b981..2ad8e0c0d 100644 --- a/SL/DB/GLTransaction.pm +++ b/SL/DB/GLTransaction.pm @@ -3,19 +3,56 @@ package SL::DB::GLTransaction; use strict; use SL::DB::MetaSetup::GLTransaction; - -__PACKAGE__->meta->initialize; +use SL::Locale::String qw(t8); +use List::Util qw(sum); # 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; my $abbreviation = $::locale->text('GL Transaction (abbreviation)'); $abbreviation .= "(" . $::locale->text('Storno (one letter abbreviation)') . ")" if $self->storno; return $abbreviation; +} + +sub displayable_type { + return t8('GL Transaction'); +} + +sub oneline_summary { + my ($self) = @_; + my $amount = sum map { $_->amount if $_->amount > 0 } @{$self->transactions}; + $amount = $::form->format_amount(\%::myconfig, $amount, 2); + return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->description, $self->reference, $amount, $self->transdate->to_kivitendo); +} + +sub link { + my ($self) = @_; + + my $html; + $html = SL::Presenter->get->gl_transaction($self, display => 'inline'); + + return $html; +} +sub invnumber { + return $_[0]->reference; } 1;