From 1f250cc904dbdce75118f73b5cae48590dc921e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 18 Sep 2015 12:29:12 +0200 Subject: [PATCH] =?utf8?q?Auftrags-Controller:=20Option=20f=C3=BCr=20"Steu?= =?utf8?q?er=20im=20Preis=20inbegriffen"=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … hier fehlt noch die Vorauswahl bei neuen Belegen. --- SL/Controller/Order.pm | 22 +++++++++++++++---- templates/webpages/order/tabs/_tax_row.html | 8 ++++++- templates/webpages/order/tabs/basic_data.html | 13 +++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 48ebf3067..f82ecf5e8 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -264,6 +264,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)) @@ -351,7 +363,7 @@ sub build_tax_rows { my $rows_as_html; foreach my $tax (@{ $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; } @@ -380,11 +392,13 @@ sub _recalc { $self->order->currency_id($::instance_conf->get_currency_id()); my %pat = $self->order->calculate_prices_and_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 f100a5f2c..11d456a26 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -205,16 +205,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 %] -- 2.20.1
+ + [% 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 %]