Auftrags-Controller: Option für "Steuer im Preis inbegriffen" …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 18 Sep 2015 10:29:12 +0000 (12:29 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 16 Nov 2015 15:15:57 +0000 (16:15 +0100)
… hier fehlt noch die Vorauswahl bei neuen Belegen.

SL/Controller/Order.pm
templates/webpages/order/tabs/_tax_row.html
templates/webpages/order/tabs/basic_data.html

index 48ebf30..f82ecf5 100644 (file)
@@ -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}};
index 010da3f..aa09a3a 100644 (file)
@@ -4,6 +4,12 @@
 [%- USE L %]
 
 <tr class="tax_row">
-  <th align="right">[%- TAX.tax.taxdescription %] [% TAX.tax.rate_as_percent %]%</th>
+  <th align="right">[%- IF TAXINCLUDED %][%- 'Including' | $T8 %]&nbsp;[%- END %][%- TAX.tax.taxdescription %] [% TAX.tax.rate_as_percent %]%</th>
   <td align="right">[%- LxERP.format_amount(TAX.amount, 2, 0) %]</td>
 </tr>
+[%- IF TAXINCLUDED %]
+<tr class="tax_row">
+  <th align="right">[%- 'Net amount' | $T8 %]</th>
+  <td align="right">[%- LxERP.format_amount(TAX.netamount, 2, 0) %]</td>
+</tr>
+[%- END%]
index f100a5f..11d456a 100644 (file)
 
             <td align="right">
               <table>
-                [%- IF NOT taxincluded %]
-                <tr>
+                <tr id="taxincluded_row_id" [%- IF !SELF.taxes.size %]style="display:none"[%- END %]>
+                  <td align=right colspan="2">
+                    <label for="order.taxincluded"><b>[% 'Tax Included' | $T8 %]</b></label>
+                    [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %]
+                  </td>
+                </tr>
+
+                <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
                   <th align="right">[%- 'Subtotal' | $T8 %]</th>
                   <td align="right">
                     [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
                   </td>
                 </tr>
-                [%- 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 %]
                 <tr id="amount_row_id">
                   <th align="right">[%- 'Total' | $T8 %]</th>