X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FInvoice.pm;h=08c5809731613b643543501acbd455090d7e87cc;hb=0395c0364adb8fde7442c6b11ab064e406fd7776;hp=a84324c40e471ca7eb8d9da696294ec604da8223;hpb=f9fdf190e4050f7eb8009467a47918340a9b975e;p=kivitendo-erp.git diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index a84324c40..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; @@ -69,7 +78,7 @@ sub add_items { goto &add_invoiceitems; } sub items_sorted { my ($self) = @_; - return [ sort {$a->id <=> $b->id } @{ $self->items } ]; + return [ sort {$a->position <=> $b->position } @{ $self->items } ]; } sub is_sales { @@ -330,27 +339,25 @@ sub displayable_type { } sub abbreviation { - my $self = shift; + my ($self) = @_; - return t8('AR Transaction (abbreviation)') if !$self->invoice; - return t8('Credit note (one letter abbreviation)') if $self->type eq 'credit_note' && $self->amount < 0 && !$self->storno; - return t8('Invoice (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->type ne 'credit_note' && $self->amount < 0 && $self->storno; - return t8('Credit note (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->type eq 'credit_note' && $self->amount > 0 && $self->storno; + return t8('AR Transaction (abbreviation)') if $self->invoice_type eq 'ar_transaction'; + return t8('Credit note (one letter abbreviation)') if $self->invoice_type eq 'credit_note'; + return t8('Invoice (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->invoice_type eq 'invoice_storno'; + return t8('Credit note (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->invoice_type eq 'credit_note_storno'; return t8('Invoice (one letter abbreviation)'); - } sub date { goto &transdate; } -sub transactions { - my ($self) = @_; - - return unless $self->id; +sub reqdate { + goto &duedate; +} - require SL::DB::AccTransaction; - SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $self->id ]); +sub customervendor { + goto &customer; } 1;