From e90048c8180f32f52f3f12ee52eb7269c4b27fcf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 28 Oct 2013 10:38:01 +0100 Subject: [PATCH] =?utf8?q?Steuernamen=20=C3=BCbersetztbar=20gemacht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AM.pm | 17 ++++++++++++++--- SL/DB/Tax.pm | 1 + SL/IS.pm | 6 +++++- SL/OE.pm | 6 +++++- bin/mozilla/am.pl | 8 ++++++++ bin/mozilla/oe.pl | 2 +- templates/webpages/am/edit_tax.html | 10 ++++++++++ 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index adb240d28..3fdf175cd 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -45,6 +45,7 @@ use SL::DBUtils; use SL::DB::AuthUser; use SL::DB::Default; use SL::DB::Employee; +use SL::GenericTranslations; use strict; @@ -1652,21 +1653,31 @@ sub save_tax { taxnumber = (SELECT accno FROM chart WHERE id= ? ), chart_categories = ? WHERE id = ?|; - push(@values, $form->{id}); } else { #ok + ($form->{id}) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('id')|); $query = qq|INSERT INTO tax ( taxkey, taxdescription, rate, chart_id, taxnumber, - chart_categories + chart_categories, + id ) - VALUES (?, ?, ?, ?, (SELECT accno FROM chart WHERE id = ?), ? )|; + VALUES (?, ?, ?, ?, (SELECT accno FROM chart WHERE id = ?), ?, ?)|; } + push(@values, $form->{id}); do_query($form, $dbh, $query, @values); + + foreach my $language_id (keys %{ $form->{translations} }) { + GenericTranslations->save('dbh' => $dbh, + 'translation_type' => 'SL::DB::Tax/taxdescription', + 'translation_id' => $form->{id}, + 'language_id' => $language_id, + 'translation' => $form->{translations}->{$language_id}); + } $dbh->commit(); diff --git a/SL/DB/Tax.pm b/SL/DB/Tax.pm index 0279dbf74..c027061fb 100644 --- a/SL/DB/Tax.pm +++ b/SL/DB/Tax.pm @@ -3,6 +3,7 @@ package SL::DB::Tax; use strict; use SL::DB::MetaSetup::Tax; +use SL::DB::Helper::TranslatedAttributes; __PACKAGE__->meta->initialize; diff --git a/SL/IS.pm b/SL/IS.pm index 372e533e3..cfaf730e8 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -49,6 +49,7 @@ use SL::IC; use SL::IO; use SL::TransNumber; use SL::DB::Default; +use SL::DB::Tax; use Data::Dumper; use strict; @@ -386,8 +387,11 @@ sub invoice_details { push(@{ $form->{TEMPLATE_ARRAYS}->{tax_nofmt} }, $taxamount ); push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} }, $form->format_amount($myconfig, $form->{"${item}_rate"} * 100)); push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate_nofmt} }, $form->{"${item}_rate"} * 100); - push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%}); push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} }, $form->{"${item}_taxnumber"}); + + my $tax_obj = SL::DB::Manager::Tax->find_by(taxnumber => $form->{"${item}_taxnumber"}); + my $description = $tax_obj->translated_attribute('taxdescription', $form->{language_id}, 0) if $tax_obj; + push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $description . q{ } . 100 * $form->{"${item}_rate"} . q{%}); } for my $i (1 .. $form->{paidaccounts}) { diff --git a/SL/OE.pm b/SL/OE.pm index 683bb0e7c..12cbb8aa1 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -43,6 +43,7 @@ use SL::CVar; use SL::DB::Order; use SL::DB::PeriodicInvoicesConfig; use SL::DB::Status; +use SL::DB::Tax; use SL::DBUtils; use SL::IC; @@ -1284,8 +1285,11 @@ sub order_details { push(@{ $form->{TEMPLATE_ARRAYS}->{tax_nofmt} }, $taxamount); push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} }, $form->format_amount($myconfig, $form->{"${item}_rate"} * 100)); push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate_nofmt} }, $form->{"${item}_rate"} * 100); - push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%}); push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} }, $form->{"${item}_taxnumber"}); + + my $tax_obj = SL::DB::Manager::Tax->find_by(taxnumber => $form->{"${item}_taxnumber"}); + my $description = $tax_obj->translated_attribute('taxdescription', $form->{language_id}, 0) if $tax_obj; + push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $description . q{ } . 100 * $form->{"${item}_rate"} . q{%}); } $form->{nodiscount_subtotal} = $form->format_amount($myconfig, $form->{nodiscount_total}, 2); diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 8a4876033..e12c1ea51 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -43,6 +43,8 @@ use SL::USTVA; use SL::Iconv; use SL::TODO; use SL::DB::Printer; +use SL::DB::Tax; +use SL::DB::Language; use CGI; require "bin/mozilla/common.pl"; @@ -1415,6 +1417,7 @@ sub add_tax { my $parameters_ref = { # ChartTypeIsAccount => $ChartTypeIsAccount, + LANGUAGES => SL::DB::Manager::Language->get_all_sorted, }; # Ausgabe des Templates @@ -1450,6 +1453,8 @@ sub edit_tax { $form->header(); my $parameters_ref = { + LANGUAGES => SL::DB::Manager::Language->get_all_sorted, + TAX => SL::DB::Manager::Tax->find_by(id => $form->{id}), }; # Ausgabe des Templates @@ -1528,6 +1533,9 @@ sub save_tax { $form->error($locale->text('Tax Percent is a number between 0 and 100')); } + my @translation_keys = grep { $_ =~ '^translation_\d+' } keys %$form; + $form->{translations} = { map { $_ =~ '^translation_(\d+)'; $1 => $form->{$_} } @translation_keys }; + AM->save_tax(\%myconfig, \%$form); $form->redirect($locale->text('Tax saved!')); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index dc47d27fa..b9b32bfaa 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -442,7 +442,7 @@ sub form_header { shiptodepartment_1 shiptodepartment_2 shiptoemail shiptocp_gender message email subject cc bcc taxpart taxservice taxaccounts cursor_fokus), @custom_hiddens, - map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} ]; # deleted: discount + map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} ]; # deleted: discount %TMPL_VAR = ( %TMPL_VAR, diff --git a/templates/webpages/am/edit_tax.html b/templates/webpages/am/edit_tax.html index f7e7cf9e1..83a10c428 100644 --- a/templates/webpages/am/edit_tax.html +++ b/templates/webpages/am/edit_tax.html @@ -1,6 +1,7 @@ [%- USE T8 %] [%- USE HTML %] [%- USE L %] +[%- USE LxERP %]
@@ -21,6 +22,15 @@ + [%- FOREACH language = LANGUAGES %] + + [%- HTML.escape(language.description) %] ([%- LxERP.t8('Translation') %]) + + + + + [%- END %] + [% 'tax_percent' | $T8 %] [% IF tax_already_used %]

[% HTML.escape(rate) %] %

-- 2.20.1