From 049677eb435b63595b0ffb748f26618fc7f6f479 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Sat, 12 Aug 2017 16:41:10 +0200 Subject: [PATCH] Kontoauszug verbuchen -> Buchung erstellen erweitert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit a) Filter erweitert, um nach Vorlagenname zu suchen b) Filter korrekt in
gepackt, um submit und reset form wie gewohnt zu unterstützen c) Buchungsmöglichkeit um gl_transactions (Dialogbuchungsvorlagen) erweitert, dass heißt in der Auswahlliste der Vorlagen werden jetzt Dialogbuchungsvorlagen angezeigt, falls ein Buchungskonto mit dem aktuellem Bankkonto übereinstimmt: (bank_accounts.chart_id == record_template_items.chart_id) d) Filter erweitert, um nach Referenz (nur in gl_transactions) zu suchen e) gl.pl erweitert, sodass die Metadaten der Vorlage geladen werden und mit den sinnvollen Vorgaben aus bank_transactions gefüllt werden --- SL/Controller/BankTransaction.pm | 50 +++++++++++++++---- bin/mozilla/gl.pl | 16 ++++-- locale/de/all | 9 ++-- .../bank_transactions/_template_list.html | 37 ++++++++++++-- .../bank_transactions/create_invoice.html | 29 ++++++++--- 5 files changed, 112 insertions(+), 29 deletions(-) diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index 9ea3f22ba..6684b8afd 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -263,13 +263,19 @@ sub action_create_invoice { my $vendor_of_transaction = SL::DB::Manager::Vendor->find_by(iban => $self->transaction->{remote_account_number}); my $use_vendor_filter = $self->transaction->{remote_account_number} && $vendor_of_transaction; - my $templates = SL::DB::Manager::RecordTemplate->get_all( + my $templates_ap = SL::DB::Manager::RecordTemplate->get_all( where => [ template_type => 'ap_transaction' ], with_objects => [ qw(employee vendor) ], ); + my $templates_gl = SL::DB::Manager::RecordTemplate->get_all( + query => [ template_type => 'gl_transaction', + chart_id => SL::DB::Manager::BankAccount->find_by(id => $self->transaction->local_bank_account_id)->chart_id, + ], + with_objects => [ qw(employee record_template_items) ], + ); - #Filter templates - $templates = [ grep { $_->vendor_id == $vendor_of_transaction->id } @{ $templates } ] if $use_vendor_filter; + # pre filter templates_ap, if we have a vendor match (IBAN eq IBAN) - show and allow user to edit this via gui! + $templates_ap = [ grep { $_->vendor_id == $vendor_of_transaction->id } @{ $templates_ap } ] if $use_vendor_filter; $self->callback($self->url_for( action => 'list', @@ -281,9 +287,10 @@ sub action_create_invoice { $self->render( 'bank_transactions/create_invoice', { layout => 0 }, - title => t8('Create invoice'), - TEMPLATES => $templates, - vendor_name => $use_vendor_filter ? $vendor_of_transaction->name : undef, + title => t8('Create invoice'), + TEMPLATES_GL => $use_vendor_filter ? undef : $templates_gl, + TEMPLATES_AP => $templates_ap, + vendor_name => $use_vendor_filter ? $vendor_of_transaction->name : undef, ); } @@ -319,12 +326,21 @@ sub action_filter_templates { $self->{transaction} = SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id}); my @filter; - push @filter, ('vendor.name' => { ilike => '%' . $::form->{vendor} . '%' }) if $::form->{vendor}; + push @filter, ('vendor.name' => { ilike => '%' . $::form->{vendor} . '%' }) if $::form->{vendor}; + push @filter, ('template_name' => { ilike => '%' . $::form->{template} . '%' }) if $::form->{template}; + push @filter, ('reference' => { ilike => '%' . $::form->{reference} . '%' }) if $::form->{reference}; - my $templates = SL::DB::Manager::RecordTemplate->get_all( - where => [ template_type => 'ap_transaction', (or => \@filter) x !!@filter ], + my $templates_ap = SL::DB::Manager::RecordTemplate->get_all( + where => [ template_type => 'ap_transaction', (and => \@filter) x !!@filter ], with_objects => [ qw(employee vendor) ], ); + my $templates_gl = SL::DB::Manager::RecordTemplate->get_all( + query => [ template_type => 'gl_transaction', + chart_id => SL::DB::Manager::BankAccount->find_by(id => $self->transaction->local_bank_account_id)->chart_id, + (and => \@filter) x !!@filter + ], + with_objects => [ qw(employee record_template_items) ], + ); $::form->{filter} //= {}; @@ -338,7 +354,8 @@ sub action_filter_templates { my $output = $self->render( 'bank_transactions/_template_list', { output => 0 }, - TEMPLATES => $templates, + TEMPLATES_AP => $templates_ap, + TEMPLATES_GL => $templates_gl, ); $self->render(\to_json({ html => $output }), { type => 'json', process => 0 }); @@ -864,6 +881,19 @@ sub load_ap_record_template_url { ); } +sub load_gl_record_template_url { + my ($self, $template) = @_; + + return $self->url_for( + controller => 'gl.pl', + action => 'load_record_template', + id => $template->id, + 'form_defaults.amount_1' => -1 * $self->transaction->amount, + 'form_defaults.transdate' => $self->transaction->transdate_as_date, + 'form_defaults.callback' => $self->callback, + ); +} + sub setup_search_action_bar { my ($self, %params) = @_; diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 676611682..ef7352d2f 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -49,7 +49,7 @@ use SL::DBUtils qw(selectrow_query selectall_hashref_query); use SL::Webdav; use SL::Locale::String qw(t8); use SL::Helper::GlAttachments qw(count_gl_attachments); - +use Carp; require "bin/mozilla/common.pl"; require "bin/mozilla/reportgenerator.pl"; @@ -94,7 +94,8 @@ sub load_record_template { die "invalid template type" unless $template->template_type eq 'gl_transaction'; $template->substitute_variables; - + my $payment_suggestion = $::form->{form_defaults}->{amount_1}; + # croak ("hier" . $payment_suggestion); # Clean the current $::form before rebuilding it from the template. my $form_defaults = delete $::form->{form_defaults}; delete @{ $::form }{ grep { !m{^(?:script|login)$}i } keys %{ $::form } }; @@ -133,8 +134,8 @@ sub load_record_template { $::form->{"accno_id_${row}"} = $item->chart_id; $::form->{"previous_accno_id_${row}"} = $item->chart_id; - $::form->{"debit_${row}"} = $::form->format_amount(\%::myconfig, $item->amount1, 2) if $item->amount1 * 1; - $::form->{"credit_${row}"} = $::form->format_amount(\%::myconfig, $item->amount2, 2) if $item->amount2 * 1; + $::form->{"debit_${row}"} = $::form->format_amount(\%::myconfig, ($payment_suggestion ? $payment_suggestion : $item->amount1), 2) if $item->amount1 * 1; + $::form->{"credit_${row}"} = $::form->format_amount(\%::myconfig, ($payment_suggestion ? $payment_suggestion : $item->amount2), 2) if $item->amount2 * 1; $::form->{"taxchart_${row}"} = $item->tax_id . '--' . $tax->rate; $::form->{"${_}_${row}"} = $item->$_ for qw(source memo project_id); } @@ -1317,7 +1318,6 @@ sub post_transaction { $form->error($err[$errno]); } - undef($form->{callback}); # saving the history if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|gltransaction_| . $form->{id}; @@ -1327,6 +1327,12 @@ sub post_transaction { } # /saving the history + if ($form->{callback} =~ /BankTransaction/) { + print $form->redirect_header($form->{callback}); + $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}); + } + # remove or clarify + undef($form->{callback}); $main::lxdebug->leave_sub(); } diff --git a/locale/de/all b/locale/de/all index 84bf4b642..449fc8576 100755 --- a/locale/de/all +++ b/locale/de/all @@ -73,6 +73,7 @@ $self->{texts} = { 'AP Transaction Storno (one letter abbreviation)' => 'S', 'AP Transaction with Storno (abbreviation)' => 'K(S)', 'AP Transactions' => 'Kreditorenbuchungen', + 'AP template suggestions' => 'Vorschlag Kreditorenbuchung', 'AP transaction posted.' => 'Kreditorenbuchung verbucht.', 'AP transactions changeable' => 'Änderbarkeit von Kreditorenbuchungen', 'AP transactions with sales taxkeys and/or AR transactions with input taxkeys' => 'Kreditorenbuchungen mit Umsatzsteuer-Steuerschlüsseln und/oder Debitorenbuchungen mit Vorsteuer-Steuerschlüsseln', @@ -1343,7 +1344,6 @@ $self->{texts} = { 'Filter for customer variables' => 'Filter für benutzerdefinierte Kundenvariablen', 'Filter for item variables' => 'Filter für benutzerdefinierte Artikelvariablen', 'Filter parts' => 'Artikel filtern', - 'Filter vendors' => 'Lieferanten filtern', 'Financial Controlling' => 'Finanzcontrolling', 'Financial Controlling Report' => 'Finanzcontrollingbericht', 'Financial Overview' => 'Finanzübersicht', @@ -1404,6 +1404,7 @@ $self->{texts} = { 'GL Transaction (abbreviation)' => 'DB', 'GL Transactions' => 'Dialogbuchungen', 'GL search' => 'FiBu Suche', + 'GL template suggestions' => 'Vorschlag Dialogbuchung', 'GL transactions changeable' => 'Änderbarkeit von Dialogbuchungen', 'GLN' => 'GLN', 'Gegenkonto' => 'Gegenkonto', @@ -1856,9 +1857,11 @@ $self->{texts} = { 'No' => 'Nein', 'No %s was found matching the search parameters.' => 'Es wurde kein %s gefunden, auf den die Suchparameter zutreffen.', 'No 1:n or n:1 relation' => 'Keine 1:n oder n:1 Beziehung', + 'No AP template was found.' => 'Keine Kreditorenbuchungsvorlage gefunden.', 'No Company Address given' => 'Keine Firmenadresse hinterlegt!', 'No Company Name given' => 'Kein Firmenname hinterlegt!', 'No Customer was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Endkunde gefunden', + 'No GL template was found.' => 'Keine Dialogbuchungsvorlage gefunden.', 'No Journal' => 'Kein Journal', 'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Händler gefunden', 'No action defined.' => 'Keine Aktion definiert.', @@ -1914,7 +1917,6 @@ $self->{texts} = { 'No such job #1 in the database.' => 'Hintergrund-Job #1 existiert nicht mehr.', 'No summary account' => 'Kein Sammelkonto', 'No template has been selected yet.' => 'Es wurde noch keine Vorlage ausgewählt.', - 'No template was found.' => 'Es wurde keine Vorlage gefunden.', 'No text blocks have been created for this position.' => 'Für diese Position wurden noch keine Textblöcke angelegt.', 'No text has been entered yet.' => 'Es wurde noch kein Text eingegeben.', 'No title yet' => 'Bisher ohne Titel', @@ -2388,6 +2390,7 @@ $self->{texts} = { 'Reference' => 'Referenz', 'Reference / Invoice Number' => 'Referenz / Rechnungsnummer', 'Reference day' => 'Referenztag', + 'Reference filter for transaction templates' => 'Dialogbuchungs-Referenz', 'Reference missing!' => 'Referenz fehlt!', 'Release From Stock' => 'Lagerausgang', 'Remaining' => 'Rest', @@ -2881,9 +2884,9 @@ $self->{texts} = { 'Telephone' => 'Telefon', 'Template' => 'Druckvorlage', 'Template Code' => 'Vorlagenkürzel', + 'Template Description' => 'Name der Vorlage', 'Template database' => 'Datenbankvorlage', 'Template date' => 'Vorlagendatum', - 'Template suggestions' => 'Vorschläge für Vorlagen', 'Templates' => 'Vorlagen', 'Terms missing in row ' => '+Tage fehlen in Zeile ', 'Test database connectivity' => 'Datenbankverbindung testen', diff --git a/templates/webpages/bank_transactions/_template_list.html b/templates/webpages/bank_transactions/_template_list.html index 9bd54e333..4e354515f 100644 --- a/templates/webpages/bank_transactions/_template_list.html +++ b/templates/webpages/bank_transactions/_template_list.html @@ -1,5 +1,7 @@ -[%- USE HTML -%][%- USE LxERP -%][%- USE P -%][% IF TEMPLATES.size %] - [% LxERP.t8('Template suggestions') %]: +[%- USE HTML -%][%- USE LxERP -%][%- USE P -%] + +[% IF TEMPLATES_AP.size %] + [% LxERP.t8('AP template suggestions') %]: @@ -11,7 +13,7 @@ - [% FOREACH template = TEMPLATES %] + [% FOREACH template = TEMPLATES_AP %] @@ -22,5 +24,32 @@
[% P.link(SELF.load_ap_record_template_url(template), template.template_name) %] [% HTML.escape(template.vendor.name) %]
[% ELSE %] -

[% LxERP.t8('No template was found.') %]

+

[% LxERP.t8('No AP template was found.') %]

+[% END %] + +[% IF TEMPLATES_GL.size %] + [% LxERP.t8('GL template suggestions') %]: + + + + + + + + + + + + [% FOREACH template = TEMPLATES_GL %] + + + + + + + [% END %] + +
[% LxERP.t8('Description') %][% LxERP.t8('Reference') %][% LxERP.t8('Employee') %][% LxERP.t8('Template date') %]
[% P.link(SELF.load_gl_record_template_url(template), template.template_name) %][% HTML.escape(template.reference) %][% HTML.escape(template.employee.name || template.employee.login) %][% HTML.escape(template.itime_as_date) %]
+[% ELSE %] +

[% LxERP.t8('No GL template was found.') %]

[% END %] diff --git a/templates/webpages/bank_transactions/create_invoice.html b/templates/webpages/bank_transactions/create_invoice.html index 25b32b395..45b1818ec 100644 --- a/templates/webpages/bank_transactions/create_invoice.html +++ b/templates/webpages/bank_transactions/create_invoice.html @@ -25,27 +25,42 @@
-[% LxERP.t8('Vendor filter for AP transaction templates') %]: - + [% L.hidden_tag("bt_id", SELF.transaction.id) %] [% L.hidden_tag("filter.bank_account", FORM.filter.bank_account) %] [% L.hidden_tag("filter.fromdate", FORM.filter.fromdate) %] [% L.hidden_tag("filter.todate", FORM.filter.todate) %] + + + + - + + + + +
[%- LxERP.t8("Template Description") %][% P.input_tag("template", template_name, style="width: 250px") %]
[%- LxERP.t8("Vendor") %][% P.input_tag("vendor", vendor_name, class="initial_focus", style="width: 250px") %][% P.input_tag("vendor", vendor_name, style="width: 250px") %]
[%- LxERP.t8("Reference") %][% P.input_tag("reference", reference_name, style="width: 250px") %]
-
-

- [% P.button_tag("kivi.BankTransaction.filter_templates()", LxERP.t8("Filter vendors")) %] + [% P.submit_tag('', LxERP.t8("Filter")) %] + [% P.button_tag('$("#create_invoice_window_form").resetForm()', LxERP.t8('Reset')) %] [% LxERP.t8("Cancel") %]

- +
[% PROCESS "bank_transactions/_template_list.html" %]
+ + -- 2.20.1