Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 8 Nov 2012 11:41:59 +0000 (12:41 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 8 Nov 2012 11:41:59 +0000 (12:41 +0100)
12 files changed:
SL/CT.pm
SL/Controller/ClientConfig.pm
SL/DBUpgrade2.pm
SL/IC.pm
bin/mozilla/am.pl
css/kivitendo/menu.css
css/lx-office-erp/menu.css
locale/de/all
locale/de_DE/all
scripts/dbupgrade2_tool.pl
templates/webpages/is/form_header.html
templates/webpages/rp/report.html

index de10623..93c3fce 100644 (file)
--- a/SL/CT.pm
+++ b/SL/CT.pm
@@ -598,6 +598,7 @@ sub search {
   my $dbh = $form->dbconnect($myconfig);
 
   my $cv = $form->{db} eq "customer" ? "customer" : "vendor";
+  my $join_records = $form->{l_invnumber} || $form->{l_ordnumber} || $form->{l_quonumber};
 
   my $where = "1 = 1";
   my @values;
@@ -611,7 +612,7 @@ sub search {
   $form->{sort} = $sortorder;
   my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
 
-  if ($sortorder !~ /(business|id)/ && 1 >= scalar grep { $form->{$_} } qw(l_ordnumber l_quonumber l_invnumber )) {
+  if ($sortorder !~ /(business|id)/ && !$join_records) {
     $sortorder  = "lower($sortorder) ${sortdir}";
   } else {
     $sortorder .= " ${sortdir}";
@@ -705,21 +706,22 @@ sub search {
 
   my $query =
     qq|SELECT ct.*, b.description AS business | .
+    (qq|, NULL AS invnumber, NULL AS ordnumber, NULL AS quonumber, NULL AS invid, NULL AS module, NULL AS formtype, NULL AS closed | x!! $join_records) .
     qq|FROM $cv ct | .
     qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
     qq|WHERE $where|;
 
   my @saved_values = @values;
   # redo for invoices, orders and quotations
-  if ($form->{l_invnumber} || $form->{l_ordnumber} || $form->{l_quonumber}) {
-    my ($ar, $union, $module);
-    $query = "";
+  if ($join_records) {
+    my $union = "UNION";
 
     if ($form->{l_invnumber}) {
       my $ar = $cv eq 'customer' ? 'ar' : 'ap';
       my $module = $ar eq 'ar' ? 'is' : 'ir';
-
-      $query =
+      push(@values, @saved_values);
+      $query .=
+        qq| UNION | .
         qq|SELECT ct.*, b.description AS business, | .
         qq|  a.invnumber, a.ordnumber, a.quonumber, a.id AS invid, | .
         qq|  '$module' AS module, 'invoice' AS formtype, | .
@@ -728,16 +730,12 @@ sub search {
         qq|JOIN $ar a ON (a.${cv}_id = ct.id) | .
         qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
         qq|WHERE $where AND (a.invoice = '1')|;
-
-      $union = qq|UNION|;
     }
 
     if ( $form->{l_ordnumber} ) {
-      if ($union eq "UNION") {
-        push(@values, @saved_values);
-      }
+      push(@values, @saved_values);
       $query .=
-        qq| $union | .
+        qq| UNION | .
         qq|SELECT ct.*, b.description AS business,| .
         qq|  ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
         qq|  'oe' AS module, 'order' AS formtype, o.closed | .
@@ -745,16 +743,12 @@ sub search {
         qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
         qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
         qq|WHERE $where AND (o.quotation = '0')|;
-
-      $union = qq|UNION|;
     }
 
     if ( $form->{l_quonumber} ) {
-      if ($union eq "UNION") {
-        push(@values, @saved_values);
-      }
+      push(@values, @saved_values);
       $query .=
-        qq| $union | .
+        qq| UNION | .
         qq|SELECT ct.*, b.description AS business, | .
         qq|  ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
         qq|  'oe' AS module, 'quotation' AS formtype, o.closed | .
index aaed72f..41c19ee 100644 (file)
@@ -18,7 +18,7 @@ sub action_edit {
   $self->{payment_options} = [ { title => $::locale->text("never"), value => 0 },
                                { title => $::locale->text("every time"), value => 1 },
                                { title => $::locale->text("on the same day"), value => 2 }, ];
-  $self->{accounting_options} = [ { title => $::locale->text("accrual"), value => "accrual" },
+  $self->{accounting_options} = [ { title => $::locale->text("Accrual"), value => "accrual" },
                                   { title => $::locale->text("cash"), value => "cash" }, ];
   $self->{inventory_options} = [ { title => $::locale->text("perpetual"), value => "perpetual" },
                                  { title => $::locale->text("periodic"), value => "periodic" }, ];
index f0d88ff..8321031 100644 (file)
@@ -25,12 +25,17 @@ sub init {
 
   $params{path_suffix} ||= '';
   $params{schema}      ||= '';
+  $params{path}          = "sql/" . $params{dbdriver} . "-upgrade2" . $params{path_suffix};
 
   map { $self->{$_} = $params{$_} } keys %params;
 
   return $self;
 }
 
+sub path {
+  $_[0]{path};
+}
+
 sub parse_dbupdate_controls {
   $::lxdebug->enter_sub();
 
@@ -42,7 +47,7 @@ sub parse_dbupdate_controls {
   local *IN;
   my %all_controls;
 
-  my $path = "sql/" . $self->{dbdriver} . "-upgrade2" . $self->{path_suffix};
+  my $path = $self->path;
 
   foreach my $file_name (<$path/*.sql>, <$path/*.pl>) {
     next unless (open(IN, $file_name));
index 0f41870..ff80d76 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -1565,6 +1565,11 @@ sub retrieve_accounts {
     } else {
       $transdate = $form->{deliverydate};
     }
+  } elsif (($form->{type} eq "credit_note") and $form->{deliverydate}) {
+    # if credit_note has a deliverydate, use this instead of invdate
+    # useful for credit_notes of invoices from an old period with different tax
+    # if there is no deliverydate then invdate is used, old default (see next elsif)
+    $transdate = $form->{deliverydate};
   } elsif (($form->{type} eq "credit_note") || ($form->{script} eq 'ir.pl')) {
     $transdate = $form->{invdate};
   } else {
index f9d299f..5005475 100644 (file)
@@ -940,7 +940,7 @@ sub edit_defaults {
   # default language
   my $all_languages = SL::DB::Manager::Language->get_all;
 
-# EÜR = cash, Bilanzierung = accrual
+# cash = IST-Versteuerung, accrual = SOLL-Versteuerung
 
   foreach my $key (keys %{ $form->{IC} }) {
     foreach my $accno (sort keys %{ $form->{IC}->{$key} }) {
index 3523c74..625abec 100644 (file)
@@ -318,3 +318,10 @@ div#menuv3 li:hover ul, div#menuv3 li li:hover ul, div#menuv3 li li li:hover ul,
 #html-menu div.s2 { padding-left: 16px }
 
 body { margin: 0 }
+
+@media print {
+  #menuv3, #menuv4, #html-menu, #frame-header, #js-menu {   /* items with this class won't print */
+    display: none;
+  }
+  #content.html-menu { margin-left: 0; }
+}
index 19f98b2..807082e 100644 (file)
@@ -325,3 +325,11 @@ div#menuv4 li li li li:hover ul
 #html-menu div.s2 { padding-left: 16px }
 
 body { margin: 0 }
+
+
+@media print {
+  #menuv3, #menuv4, #html-menu, #frame-header, #js-menu {   /* items with this class won't print */
+    display: none;
+  }
+  #content.html-menu { margin-left: 0; }
+}
index f5a79c3..6ed0ddd 100644 (file)
@@ -101,7 +101,7 @@ $self->{texts} = {
   'Accounting Group deleted!'   => 'Buchungsgruppe gel&ouml;scht!',
   'Accounting Group saved!'     => 'Buchungsgruppe gespeichert!',
   'Accounting method'           => 'Versteuerungsart',
-  'Accrual'                     => 'Bilanzierung',
+  'Accrual'                     => 'Soll-Versteuerung',
   'Active'                      => 'Aktiv',
   'Active?'                     => 'Aktiviert?',
   'Add'                         => 'Erfassen',
index 182d245..52d3ec5 100644 (file)
@@ -101,7 +101,7 @@ $self->{texts} = {
   'Accounting Group deleted!'   => 'Buchungsgruppe gel&ouml;scht!',
   'Accounting Group saved!'     => 'Buchungsgruppe gespeichert!',
   'Accounting method'           => 'Versteuerungsart',
-  'Accrual'                     => 'Bilanzierung',
+  'Accrual'                     => 'Soll-Versteuerung',
   'Active'                      => 'Aktiv',
   'Active?'                     => 'Aktiviert?',
   'Add'                         => 'Erfassen',
@@ -2212,7 +2212,7 @@ $self->{texts} = {
   '[email]'                     => '[email]',
   'absolute'                    => 'absolut',
   'account_description'         => 'Beschreibung',
-  'accrual'                     => 'Bilanzierung (Soll-Versteuerung)',
+  'accrual'                     => 'Soll-Versteuerung',
   'action= not defined!'        => 'action= nicht definiert!',
   'active'                      => 'aktiv',
   'all entries'                 => 'alle Einträge',
index 253706c..ba13e3f 100755 (executable)
@@ -43,7 +43,8 @@ use SL::Dispatcher;
 
 my ($opt_list, $opt_tree, $opt_rtree, $opt_nodeps, $opt_graphviz, $opt_help);
 my ($opt_user, $opt_apply, $opt_applied, $opt_unapplied, $opt_format, $opt_test_utf8);
-my ($opt_dbhost, $opt_dbport, $opt_dbname, $opt_dbuser, $opt_dbpassword);
+my ($opt_dbhost, $opt_dbport, $opt_dbname, $opt_dbuser, $opt_dbpassword, $opt_create, $opt_type);
+my ($opt_description, $opt_encoding, @opt_depends);
 
 our (%myconfig, $form, $user, $auth, $locale, $controls, $dbupgrader);
 
@@ -231,6 +232,48 @@ sub dump_nodeps {
     "\n\n";
 }
 
+sub create_upgrade {
+  my (%params) = @_;
+
+  my $filename    = $params{filename};
+  my $dbupgrader  = $params{dbupgrader};
+  my $type        = $params{type}        || '';
+  my $description = $params{description} || '';
+  my $encoding    = $params{encoding}    || 'utf-8';
+  my @depends     = @{ $params{depends} };
+
+  if (!@depends) {
+    my @releases = grep { /^release_/ } keys %$controls;
+    @depends = ((sort @releases)[-1]);
+  }
+
+  my $comment;
+  if ($type eq 'sql') {
+    $comment = '--';
+  } elsif ($type eq 'pl') {
+    $comment = '#';
+  } elsif (!$type) {
+    die 'Error: No --type was given but is required for --create.';
+  } else {
+    die 'Error: Unknown --type. Try "sql" or "pl".';
+  }
+
+  my $full_filename = $dbupgrader->path . '/' . $filename . '.' . $type;
+
+  die "file '$full_filename' already exists, aborting" if -f $full_filename;
+
+
+  open my $fh, ">:encoding($encoding)", $full_filename or die "can't open $full_filename";
+  print $fh "$comment \@tag: $filename\n";
+  print $fh "$comment \@description: $description\n";
+  print $fh "$comment \@depends: @depends\n";
+  print $fh "$comment \@encoding: $encoding\n";
+  close $fh;
+
+  system("\$EDITOR $full_filename");
+  exit 0;
+}
+
 sub apply_upgrade {
   my $name = shift;
 
@@ -399,6 +442,11 @@ GetOptions("list"         => \$opt_list,
            "user=s"       => \$opt_user,
            "apply=s"      => \$opt_apply,
            "applied"      => \$opt_applied,
+           "create=s"     => \$opt_create,
+           "type=s"       => \$opt_type,
+           "encoding=s"   => \$opt_encoding,
+           "description=s" => \$opt_description,
+           "depends=s"    => \@opt_depends,
            "unapplied"    => \$opt_unapplied,
            "test-utf8"    => \$opt_test_utf8,
            "dbhost:s"     => \$opt_dbhost,
@@ -420,6 +468,12 @@ dump_tree_reverse()                         if ($opt_rtree);
 dump_graphviz('file_name' => $opt_graphviz,
               'format'    => $opt_format)   if (defined $opt_graphviz);
 dump_nodeps()                               if ($opt_nodeps);
+create_upgrade(filename   => $opt_create,
+               dbupgrader  => $dbupgrader,
+               type        => $opt_type,
+               description => $opt_description,
+               encoding    => $opt_encoding,
+               depends     => \@opt_depends) if ($opt_create);
 
 if ($opt_user) {
   $auth = SL::Auth->new();
@@ -456,6 +510,7 @@ if ($opt_unapplied) {
   dump_unapplied();
 }
 
+
 if ($opt_test_utf8) {
   $form->error("--test-utf8 used but no database name given with --dbname.") if (!$opt_dbname);
 
index bbe05f0..97561d1 100644 (file)
         <th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th>
           <td colspan="3"><input size='11' name="donumber" value="[% HTML.escape(donumber) %]"></td>
         </tr>
+[%- END %]
         <tr>
           <th align="right">[% 'Delivery Date' | $T8 %]</th>
           <td>[% L.date_tag('deliverydate', deliverydate, cal_align='BL') %]</td>
         </tr>
-[%- END %]
-
         <tr>
           <th align="right" nowrap>[% 'Order Number' | $T8 %]</th>
           <td colspan="3"><input size='11' name="ordnumber" value="[% HTML.escape(ordnumber) %]"></td>
index cf755d6..158c0cc 100644 (file)
@@ -63,7 +63,7 @@
     <th align=left>[% 'Method' | $T8 %]</th>
     <td colspan=3>
       [% L.radio_button_tag('method', value='accrual', checked=accrual, label=LxERP.t8('Accrual')) %]
-      [% L.radio_button_tag('method', value='cash', checked=cash, label=LxERP.t8('EUR')) %]
+      [% L.radio_button_tag('method', value='cash', checked=cash, label=LxERP.t8('cash')) %]
     </td>
   </tr>
 [%- END %]