1 package SL::DB::GLTransaction;
5 use SL::DB::MetaSetup::GLTransaction;
6 use SL::Locale::String qw(t8);
7 use List::Util qw(sum);
9 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
10 __PACKAGE__->meta->make_manager_class;
12 __PACKAGE__->meta->add_relationship(
14 type => 'one to many',
15 class => 'SL::DB::AccTransaction',
16 column_map => { id => 'trans_id' },
18 with_objects => [ 'chart' ],
19 sort_by => 'acc_trans_id ASC',
24 __PACKAGE__->meta->initialize;
29 my $abbreviation = $::locale->text('GL Transaction (abbreviation)');
30 $abbreviation .= "(" . $::locale->text('Storno (one letter abbreviation)') . ")" if $self->storno;
34 sub displayable_type {
35 return t8('GL Transaction');
40 my $amount = sum map { $_->amount if $_->amount > 0 } @{$self->transactions};
41 $amount = $::form->format_amount(\%::myconfig, $amount, 2);
42 return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->description, $self->reference, $amount, $self->transdate->to_kivitendo);
49 $html = SL::Presenter->get->gl_transaction($self, display => 'inline');
55 return $_[0]->reference;