From: Bernd Bleßmann Date: Tue, 8 Mar 2016 14:54:15 +0000 (+0100) Subject: Auftrags-Controller: Option für "Steuer im Preis inbegriffen" X-Git-Tag: release-3.4.1~350 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=9af3ce1ca10555dff25e4762d2eb1e7fa0c1e877;p=kivitendo-erp.git Auftrags-Controller: Option für "Steuer im Preis inbegriffen" --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 496031abf..ff3aca4e3 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -137,18 +137,31 @@ sub action_customer_vendor_changed { $self->js->hide('#shipto_row'); } + $self->order->taxzone_id($self->order->$cv_method->taxzone_id); + + if ($self->order->is_sales) { + $self->order->taxincluded(defined($self->order->$cv_method->taxincluded_checked) + ? $self->order->$cv_method->taxincluded_checked + : $::myconfig{taxincluded_checked}); + } + $self->order->payment_id($self->order->$cv_method->payment_id); $self->order->delivery_term_id($self->order->$cv_method->delivery_term_id); + $self->_recalc(); + $self->js - ->replaceWith('#order_cp_id', $self->build_contact_select) - ->replaceWith('#order_shipto_id', $self->build_shipto_select) - ->val('#order_taxzone_id', $self->order->taxzone_id) - ->val('#order_payment_id', $self->order->payment_id) - ->val('#order_delivery_term_id', $self->order->delivery_term_id) - ->val('#order_intnotes', $self->order->$cv_method->notes) - ->focus('#order_' . $self->cv . '_id') - ->render($self); + ->replaceWith('#order_cp_id', $self->build_contact_select) + ->replaceWith('#order_shipto_id', $self->build_shipto_select) + ->val( '#order_taxzone_id', $self->order->taxzone_id) + ->val( '#order_taxincluded', $self->order->taxincluded) + ->val( '#order_payment_id', $self->order->payment_id) + ->val( '#order_delivery_term_id', $self->order->delivery_term_id) + ->val( '#order_intnotes', $self->order->$cv_method->notes) + ->focus( '#order_' . $self->cv . '_id'); + + $self->_js_redisplay_amounts_and_taxes; + $self->js->render(); } sub action_add_item { @@ -220,6 +233,18 @@ sub _js_redisplay_linetotals { sub _js_redisplay_amounts_and_taxes { my ($self) = @_; + if (scalar @{ $self->{taxes} }) { + $self->js->show('#taxincluded_row_id'); + } else { + $self->js->hide('#taxincluded_row_id'); + } + + if ($self->order->taxincluded) { + $self->js->hide('#subtotal_row_id'); + } else { + $self->js->show('#subtotal_row_id'); + } + $self->js ->html('#netamount_id', $::form->format_amount(\%::myconfig, $self->order->netamount, -2)) ->html('#amount_id', $::form->format_amount(\%::myconfig, $self->order->amount, -2)) @@ -303,7 +328,7 @@ sub build_tax_rows { my $rows_as_html; foreach my $tax (sort { $a->{tax}->rate cmp $b->{tax}->rate } @{ $self->{taxes} }) { - $rows_as_html .= $self->p->render('order/tabs/_tax_row', TAX => $tax); + $rows_as_html .= $self->p->render('order/tabs/_tax_row', TAX => $tax, TAXINCLUDED => $self->order->taxincluded); } return $rows_as_html; } @@ -335,8 +360,11 @@ sub _recalc { $self->{taxes} = []; foreach my $tax_chart_id (keys %{ $pat{taxes} }) { my $tax = SL::DB::Manager::Tax->find_by(chart_id => $tax_chart_id); - push(@{ $self->{taxes} }, { amount => $pat{taxes}->{$tax_chart_id}, - tax => $tax }); + + my @amount_keys = grep { $pat{amounts}->{$_}->{tax_id} == $tax->id } keys %{ $pat{amounts} }; + push(@{ $self->{taxes} }, { amount => $pat{taxes}->{$tax_chart_id}, + netamount => $pat{amounts}->{$amount_keys[0]}->{amount}, + tax => $tax }); } pairwise { $a->{linetotal} = $b->{linetotal} } @{$self->order->items}, @{$pat{items}}; diff --git a/templates/webpages/order/tabs/_tax_row.html b/templates/webpages/order/tabs/_tax_row.html index 010da3fba..aa09a3a86 100644 --- a/templates/webpages/order/tabs/_tax_row.html +++ b/templates/webpages/order/tabs/_tax_row.html @@ -4,6 +4,12 @@ [%- USE L %] - [%- TAX.tax.taxdescription %] [% TAX.tax.rate_as_percent %]% + [%- IF TAXINCLUDED %][%- 'Including' | $T8 %] [%- END %][%- TAX.tax.taxdescription %] [% TAX.tax.rate_as_percent %]% [%- LxERP.format_amount(TAX.amount, 2, 0) %] +[%- IF TAXINCLUDED %] + + [%- 'Net amount' | $T8 %] + [%- LxERP.format_amount(TAX.netamount, 2, 0) %] + +[%- END%] diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index 8d1a25701..3d7507139 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -38,7 +38,7 @@ [% 'Steuersatz' | $T8 %] - [% L.select_tag('order.taxzone_id', SELF.all_taxzones, default=SELF.order.taxzone_id, title_key='description', style='width: 300px') %] + [% L.select_tag('order.taxzone_id', SELF.all_taxzones, default=SELF.order.taxzone_id, title_key='description', style='width: 300px', class='recalc') %] @@ -210,16 +210,21 @@ - [%- IF NOT taxincluded %] - + + + + + - [%- END %] [%- FOREACH tax = SELF.taxes %] - [%- PROCESS order/tabs/_tax_row.html TAX=tax %] + [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %] [%- END %] @@ -244,10 +249,10 @@
+ + [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %] +
[%- 'Subtotal' | $T8 %] [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
[%- 'Total' | $T8 %]