From: Sven Schöling Date: Mon, 4 Apr 2016 11:46:16 +0000 (+0200) Subject: Revert "country_mode entfernt." X-Git-Tag: release-3.4.1~259 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a0b8d78b54fc1ff2fc2f0f527ec4c9630444e590;p=kivitendo-erp.git Revert "country_mode entfernt." Originalcommit: b05b5075ac0f3cbb0823c2f513cdbcacfb17bede. --- diff --git a/SL/Controller/Admin.pm b/SL/Controller/Admin.pm index ab4e24fbb..634dd27ff 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) ], ); @@ -552,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 # diff --git a/SL/Controller/ClientConfig.pm b/SL/Controller/ClientConfig.pm index 4ce4faa0a..bd95e3b9c 100644 --- a/SL/Controller/ClientConfig.pm +++ b/SL/Controller/ClientConfig.pm @@ -30,6 +30,7 @@ sub action_edit { my ($self, %params) = @_; $::form->{use_templates} = $self->defaults->templates ? 'existing' : 'new'; + $::form->{country_mode} = $self->defaults->country_mode; $self->edit_form; } diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index 96c4b0f1f..88ac138c5 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -37,6 +37,7 @@ __PACKAGE__->meta->columns( customer_hourly_rate => { type => 'numeric', precision => 8, scale => 2 }, customer_projects_only_in_sales => { type => 'boolean', default => 'false', not_null => 1 }, customernumber => { type => 'text' }, + country_mode => { type => 'text', default => 'DE', not_null => 1 }, datev_check_on_ap_transaction => { type => 'boolean', default => 'true' }, datev_check_on_ar_transaction => { type => 'boolean', default => 'true' }, datev_check_on_gl_transaction => { type => 'boolean', default => 'true' }, diff --git a/SL/DefaultManager.pm b/SL/DefaultManager.pm index b9940c05f..fc9b21a69 100644 --- a/SL/DefaultManager.pm +++ b/SL/DefaultManager.pm @@ -34,6 +34,14 @@ sub _get { } } +sub country_modes { + my ($self) = @_; + return ( + 'CH' => 'Switzerland', + 'DE' => 'Germany', + ) +} + sub AUTOLOAD { our $AUTOLOAD; diff --git a/SL/User.pm b/SL/User.pm index 37e1a9b5f..25a903aa2 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -46,7 +46,6 @@ use SL::DBUtils; use SL::Iconv; use SL::Inifile; use SL::System::InstallationLock; -use SL::DefaultManager; use strict; @@ -292,34 +291,12 @@ sub dbcreate { my $dbupdater = SL::DBUpgrade2->new(form => $form, return_on_error => 1, silent => 1)->parse_dbupdate_controls; # create the tables $dbupdater->process_query($dbh, "sql/lx-office.sql"); - $dbupdater->process_query($dbh, "sql/$form->{chart}-chart.sql"); - - $query = qq|UPDATE defaults SET coa = ?|; - do_query($form, $dbh, $query, map { $form->{$_} } qw(chart)); - - $dbh->disconnect; - - # update new database - $self->dbupdate2(form => $form, updater => $dbupdater, database => $form->{db}, silent => 1); - $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) - or $form->dberror; - - $query = "SELECT * FROM currencies WHERE name = ?"; - my $curr = selectfirst_hashref_query($form, $dbh, $query, $form->{defaultcurrency}); - if (!$curr->{id}) { - do_query($form, $dbh, "INSERT INTO currencies (name) VALUES (?)", $form->{defaultcurrency}); - $curr = selectfirst_hashref_query($form, $dbh, $query, $form->{defaultcurrency}); - } + # load chart of accounts + $dbupdater->process_query($dbh, "sql/$form->{chart}-chart.sql"); - $query = qq|UPDATE defaults SET accounting_method = ?, profit_determination = ?, inventory_system = ?, precision = ?, currency_id = ?|; - do_query($form, $dbh, $query, - $form->{accounting_method}, - $form->{profit_determination}, - $form->{inventory_system}, - $form->parse_amount(\%::myconfig, $form->{precision_as_number}), - $curr->{id}, - ); + $query = qq|UPDATE defaults SET coa = ?, accounting_method = ?, profit_determination = ?, inventory_system = ?, curr = ?|; + do_query($form, $dbh, $query, map { $form->{$_} } qw(chart accounting_method profit_determination inventory_system defaultcurrency)); $dbh->disconnect; @@ -447,15 +424,14 @@ sub data { sub get_default_myconfig { my ($self_or_class, %user_config) = @_; - my $defaults = SL::DefaultManager->new($::lx_office_conf{system}->{default_manager}); return ( - countrycode => $defaults->language('de'), + countrycode => 'de', css_path => 'css', # Needed for menunew, see SL::Layout::Base::get_stylesheet_for_user - dateformat => $defaults->dateformat('dd.mm.yy'), - numberformat => $defaults->numberformat('1.000,00'), - stylesheet => $defaults->stylesheet('kivitendo.css'), - timeformat => $defaults->timeformat('hh:mm'), + dateformat => 'dd.mm.yy', + numberformat => '1.000,00', + stylesheet => 'kivitendo.css', + timeformat => 'hh:mm', %user_config, ); } diff --git a/sql/Pg-upgrade2/defaults_add_country_mode.sql b/sql/Pg-upgrade2/defaults_add_country_mode.sql new file mode 100644 index 000000000..d6495e1d7 --- /dev/null +++ b/sql/Pg-upgrade2/defaults_add_country_mode.sql @@ -0,0 +1,5 @@ +-- @tag: defaults_add_country_mode +-- @description: adds new column 'country_mode' (ISO-3166) in table defaults used for erp.ini +-- @depends: release_3_2_0 +ALTER TABLE defaults ADD COLUMN country_mode TEXT NOT NULL DEFAULT('DE'); + diff --git a/templates/webpages/admin/create_dataset.html b/templates/webpages/admin/create_dataset.html index 741a941db..00bdf0b6d 100644 --- a/templates/webpages/admin/create_dataset.html +++ b/templates/webpages/admin/create_dataset.html @@ -21,6 +21,11 @@ [% L.input_tag('db', FORM.db, class="initial_focus") %] + + [% LxERP.t8('Country') %] + [% L.select_tag('countrymode', SELF.all_countrymodes, title_key="title", default=(FORM.countrymode), onchange='select_country_defaults(this.value)') %] + +