Versandort und Steuersatz (Zone) im Auftragsbericht filter- und anzeigbar
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 4 Nov 2013 14:18:07 +0000 (15:18 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 6 Nov 2013 12:14:09 +0000 (13:14 +0100)
SL/OE.pm
bin/mozilla/oe.pl
templates/webpages/oe/search.html

index 12cbb8a..aaf0fae 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -88,7 +88,8 @@ sub transactions {
     qq|  ex.$rate AS exchangerate, | .
     qq|  pr.projectnumber AS globalprojectnumber, | .
     qq|  e.name AS employee, s.name AS salesman, | .
-    qq|  ct.${vc}number AS vcnumber, ct.country, ct.ustid, ct.business_id  | .
+    qq|  ct.${vc}number AS vcnumber, ct.country, ct.ustid, ct.business_id,  | .
+    qq|  tz.description AS taxzone | .
     $periodic_invoices_columns .
     qq|FROM oe o | .
     qq|JOIN $vc ct ON (o.${vc}_id = ct.id) | .
@@ -97,6 +98,7 @@ sub transactions {
     qq|LEFT JOIN exchangerate ex ON (ex.currency_id = o.currency_id | .
     qq|  AND ex.transdate = o.transdate) | .
     qq|LEFT JOIN project pr ON (o.globalproject_id = pr.id) | .
+    qq|LEFT JOIN tax_zones tz ON (o.taxzone_id = tz.id) | .
     qq|$periodic_invoices_joins | .
     qq|WHERE (o.quotation = ?) |;
   push(@values, $quotation);
@@ -192,6 +194,16 @@ SQL
     push(@values, conv_date($form->{reqdateto}));
   }
 
+  if ($form->{shippingpoint}) {
+    $query .= qq| AND o.shippingpoint ILIKE ?|;
+    push(@values, '%' . $form->{shippingpoint} . '%');
+  }
+
+  if ($form->{taxzone_id} ne '') { # taxzone_id could be 0
+    $query .= qq| AND tz.id = ?|;
+    push(@values, $form->{taxzone_id});
+  }
+
   if ($form->{transaction_description}) {
     $query .= qq| AND o.transaction_description ILIKE ?|;
     push(@values, '%' . $form->{transaction_description} . '%');
@@ -214,7 +226,9 @@ SQL
     "employee"                => "e.name",
     "salesman"                => "s.name",
     "shipvia"                 => "o.shipvia",
-    "transaction_description" => "o.transaction_description"
+    "transaction_description" => "o.transaction_description",
+    "shippingpoint"           => "o.shippingpoint",
+    "taxzone"                 => "tz.description",
   );
   if ($form->{sort} && grep($form->{sort}, keys(%allowed_sort_columns))) {
     $sortorder = $allowed_sort_columns{$form->{sort}} . " ${sortdir}";
index 6b84103..1c1135c 100644 (file)
@@ -48,6 +48,7 @@ use List::Util qw(min max reduce sum);
 use Data::Dumper;
 
 use SL::DB::Customer;
+use SL::DB::TaxZone;
 
 require "bin/mozilla/io.pl";
 require "bin/mozilla/arap.pl";
@@ -722,7 +723,8 @@ sub search {
   $form->get_lists("projects"     => { "key" => "ALL_PROJECTS", "all" => 1 },
                    "departments"  => "ALL_DEPARTMENTS",
                    "$form->{vc}s" => "ALL_VC",
-                   "business_types" => "ALL_BUSINESS_TYPES");
+                   "taxzones"     => "ALL_TAXZONES",
+                   "business_types" => "ALL_BUSINESS_TYPES",);
   $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
 
   # constants and subs for template
@@ -792,7 +794,8 @@ sub orders {
     "delivered",               "periodic_invoices",
     "marge_total",             "marge_percent",
     "vcnumber",                "ustid",
-    "country",
+    "country",                 "shippingpoint",
+    "taxzone",
   );
 
   # only show checkboxes if gotten here via sales_order form.
@@ -831,9 +834,12 @@ sub orders {
   push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
                                                         transaction_description transdatefrom transdateto type vc employee_id salesman_id
                                                         reqdatefrom reqdateto projectnumber project_id periodic_invoices_active periodic_invoices_inactive
-                                                        business_id);
+                                                        business_id shippingpoint taxzone_id);
 
-  my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
+  my   @keys_for_url = grep { $form->{$_} } @hidden_variables;
+  push @keys_for_url, 'taxzone_id' if $form->{taxzone_id} ne ''; # taxzone_id could be 0
+
+  my $href = build_std_url('action=orders', @keys_for_url);
 
   my %column_defs = (
     'ids'                     => { 'text' => '', },
@@ -861,9 +867,11 @@ sub orders {
     'country'                 => { 'text' => $locale->text('Country'), },
     'ustid'                   => { 'text' => $locale->text('USt-IdNr.'), },
     'periodic_invoices'       => { 'text' => $locale->text('Per. Inv.'), },
+    'shippingpoint'           => { 'text' => $locale->text('Shipping Point'), },
+    'taxzone'                 => { 'text' => $locale->text('Steuersatz'), },
   );
 
-  foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee salesman shipvia transaction_description)) {
+  foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee salesman shipvia transaction_description shippingpoint taxzone)) {
     my $sortdir                 = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
     $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir";
   }
@@ -888,6 +896,7 @@ sub orders {
   push @options, $locale->text('Order Number')            . " : $form->{ordnumber}"                       if $form->{ordnumber};
   push @options, $locale->text('Notes')                   . " : $form->{notes}"                           if $form->{notes};
   push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"         if $form->{transaction_description};
+  push @options, $locale->text('Shipping Point')          . " : $form->{shippingpoint}"                   if $form->{shippingpoint};
   if ( $form->{transdatefrom} or $form->{transdateto} ) {
     push @options, $locale->text('Order Date');
     push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1)     if $form->{transdatefrom};
@@ -908,6 +917,9 @@ sub orders {
     my $vc_type_label = $form->{vc} eq 'customer' ? $locale->text('Customer type') : $locale->text('Vendor type');
     push @options, $vc_type_label . " : " . SL::DB::Business->new(id => $form->{business_id})->load->description;
   }
+  if ($form->{taxzone_id} ne '') { # taxzone_id could be 0
+    push @options, $locale->text('Steuersatz') . " : " . SL::DB::TaxZone->new(id => $form->{taxzone_id})->load->description;
+  }
 
   $report->set_options('top_info_text'        => join("\n", @options),
                        'raw_top_info_text'    => $form->parse_html_template('oe/orders_top'),
index c71e60f..8d76ecb 100644 (file)
      <th align="right">[% 'Salesman' | $T8 %]</th>
      <td>[% L.select_tag('salesman_id', ALL_EMPLOYEES, title_key='safe_name', with_empty=1, style='width:250px') %]</td>
     </tr>
+    <tr>
+     <th align="right">[% 'Steuersatz' | $T8 %]</th>
+     <td>[% L.select_tag('taxzone_id', ALL_TAXZONES, with_empty=1, title_key='description', style='width: 250px') %]</td>
+    </tr>
+    <tr>
+     <th align="right">[% 'Shipping Point' | $T8 %]</th>
+     <td colspan="3">[% L.input_tag('shippingpoint', '', style='width:250px') %]</td>
+    </tr>
     <tr>
      <th align="right">[% 'Transaction description' | $T8 %]</th>
      <td colspan="3"><input name="transaction_description" style="width: 250px"></td>
          <input name="l_customernumber" id="l_customernumber" class="checkbox" type="checkbox" value="Y">
          <label for="l_customernumber">[% 'Customer Number' | $T8 %]</label>
         </td>
+        <td>[%- L.checkbox_tag('l_taxzone',       label => LxERP.t8('Steuersatz'))     %]</td>
+        <td>[%- L.checkbox_tag('l_shippingpoint', label => LxERP.t8('Shipping Point')) %]</td>
        </tr>
        <tr>
         <td>