From: Moritz Bunkus Date: Tue, 24 Jan 2017 15:04:37 +0000 (+0100) Subject: Belegvorlagen: Speichern bei Debitorenbuchungen X-Git-Tag: release-3.5.4~1650 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=558c234e56b3a5387b164655e05f562929d9f736;p=kivitendo-erp.git Belegvorlagen: Speichern bei Debitorenbuchungen --- diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 75d21f686..540c8fb31 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -37,6 +37,7 @@ use List::Util qw(sum first max); use List::UtilsBy qw(sort_by); use SL::AR; +use SL::Controller::Base; use SL::FU; use SL::GL; use SL::IS; @@ -152,6 +153,57 @@ sub load_record_template { update(); } +sub save_record_template { + $::auth->assert('ar_transactions'); + + my $template = $::form->{record_template_id} ? SL::DB::RecordTemplate->new(id => $::form->{record_template_id})->load : SL::DB::RecordTemplate->new; + my $js = SL::ClientJS->new(controller => SL::Controller::Base->new); + my $new_name = $template->template_name_to_use($::form->{record_template_new_template_name}); + + $js->dialog->close('#record_template_dialog'); + + my @items = grep { + $_->{chart_id} && (($_->{tax_id} // '') ne '') && ($_->{amount1} != 0) + } map { + +{ chart_id => $::form->{"AR_amount_chart_id_${_}"}, + amount1 => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}), + tax_id => (split m{--}, $::form->{"taxchart_${_}"})[0], + project_id => $::form->{"project_id_${_}"} || undef, + } + } (1..($::form->{rowcount} || 1)); + + $template->assign_attributes( + template_type => 'ar_transaction', + template_name => $new_name, + + currency_id => SL::DB::Manager::Currency->find_by(name => $::form->{currency})->id, + ar_ap_chart_id => $::form->{AR_chart_id} || undef, + customer_id => $::form->{customer_id} || undef, + department_id => $::form->{department_id} || undef, + project_id => $::form->{globalproject_id} || undef, + employee_id => $::form->{employee_id} || undef, + taxincluded => $::form->{taxincluded} ? 1 : 0, + direct_debit => $::form->{direct_debit} ? 1 : 0, + ordnumber => $::form->{ordnumber}, + notes => $::form->{notes}, + + items => \@items, + ); + + eval { + $template->save; + 1; + } or do { + return $js + ->flash('error', $::locale->text("Saving the record template '#1' failed.", $new_name)) + ->render; + }; + + return $js + ->flash('info', $::locale->text("The record template '#1' has been saved.", $new_name)) + ->render; +} + sub add { $main::lxdebug->enter_sub(); @@ -334,7 +386,7 @@ sub form_header { my $follow_up_vc = $form->{customer_id} ? SL::DB::Customer->load_cached($form->{customer_id})->name : ''; my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; - $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js"); + $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js"); my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; my $first_taxchart; diff --git a/locale/de/all b/locale/de/all index adac93f1e..bca0f652e 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2497,6 +2497,7 @@ $self->{texts} = { 'Save settings as' => 'Einstellungen speichern unter', 'Saving failed. Error message from the database: #1' => 'Speichern schlug fehl. Fehlermeldung der Datenbank: #1', 'Saving the file \'%s\' failed. OS error message: %s' => 'Das Speichern der Datei \'%s\' schlug fehl. Fehlermeldung des Betriebssystems: %s', + 'Saving the record template \'#1\' failed.' => 'Das Speichern der Belegvorlage »#1« schlug fehl.', 'Score' => 'Punkte', 'Screen' => 'Bildschirm', 'Search' => 'Suchen', @@ -3058,6 +3059,8 @@ $self->{texts} = { 'The project type is in use and cannot be deleted.' => 'Der Projekttyp wird verwendet und kann nicht gelöscht werden.', 'The receivables chart isn\'t a valid chart.' => 'Das Forderungskonto ist kein gültiges Konto', 'The recipient, subject or body is missing.' => 'Der Empfäger, der Betreff oder der Text ist leer.', + 'The record template \'#1\' has been loaded.' => 'Die Belegvorlage »#1« wurde geladen.', + 'The record template \'#1\' has been saved.' => 'Die Belegvorlage »#1« wurde gespeichert.', 'The required information consists of the IBAN and the BIC.' => 'Die benötigten Informationen bestehen aus der IBAN und der BIC. Zusätzlich wird die SEPA-Kreditoren-Identifikation aus der Mandantenkonfiguration benötigt.', 'The required information consists of the IBAN, the BIC, the mandator ID and the mandate\'s date of signature.' => 'Die benötigten Informationen bestehen aus IBAN, BIC, Mandanten-ID und dem Unterschriftsdatum des Mandates. Zusätzlich wird die SEPA-Kreditoren-Identifikation aus der Mandantenkonfiguration benötigt.', 'The requirement spec has been deleted.' => 'Das Pflichtenheft wurde gelöscht.', diff --git a/templates/webpages/ar/form_footer.html b/templates/webpages/ar/form_footer.html index 484985cae..e7b9660dc 100644 --- a/templates/webpages/ar/form_footer.html +++ b/templates/webpages/ar/form_footer.html @@ -43,6 +43,8 @@ [% L.submit_tag("action", LxERP.t8('mark as paid'), confirm=LxERP.t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?')) %] [% END %] + [% L.button_tag("kivi.RecordTemplate.popup('ar_transaction')", LxERP.t8("Record templates")) %] +