commit 1e403f489b283e2e6b725f32cea29f38b3fe4e1f
Author: Rolf Fluehmann <rolf.fluehmann@revamp-it.ch>
Date:   Mon Jan 4 16:55:13 2016 +0100

    Admin: create_dataset Änderungen für neue Eingenschaften

diff --git a/SL/Controller/Admin.pm b/SL/Controller/Admin.pm
index 1c0f25e0c..c595b2411 100644
--- a/SL/Controller/Admin.pm
+++ b/SL/Controller/Admin.pm
@@ -21,7 +21,7 @@ use SL::Layout::AdminLogin;
 use Rose::Object::MakeMethods::Generic
 (
   'scalar --get_set_init' => [ qw(client user group printer db_cfg is_locked
-                                  all_dateformats all_numberformats all_countrycodes all_stylesheets all_menustyles all_clients all_groups all_users all_rights all_printers
+                                  all_dateformats all_numberformats all_countrycodes all_countrymodes all_stylesheets all_menustyles all_clients all_groups all_users all_rights all_printers
                                   all_dbsources all_used_dbsources all_accounting_methods all_inventory_systems all_profit_determinations all_charts) ],
 );
 
@@ -112,12 +112,13 @@ sub action_show {
 sub action_new_user {
   my ($self) = @_;
 
+  my $defaults = SL::DefaultManager->new($::lx_office_conf{system}->{default_manager});
   $self->user(SL::DB::AuthUser->new(
     config_values => {
       vclimit      => 200,
-      countrycode  => "de",
-      numberformat => "1.000,00",
-      dateformat   => "dd.mm.yy",
+      countrycode  => $defaults->language('de'),
+      numberformat => $defaults->numberformat('1.000,00'),
+      dateformat   => $defaults->dateformat('dd.mm.yy'),
       stylesheet   => "kivitendo.css",
       menustyle    => "neu",
     },
@@ -498,8 +499,8 @@ sub init_all_users         { SL::DB::Manager::AuthUser  ->get_all_sorted
 sub init_all_groups        { SL::DB::Manager::AuthGroup ->get_all_sorted                                                     }
 sub init_all_printers      { SL::DB::Manager::Printer   ->get_all_sorted                                                     }
 sub init_all_dateformats   { [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd)      ]                                              }
-sub init_all_numberformats { [ '1,000.00', '1000.00', '1.000,00', '1000,00'   ]                                              }
-sub init_all_stylesheets   { [ qw(lx-office-erp.css kivitendo.css) ]                                                         }
+sub init_all_numberformats { [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ]                                    }
+sub init_all_stylesheets   { [ qw(lx-office-erp.css Mobile.css kivitendo.css) ]                                              }
 sub init_all_dbsources             { [ sort User->dbsources($::form)                               ] }
 sub init_all_used_dbsources        { { map { (join(':', $_->dbhost || 'localhost', $_->dbport || 5432, $_->dbname) => $_->name) } @{ $_[0]->all_clients }  } }
 sub init_all_accounting_methods    { [ { id => 'accrual',   name => t8('Accrual accounting')  }, { id => 'cash',     name => t8('Cash accounting')       } ] }
@@ -551,6 +552,11 @@ sub init_all_countrycodes {
   return [ map { id => $_, title => $cc{$_} }, sort { $cc{$a} cmp $cc{$b} } keys %cc ];
 }
 
+sub init_all_countrymodes {
+  my %cm = SL::DefaultManager->country_modes;
+  return [ map { id => $_, title => "$_ ($cm{$_})" }, sort keys %cm ];
+}
+
 #
 # filters
 #
@@ -558,12 +564,13 @@ sub init_all_countrycodes {
 sub setup_layout {
   my ($self, $action) = @_;
 
+  my $defaults = SL::DefaultManager->new($::lx_office_conf{system}->{default_manager});
   $::request->layout(SL::Layout::Dispatcher->new(style => 'admin'));
   $::form->{favicon} = "favicon.ico";
   %::myconfig        = (
-    countrycode      => 'de',
-    numberformat     => '1.000,00',
-    dateformat       => 'dd.mm.yy',
+    countrycode      => $defaults->language('de'),
+    numberformat     => $defaults->numberformat('1.000,00'),
+    dateformat       => $defaults->dateformat('dd.mm.yy'),
   ) if !%::myconfig;
 }
 
@@ -628,6 +635,17 @@ sub database_administration_login_form {
 
 sub create_dataset_form {
   my ($self, %params) = @_;
+
+  my $defaults = SL::DefaultManager->new($::lx_office_conf{system}->{default_manager});
+  $::form->{favicon} = "favicon.ico";
+  $::form->{countrymode}          = $defaults->country('DE');
+  $::form->{chart}                = $defaults->chart_of_accounts('Germany-DATEV-SKR03EU');
+  $::form->{defaultcurrency}      = $defaults->currency('EUR');
+  $::form->{precision}            = $defaults->precision(0.01);
+  $::form->{accounting_method}    = $defaults->accounting_method('cash');
+  $::form->{inventory_system}     = $defaults->inventory_system('periodic');
+  $::form->{profit_determination} = $defaults->profit_determination('balance');
+
   $self->render('admin/create_dataset', title => (t8('Database Administration') . " / " . t8('Create Dataset')));
 }
 
diff --git a/locale/de/all b/locale/de/all
index 2fcc279f6..7a6d1c211 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -2004,6 +2004,7 @@ $self->{texts} = {
   'Posustva_coa'                => 'USTVA Kennz.',
   'Pre-defined Texts'           => 'Vordefinierte Textblöcke',
   'Preamble'                    => 'Einleitung',
+  'Precision'                   => 'Genauigkeit',
   'Preferences'                 => 'Einstellungen',
   'Preferences saved!'          => 'Einstellungen gespeichert!',
   'Prefix for the new bins\' names' => 'Namenspr&auml;fix f&uuml;r die neuen Lagerpl&auml;tze',
diff --git a/locale/en/all b/locale/en/all
index 02fed2c44..124ac89c0 100644
--- a/locale/en/all
+++ b/locale/en/all
@@ -1624,6 +1624,7 @@ $self->{texts} = {
   'Posting Configuration'       => '',
   'Postscript'                  => '',
   'Posustva_coa'                => '',
+  'Precision'                   => '',
   'Preferences'                 => '',
   'Preferences saved!'          => '',
   'Prefix for the new bins\' names' => '',
diff --git a/templates/webpages/admin/create_dataset.html b/templates/webpages/admin/create_dataset.html
index 5b776569b..4f875a882 100644
--- a/templates/webpages/admin/create_dataset.html
+++ b/templates/webpages/admin/create_dataset.html
@@ -21,29 +21,44 @@
    <td>[% L.input_tag('db', FORM.db, class="initial_focus") %]</td>
   </tr>
 
+  <tr>
+   <th valign="top" align="right" nowrap>[% LxERP.t8('Country') %]</th>
+   <td>[% L.select_tag('countrymode', SELF.all_countrymodes, title_key="title", default=(FORM.countrymode), onchange='select_country_defaults(this.value)') %]</td>
+  </tr>
+
+  <tr>
+   <td colspan="1"> </td>
+   <td><hr size="1" noshade></td>
+  </tr>
+
   <tr>
    <th align="right" nowrap>[% LxERP.t8('Default currency') %]</th>
-   <td>[% L.input_tag('defaultcurrency', FORM.defaultcurrency || 'EUR') %]</td>
+   <td>[% L.input_tag('defaultcurrency', FORM.defaultcurrency) %]</td>
+  </tr>
+
+  <tr>
+   <th align="right" nowrap>[% LxERP.t8('Precision') %]</th>
+   <td>[% L.input_tag('precision', FORM.precision) %]</td>
   </tr>
 
   <tr>
    <th valign="top" align="right" nowrap>[% LxERP.t8('Create Chart of Accounts') %]</th>
-   <td>[% L.select_tag('chart', SELF.all_charts, onchange='comment_selected_chart(this.value)', default=(FORM.chart || 'Germany-DATEV-SKR03EU')) %]</td>
+   <td>[% L.select_tag('chart', SELF.all_charts, default=(FORM.chart), onchange='comment_selected_chart(this.value)') %]</td>
   </tr>
 
   <tr>
    <th valign="top" align="right" nowrap>[% LxERP.t8('Accounting method') %]</th>
-   <td>[% L.select_tag('accounting_method', SELF.all_accounting_methods, title_key='name', default=(FORM.accounting_method || 'cash')) %]</td>
+   <td>[% L.select_tag('accounting_method', SELF.all_accounting_methods, title_key='name', default=(FORM.accounting_method)) %]</td>
   </tr>
 
   <tr>
    <th valign="top" align="right" nowrap>[% LxERP.t8('Inventory system') %]</th>
-   <td>[% L.select_tag('inventory_system', SELF.all_inventory_systems, title_key='name', default=(FORM.inventory_system || 'periodic')) %]</td>
+   <td>[% L.select_tag('inventory_system', SELF.all_inventory_systems, title_key='name', default=(FORM.inventory_system)) %]</td>
   </tr>
 
   <tr>
    <th valign="top" align="right" nowrap>[% LxERP.t8('Profit determination') %]</th>
-   <td>[% L.select_tag('profit_determination', SELF.all_profit_determinations, title_key='name', default=(FORM.profit_determination || 'income')) %]</td>
+   <td>[% L.select_tag('profit_determination', SELF.all_profit_determinations, title_key='name', default=(FORM.profit_determination)) %]</td>
   </tr>
  </table>
 
@@ -67,30 +82,35 @@
 
 function comment_selected_chart(s) {
   if (s == 'Austria') {
-   alert("SKR07 Austria ist noch Stand 2002." +
+    alert("SKR07 Austria ist noch Stand 2002." +
          "\n" +
          "Die Buchungsgruppen sind nicht korrekt vorkonfiguriert" +
          "\n" +
          "fuer Kunden im Ausland." +
          "\n" +
          "Hinweis vom 20.09.2011");
-
-  } else if (s == 'Swiss-German') {
-   alert("Hinweis: Das ist weder ein Schweizer Kontorahmen nach Kaefer noch ein " +
-         "Schweizer KMU-Kontenrahmen, sondern ein angelehnter KMU-Kontenrahmen fuer " +
-         "ein EDV-Dienstleistungsunternehmen mit Stand 2006 (Bspw. 32001 Hardware, " +
-         "statt 3200 Warenertrag)." +
-         "\n" +
-         "Ferner sind keine Buchungsgruppe vorkonfiguriert, somit wird " +
-         "standardmaessig keine Rechnung mit Steuer ausgewiesen." +
-         "\n" +
-         "Zum schnellen Testen und Zusammenhaenge verstehen waehlen Sie lieber einen " +
-         "deutschen Kontenrahmen aus (SKR03 oder SKR04) und passen die Steuer an." +
-         "\n" +
-         "Hinweis vom 21.09.2011");
   }
+  return true;
+}
 
+function select_country_defaults(country) {
+  if (/^CH/.test(country)) {
+    document.getElementById('defaultcurrency').value='CHF';
+    document.getElementById('precision').value='0.05';
+    document.getElementById('chart').value='Switzerland-deutsch-MWST-2014';
+    document.getElementById('accounting_method').value='accrual';
+    document.getElementById('inventory_system').value='periodic';
+    document.getElementById('profit_determination').value='balance';
+  } else {
+    document.getElementById('defaultcurrency').value='EUR';
+    document.getElementById('precision').value='0.01';
+    document.getElementById('chart').value='Germany-DATEV-SKR03EU';
+    document.getElementById('accounting_method').value='cash';
+    document.getElementById('inventory_system').value='periodic';
+    document.getElementById('profit_determination').value='income';
+  }
   return true;
 }
+
    -->
 </script>
