X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FInvoice.pm;h=26faca1a36f70811b7b200c77147d83d64fbdcb5;hb=7520cd583a92860e2a33ee0b3155fd1695cc21bf;hp=0e27f8adfbd88420c480a14c04b6010582715d77;hpb=35429440e41f131dfc153e67c8ae3c2680353736;p=kivitendo-erp.git diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 0e27f8adf..26faca1a3 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -13,9 +13,11 @@ use SL::DB::Helper::AttrHTML; use SL::DB::Helper::AttrSorted; use SL::DB::Helper::FlattenToForm; use SL::DB::Helper::LinkedRecords; +use SL::DB::Helper::PDF_A; use SL::DB::Helper::PriceTaxCalculator; use SL::DB::Helper::PriceUpdater; use SL::DB::Helper::TransNumberGenerator; +use SL::DB::Helper::ZUGFeRD; use SL::Locale::String qw(t8); use SL::DB::CustomVariable; @@ -154,7 +156,7 @@ sub new_from { my (@columns, @item_columns, $item_parent_id_column, $item_parent_column); if (ref($source) eq 'SL::DB::Order') { - @columns = qw(quonumber delivery_customer_id delivery_vendor_id); + @columns = qw(quonumber delivery_customer_id delivery_vendor_id tax_point); @item_columns = qw(subtotal); $item_parent_id_column = 'trans_id'; @@ -171,8 +173,8 @@ sub new_from { $terms = $source->customer->payment_terms if !defined $terms && $source->customer; my %args = ( map({ ( $_ => $source->$_ ) } qw(customer_id taxincluded shippingpoint shipvia notes intnotes salesman_id cusordnumber ordnumber department_id - cp_id language_id taxzone_id globalproject_id transaction_description currency_id delivery_term_id), @columns), - transdate => DateTime->today_local, + cp_id language_id taxzone_id tax_point globalproject_id transaction_description currency_id delivery_term_id), @columns), + transdate => $params{transdate} // DateTime->today_local, gldate => DateTime->today_local, duedate => $terms ? $terms->calc_date(reference_date => DateTime->today_local) : DateTime->today_local, invoice => 1, @@ -273,7 +275,7 @@ sub post { $self->_post_add_acctrans($data{amounts_cogs}); $self->_post_add_acctrans($data{amounts}); - $self->_post_add_acctrans($data{taxes}); + $self->_post_add_acctrans($data{taxes_by_chart_id}); $self->_post_add_acctrans({ $params{ar_id} => $self->amount * -1 }); @@ -303,14 +305,16 @@ sub _post_add_acctrans { $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, - chart_link => $chart_link)->save; + if ($spec->{amount} != 0) { + 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, + chart_link => $chart_link)->save; + } } } @@ -362,6 +366,7 @@ sub add_ar_amount_row { chart_id => $params{chart}->id, chart_link => $params{chart}->link, transdate => $self->transdate, + gldate => $self->gldate, taxkey => $tax->taxkey, tax_id => $tax->id, project_id => $params{project_id}, @@ -376,6 +381,7 @@ sub add_ar_amount_row { chart_id => $tax->chart_id, chart_link => $tax->chart->link, transdate => $self->transdate, + gldate => $self->gldate, taxkey => $tax->taxkey, tax_id => $tax->id, ); @@ -603,6 +609,12 @@ sub mark_as_paid { $self->update_attributes(paid => $self->amount); } +sub effective_tax_point { + my ($self) = @_; + + return $self->tax_point || $self->deliverydate || $self->transdate; +} + 1; __END__