X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FInvoice.pm;h=dd26532e025193cbffe851fcd5ebecb05830c42a;hb=03ff37cb621e68f7d224d2520099ee86f612f833;hp=c6658413568220b28d3a3b58a34dcab42903ada5;hpb=8a40e3dd0f638557b8c666fe708ccbc1ac709c4e;p=kivitendo-erp.git diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index c66584135..dd26532e0 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -28,35 +28,10 @@ __PACKAGE__->meta->add_relationship( with_objects => [ 'part' ] } }, - payment_term => { - type => 'one to one', - class => 'SL::DB::PaymentTerm', - column_map => { payment_id => 'id' }, - }, - contact => { - type => 'one to one', - class => 'SL::DB::Contact', - column_map => { cp_id => 'cp_id' }, - }, - shipto => { - type => 'one to one', - class => 'SL::DB::Shipto', - column_map => { shipto_id => 'shipto_id' }, - }, - department => { - type => 'one to one', - class => 'SL::DB::Department', - column_map => { department_id => 'id' }, - }, - language => { - type => 'one to one', - class => 'SL::DB::Language', - column_map => { language_id => 'id' }, - }, - employee => { - type => 'one to one', - class => 'SL::DB::Employee', - column_map => { employee_id => 'id' }, + storno_invoices => { + type => 'one to many', + class => 'SL::DB::Invoice', + column_map => { id => 'storno_id' }, }, ); @@ -66,6 +41,12 @@ __PACKAGE__->meta->initialize; sub items { goto &invoiceitems; } +sub is_sales { + # For compatibility with Order, DeliveryOrder + croak 'not an accessor' if @_ > 1; + return 1; +} + # it is assumed, that ordnumbers are unique here. sub first_order_by_ordnumber { my $self = shift; @@ -188,11 +169,14 @@ sub post { sub _post_add_acctrans { my ($self, $entries) = @_; + my $default_tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id; + 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; 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;