kivitendo/SL/DB/GLTransaction.pm @ 6ef53d3f
82515b2d | Sven Schöling | package SL::DB::GLTransaction;
|
||
use strict;
|
||||
use SL::DB::MetaSetup::GLTransaction;
|
||||
bfb31beb | Geoffrey Richardson | use SL::Locale::String qw(t8);
|
||
0abce1b8 | Geoffrey Richardson | use List::Util qw(sum);
|
||
2d7e4203 | Sven Schöling | |||
82515b2d | Sven Schöling | # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
|
||
__PACKAGE__->meta->make_manager_class;
|
||||
0395c036 | Geoffrey Richardson | __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;
|
||||
f6ed86ef | Geoffrey Richardson | sub abbreviation {
|
||
my $self = shift;
|
||||
my $abbreviation = $::locale->text('GL Transaction (abbreviation)');
|
||||
$abbreviation .= "(" . $::locale->text('Storno (one letter abbreviation)') . ")" if $self->storno;
|
||||
return $abbreviation;
|
||||
6a12a968 | Niclas Zimmermann | }
|
||
bfb31beb | Geoffrey Richardson | sub displayable_type {
|
||
return t8('GL Transaction');
|
||||
}
|
||||
a5e4f9ca | Geoffrey Richardson | sub oneline_summary {
|
||
my ($self) = @_;
|
||||
0abce1b8 | Geoffrey Richardson | 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);
|
||||
a5e4f9ca | Geoffrey Richardson | }
|
||
6a12a968 | Niclas Zimmermann | sub link {
|
||
my ($self) = @_;
|
||||
my $html;
|
||||
$html = SL::Presenter->get->gl_transaction($self, display => 'inline');
|
||||
return $html;
|
||||
}
|
||||
f6ed86ef | Geoffrey Richardson | |||
6a12a968 | Niclas Zimmermann | sub invnumber {
|
||
return $_[0]->reference;
|
||||
f6ed86ef | Geoffrey Richardson | }
|
||
82515b2d | Sven Schöling | 1;
|