From cd4177627912b8d09f195e7831c0dd0cd4096af2 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 14 Jun 2013 16:33:28 +0200 Subject: [PATCH] address businessnumber company co_ustid duns taxnumber sepa_creditor_id aus Defaults-Tabelle holen --- SL/AM.pm | 3 +-- SL/Form.pm | 22 ++++++++++++++++------ bin/mozilla/ca.pl | 4 +++- bin/mozilla/io.pl | 4 ++-- bin/mozilla/rp.pl | 14 ++------------ bin/mozilla/sepa.pl | 13 +++++++------ bin/mozilla/ustva.pl | 19 +++++++++++-------- templates/webpages/ustva/config_step2.html | 2 +- 8 files changed, 43 insertions(+), 38 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index bc6c8266e..e2ea0be0e 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1062,8 +1062,7 @@ sub save_preferences { my $user = SL::DB::Manager::AuthUser->find_by(login => $form->{login}); $user->update_attributes( config_values => { - map({ ($_ => $form->{$_}) } SL::DB::AuthUser::CONFIG_VARS()), - map({ ($_ => do { my $v = $form->{$_}; $v =~ s/\r//g; $v }) } qw(address signature)), + map { ($_ => $form->{$_}) } SL::DB::AuthUser::CONFIG_VARS(), }); $main::lxdebug->leave_sub(); diff --git a/SL/Form.pm b/SL/Form.pm index 0246f232e..8f9594bdb 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -978,6 +978,7 @@ sub parse_template { local (*IN, *OUT); + my $defaults = SL::DB::Default->get; my $userspath = $::lx_office_conf{paths}->{userspath}; $self->{"cwd"} = getcwd(); @@ -1029,11 +1030,13 @@ sub parse_template { $self->{"notes"} = $self->{ $self->{"formname"} . "notes" }; if (!$self->{employee_id}) { - map { $self->{"employee_${_}"} = $myconfig->{$_}; } qw(email tel fax name signature company address businessnumber co_ustid taxnumber duns); + $self->{"employee_${_}"} = $myconfig->{$_} for qw(email tel fax name signature); + $self->{"employee_${_}"} = $defaults->$_ for qw(address businessnumber co_ustid company duns sepa_creditor_id taxnumber); } - map { $self->{"${_}"} = $myconfig->{$_}; } qw(co_ustid); - map { $self->{"myconfig_${_}"} = $myconfig->{$_} } grep { $_ ne 'dbpasswd' } keys %{ $myconfig }; + $self->{"myconfig_${_}"} = $myconfig->{$_} for grep { $_ ne 'dbpasswd' } keys %{ $myconfig }; + $self->{$_} = $defaults->$_ for qw(co_ustid); + $self->{"myconfig_${_}"} = $defaults->$_ for qw(address businessnumber co_ustid company duns sepa_creditor_id taxnumber); $self->{copies} = 1 if (($self->{copies} *= 1) <= 0); @@ -1898,6 +1901,7 @@ sub get_employee_data { my $self = shift; my %params = @_; + my $defaults = SL::DB::Default->get; Common::check_params(\%params, qw(prefix)); Common::check_params_x(\%params, qw(id)); @@ -1914,7 +1918,8 @@ sub get_employee_data { if ($login) { my $user = User->new(login => $login); - map { $self->{$params{prefix} . "_${_}"} = $user->{$_}; } qw(address businessnumber co_ustid company duns email fax name signature taxnumber tel); + $self->{$params{prefix} . "_${_}"} = $user->{$_} for qw(email fax name signature tel); + $self->{$params{prefix} . "_${_}"} = $defaults->$_ for qw(address businessnumber co_ustid company duns taxnumber); $self->{$params{prefix} . '_login'} = $login; $self->{$params{prefix} . '_name'} ||= $login; @@ -3377,11 +3382,16 @@ sub prepare_for_printing { die "'media' other than 'email', 'file', 'printer' is not supported yet" unless $self->{media} =~ m/^(?:email|file|printer)$/; + # Several fields that used to reside in %::myconfig (stored in + # auth.user_config) are now stored in defaults. Copy them over for + # compatibility. + $self->{$_} = $defaults->$_ for qw(company address taxnumber co_ustid duns sepa_creditor_id); + # set shipto from billto unless set my $has_shipto = any { $self->{"shipto$_"} } qw(name street zipcode city country contact); if (!$has_shipto && ($self->{type} =~ m/^(?:purchase_order|request_quotation)$/)) { - $self->{shiptoname} = $::myconfig{company}; - $self->{shiptostreet} = $::myconfig{address}; + $self->{shiptoname} = $defaults->company; + $self->{shiptostreet} = $defaults->address; } my $language = $self->{language} ? '_' . $self->{language} : ''; diff --git a/bin/mozilla/ca.pl b/bin/mozilla/ca.pl index da3bfb029..c2fd6a218 100644 --- a/bin/mozilla/ca.pl +++ b/bin/mozilla/ca.pl @@ -35,6 +35,7 @@ use POSIX qw(strftime); use SL::CA; +use SL::DB::Default; use SL::ReportGenerator; require "bin/mozilla/reportgenerator.pl"; @@ -186,6 +187,7 @@ sub list_transactions { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; $main::auth->assert('report'); @@ -331,7 +333,7 @@ sub list_transactions { $form->{print_date} = $locale->text('Create Date') . " " . $locale->date(\%myconfig, $form->current_date(\%myconfig), 0); push (@options, $form->{print_date}); - $form->{company} = $locale->text('Company') . " " . $myconfig{company}; + $form->{company} = $locale->text('Company') . " " . $defaults->company; push (@options, $form->{company}); my @columns = qw(transdate reference description gegenkonto debit credit ustkonto ustrate balance); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 69b70e813..e67bbbb2b 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1443,8 +1443,8 @@ sub print_form { if ($shipto) { if ( $form->{formname} eq 'purchase_order' || $form->{formname} eq 'request_quotation') { - $form->{shiptoname} = $myconfig{company}; - $form->{shiptostreet} = $myconfig{address}; + $form->{shiptoname} = $defaults->company; + $form->{shiptostreet} = $defaults->address; } else { map { $form->{"shipto$_"} = $form->{$_} } @a; } diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 89e1b280d..8062dad90 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -375,10 +375,6 @@ sub generate_income_statement { . qq| $longcomparetodate|; } - # setup variables for the form - my @a = qw(company address businessnumber); - map { $form->{$_} = $myconfig{$_} } @a; - $form->{IN} = "income_statement.html"; $form->parse_template; @@ -415,9 +411,6 @@ sub generate_balance_sheet { # $::form->{IN} = "balance_sheet.html"; - # setup company variables for the form - map { $::form->{$_} = $::myconfig{$_} } qw(company address businessnumber nativecurr); - $::form->header; print $::form->parse_html_template('rp/balance_sheet', $data); @@ -459,6 +452,7 @@ sub generate_trial_balance { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; if ($form->{reporttype} eq "custom") { @@ -620,7 +614,7 @@ sub generate_trial_balance { $form->{print_date} = $locale->text('Create Date') . " " . $locale->date(\%myconfig, $form->current_date(\%myconfig), 0); push (@options, $form->{print_date}); - $form->{company} = $locale->text('Company') . " " . $myconfig{company}; + $form->{company} = $locale->text('Company') . " " . $defaults->company; push (@options, $form->{company}); @@ -1828,10 +1822,6 @@ sub generate_bwa { . qq| $longtodate|; } - # setup variables for the form - my @a = qw(company address businessnumber); - map { $form->{$_} = $myconfig{$_} } @a; - $form->{IN} = "bwa.html"; $form->parse_template; diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index 18f48b2f5..edb6edae1 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -452,13 +452,14 @@ sub bank_transfer_download_sepa_xml { my $locale = $main::locale; my $cgi = $::request->{cgi}; my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; + my $defaults = SL::DB::Default->get; - if (!$myconfig->{company}) { - $form->show_generic_error($locale->text('You have to enter a company name in your user preferences (see the "Program" menu, "Preferences").'), 'back_button' => 1); + if (!$defaults->company) { + $form->show_generic_error($locale->text('You have to enter a company name in the client configuration.'), 'back_button' => 1); } - if (($vc eq 'customer') && !$myconfig->{sepa_creditor_id}) { - $form->show_generic_error($locale->text('You have to enter the SEPA creditor ID in your user preferences (see the "Program" menu, "Preferences").'), 'back_button' => 1); + if (($vc eq 'customer') && !$defaults->sepa_creditor_id) { + $form->show_generic_error($locale->text('You have to enter the SEPA creditor ID in the client configuration.'), 'back_button' => 1); } my @ids; @@ -486,8 +487,8 @@ sub bank_transfer_download_sepa_xml { my $message_id = strftime('MSG%Y%m%d%H%M%S', localtime) . sprintf('%06d', $$); - my $sepa_xml = SL::SEPA::XML->new('company' => $myconfig->{company}, - 'creditor_id' => $myconfig->{sepa_creditor_id}, + my $sepa_xml = SL::SEPA::XML->new('company' => $defaults->company, + 'creditor_id' => $defaults->sepa_creditor_id, 'src_charset' => $::lx_office_conf{system}->{dbcharset} || 'ISO-8859-15', 'message_id' => $message_id, 'grouped' => 1, diff --git a/bin/mozilla/ustva.pl b/bin/mozilla/ustva.pl index cb1c09180..06258d63e 100644 --- a/bin/mozilla/ustva.pl +++ b/bin/mozilla/ustva.pl @@ -84,6 +84,7 @@ sub report { $::auth->assert('advance_turnover_tax_return'); + my $defaults = SL::DB::Default->get; $form->{title} = $locale->text('UStVA'); $form->{kz10} = ''; #Berichtigte Anmeldung? Ja =1 Nein=0 @@ -101,19 +102,20 @@ sub report { # Hier Einlesen der user-config # steuernummer entfernt für prerelease my @a = qw( - signature name company address businessnumber + signature name tel fax email co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2 co_fax co_fax1 co_email co_email1 - co_url co_url1 ustid duns co_bankname + co_url co_url1 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3 ); - map { $form->{$_} = $myconfig{$_} } @a; + $form->{$_} = $myconfig{$_} for @a; + $form->{$_} = $defaults->$_ for qw(company address co_ustid duns); my $openings = $form->{FA_Oeffnungszeiten}; $openings =~ s/\\\\n/
/g; @@ -200,7 +202,7 @@ sub report { company_given => $company_given, address_given => $address_given, taxnumber_given => $taxnumber_given, - taxnumber => $myconfig{taxnumber}, + taxnumber => $defaults->taxnumber, select_year => $select_year, period_local => $period_local, method_local => $method_local, @@ -741,14 +743,15 @@ sub generate_ustva { $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0); # setup variables for the form - my @a = qw(company businessnumber tel fax email + my @a = qw(tel fax email co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2 - co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns + co_fax co_fax1 co_email co_email1 co_url co_url1 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3); - map { $form->{$_} = $myconfig{$_} } @a; + $form->{$_} = $myconfig{$_} for @a; + $form->{$_} = $defaults->$_ for qw(company address co_ustid duns); if ($form->{address} ne '') { my $temp = $form->{address}; @@ -1070,7 +1073,7 @@ sub generate_ustva { $form->header(); my $template_ref = { - taxnumber => $myconfig{taxnumber}, + taxnumber => $defaults->taxnumber, }; print($form->parse_html_template('ustva/generic_taxreport', $template_ref)); diff --git a/templates/webpages/ustva/config_step2.html b/templates/webpages/ustva/config_step2.html index 48a2e3eb0..d566dbd29 100644 --- a/templates/webpages/ustva/config_step2.html +++ b/templates/webpages/ustva/config_step2.html @@ -158,7 +158,7 @@ [%- IF COA_Germany %] [% input_steuernummer %] [%- ELSE %] -[% 'Please enter the taxnumber in the administration menu user preferences' | $T8 %] +[% 'Please enter the taxnumber in the client configuration.' | $T8 %] [% 'Current value:' | $T8 %] [% HTML.escape(myconfig_taxnumber) %] [%- END %] -- 2.20.1