From: Moritz Bunkus Date: Fri, 28 Feb 2020 15:25:45 +0000 (+0100) Subject: ZUGFeRD: allgemeine Notizen für alle Rechnungen in Übersetzungen anlegen können X-Git-Tag: release-3.5.6.1~245^2~29 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e5f53eb5c67c19d6a356fcde22ca46169cdca5dc;p=kivitendo-erp.git ZUGFeRD: allgemeine Notizen für alle Rechnungen in Übersetzungen anlegen können --- diff --git a/SL/DB/Helper/ZUGFeRD.pm b/SL/DB/Helper/ZUGFeRD.pm index f25eddf62..5cee13a3e 100644 --- a/SL/DB/Helper/ZUGFeRD.pm +++ b/SL/DB/Helper/ZUGFeRD.pm @@ -6,6 +6,7 @@ use utf8; use parent qw(Exporter); our @EXPORT = qw(create_zugferd_data create_zugferd_xmp_data); +use SL::DB::GenericTranslation; use SL::DB::Tax; use SL::DB::TaxKey; use SL::Helper::ISO3166; @@ -15,7 +16,7 @@ use SL::Helper::UNECERecommendation20; use Carp; use Encode qw(encode); use List::MoreUtils qw(pairwise); -use List::Util qw(sum); +use List::Util qw(first sum); use Template; use XML::Writer; @@ -308,6 +309,14 @@ sub _exchanged_document_context { # } +sub _included_note { + my ($self, %params) = @_; + + $params{xml}->startTag("ram:IncludedNote"); + $params{xml}->dataElement("ram:Content", _u8($params{note})); + $params{xml}->endTag; +} + sub _exchanged_document { my ($self, %params) = @_; @@ -328,18 +337,26 @@ sub _exchanged_document { $params{xml}->dataElement("ram:LanguageID", uc($1)); } - if ($self->transaction_description) { - $params{xml}->startTag("ram:IncludedNote"); - $params{xml}->dataElement("ram:Content", _u8($self->transaction_description)); - $params{xml}->endTag; - } + my $std_notes = SL::DB::Manager::GenericTranslation->get_all( + where => [ + translation_type => 'ZUGFeRD/notes', + or => [ + language_id => undef, + language_id => $self->language_id, + ], + '!translation' => undef, + '!translation' => '', + ], + ); + + my $std_note = first { $_->language_id == $self->language_id } @{ $std_notes }; + $std_note //= first { !defined $_->language_id } @{ $std_notes }; my $notes = $self->notes_as_stripped_html; - if ($notes) { - $params{xml}->startTag("ram:IncludedNote"); - $params{xml}->dataElement("ram:Content", _u8($notes)); - $params{xml}->endTag; - } + + _included_note($self, %params, note => $self->transaction_description) if $self->transaction_description; + _included_note($self, %params, note => $notes) if $notes; + _included_note($self, %params, note => $std_note->translation) if $std_note; $params{xml}->endTag; # diff --git a/bin/mozilla/generictranslations.pl b/bin/mozilla/generictranslations.pl index 0261ef1b1..9fc60c541 100644 --- a/bin/mozilla/generictranslations.pl +++ b/bin/mozilla/generictranslations.pl @@ -210,6 +210,48 @@ sub save_email_strings { $main::lxdebug->leave_sub(); } +sub edit_zugferd_notes { + $::auth->assert('config'); + + $::form->get_lists('languages' => 'LANGUAGES'); + + my $translation_list = GenericTranslations->list(translation_type => 'ZUGFeRD/notes'); + my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list }; + + unshift @{ $::form->{LANGUAGES} }, { 'id' => 'default', }; + + foreach my $language (@{ $::form->{LANGUAGES} }) { + $language->{translation} = $translations{$language->{id}}; + } + + setup_generictranslations_edit_zugferd_notes_action_bar(); + + $::form->{title} = $::locale->text('Edit ZUGFeRD notes'); + $::form->header; + print $::form->parse_html_template('generictranslations/edit_zugferd_notes'); +} + +sub save_zugferd_notes { + $::auth->assert('config'); + + $::form->get_lists('languages' => 'LANGUAGES'); + + unshift @{ $::form->{LANGUAGES} }, { }; + + foreach my $language (@{ $::form->{LANGUAGES} }) { + GenericTranslations->save( + translation_type => 'ZUGFeRD/notes', + translation_id => undef, + language_id => $language->{id}, + translation => $::form->{"translation__" . ($language->{id} || 'default')}, + ); + } + + $::form->{message} = $::locale->text('The ZUGFeRD notes have been saved.'); + + edit_zugferd_notes(); +} + sub setup_generictranslations_edit_greetings_action_bar { my %params = @_; @@ -237,6 +279,7 @@ sub setup_generictranslations_edit_sepa_strings_action_bar { ); } } + sub setup_generictranslations_edit_email_strings_action_bar { my %params = @_; @@ -251,4 +294,18 @@ sub setup_generictranslations_edit_email_strings_action_bar { } } +sub setup_generictranslations_edit_zugferd_notes_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "save_zugferd_notes" } ], + accesskey => 'enter', + ], + ); + } +} + 1; diff --git a/locale/de/all b/locale/de/all index 0567e1f14..143a02d01 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1177,6 +1177,7 @@ $self->{texts} = { 'Edit Vendor' => 'Lieferant editieren', 'Edit Vendor Invoice' => 'Einkaufsrechnung bearbeiten', 'Edit Warehouse' => 'Lager bearbeiten', + 'Edit ZUGFeRD notes' => 'ZUGFeRD-Notizen bearbeiten', 'Edit acceptance status' => 'Abnahmestatus bearbeiten', 'Edit additional articles' => 'Zusätzliche Artikel bearbeiten', 'Edit all drafts' => 'Entwürfe von allen Benutzern bearbeiten', @@ -3183,6 +3184,7 @@ $self->{texts} = { 'The SQL query does not contain any parameter that need to be configured.' => 'Die SQL-Abfrage enthält keine Parameter, die angegeben werden müssten.', 'The URL is missing.' => 'URL fehlt', 'The WebDAV feature has been used.' => 'Das WebDAV-Feature wurde benutzt.', + 'The ZUGFeRD notes have been saved.' => 'Die ZUGFeRD-Notizen wurden gespeichert.', 'The abbreviation is missing.' => 'Abkürzung fehlt', 'The access rights a user has within a client instance is still governed by his group membership.' => 'Welche Zugriffsrechte ein Benutzer innerhalb eines Mandanten hat, wird weiterhin über Gruppenmitgliedschaften geregelt.', 'The access rights have been saved.' => 'Die Zugriffsrechte wurden gespeichert.', @@ -3979,6 +3981,7 @@ $self->{texts} = { 'Your import is being processed.' => 'Ihr Import wird verarbeitet', 'Your target quantity will be added to the stocked quantity.' => 'Ihre gezählte Zielmenge wird zum Lagerbestand hinzugezählt.', 'ZUGFeRD invoice' => 'ZUGFeRD-Rechnung', + 'ZUGFeRD notes for each invoice' => 'ZUGFeRD-Notizen für jede Rechnung', 'Zeitraum' => 'Zeitraum', 'Zero amount posting!' => 'Buchung ohne Wert', 'Zip' => 'PLZ', diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml index ebcafbd10..9f03529f7 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -1252,6 +1252,13 @@ module: generictranslations.pl params: action: edit_sepa_strings +- parent: system_languages_and_translations + id: system_languages_and_translations_zugferd_notes + name: ZUGFeRD notes for each invoice + order: 450 + module: generictranslations.pl + params: + action: edit_zugferd_notes - parent: system_languages_and_translations id: system_languages_and_translations_email_strings name: Preset email strings diff --git a/templates/webpages/generictranslations/edit_zugferd_notes.html b/templates/webpages/generictranslations/edit_zugferd_notes.html new file mode 100644 index 000000000..04f1051f0 --- /dev/null +++ b/templates/webpages/generictranslations/edit_zugferd_notes.html @@ -0,0 +1,33 @@ +[%- USE T8 %] +[%- USE HTML %] +

[% HTML.escape(title) %]

+ + [%- IF message %] +

+ [% HTML.escape(message) %] +

+ [%- END %] + +
+ + + + + + + + + [%- FOREACH language = LANGUAGES %] + + + + + [%- END %] +
 [% 'ZUGFeRD notes for each invoice' | $T8 %]
+ [%- IF language.id == 'default' %] + [% 'Default (no language selected)' | $T8 %] + [%- ELSE %] + [%- HTML.escape(language.description) %] + [%- END %] +
+