X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a93f1e395694983593c65b35427a13d68e46d380..fc44ab06e84d2546c7eb9c7c5f0586db17f01242:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index f75a6cd65..77d6769a8 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -25,17 +25,21 @@ __PACKAGE__->meta->add_relationship( class => 'SL::DB::InvoiceItem', column_map => { id => 'trans_id' }, manager_args => { - with_objects => [ 'parts' ] + with_objects => [ 'part' ] } }, + storno_invoices => { + type => 'one to many', + class => 'SL::DB::Invoice', + column_map => { id => 'storno_id' }, + }, ); __PACKAGE__->meta->initialize; # methods -sub items { goto &invoiceitems; } -sub payment_term { goto &payment; } +sub items { goto &invoiceitems; } sub is_sales { # For compatibility with Order, DeliveryOrder @@ -165,14 +169,22 @@ sub post { sub _post_add_acctrans { my ($self, $entries) = @_; + my $default_tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id; + my $chart_link; + while (my ($chart_id, $spec) = each %{ $entries }) { - $spec = { taxkey => 0, amount => $spec } unless ref $spec; + $spec = { taxkey => 0, tax_id => $default_tax_id, amount => $spec } unless ref $spec; + $chart_link = SL::DB::Manager::Chart->find_by(id => $chart_id)->{'link'}; + $chart_link ||= ''; + SL::DB::AccTransaction->new(trans_id => $self->id, chart_id => $chart_id, amount => $spec->{amount}, + tax_id => $spec->{tax_id}, taxkey => $spec->{taxkey}, project_id => $self->globalproject_id, - transdate => $self->transdate)->save; + transdate => $self->transdate, + chart_link => $chart_link)->save; } }