From: Jan Büren Date: Wed, 11 Jul 2018 13:20:45 +0000 (+0200) Subject: Kontoauszug verbuchen -> Dialogbuchungsentwürfe verbessert X-Git-Tag: release-3.5.4~367 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ed9b1bfb7ca6acf18d907a7d34ddd3a82061b8cb;p=kivitendo-erp.git Kontoauszug verbuchen -> Dialogbuchungsentwürfe verbessert Nette Idee aus odyn (Start des Gedankens #f09c2b407faa7 Ende des Gedankens #765a3d421e7). Zwei Sollbruchstellen in odyn, deshalb in kivi neu formuliert: Sollbruchstellen: a) Ein Aufruf von BankTransaction::action_list kann Zustände im Datenmodell verändern b) Der Benutzer kann beliebige Zahlenwerte oder neue Konten in der Dialogbuchungsmaske eingeben Konsequenz: -> Zustände des Datenmodells in gl.pl post_transactions ändern, Werte per Rose hierzu aus der DB (und nicht aus $form) Möglichst viel dem Benutzer auf die Flossen hauen, wenn die Buchungsmaske unlogisch benutzt wird --- diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index efc0d1425..370ac954c 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -262,12 +262,6 @@ sub action_create_invoice { $self->transaction(SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id})); - # This was dead code: We compared vendor.account_name with bank_transaction.iban. - # This did never match (Kontonummer != IBAN). It's kivis 09/02 (2013) day - # If refactored/improved, also consider that vendor.iban should be normalized - # user may like to input strings like: 'AT 3333 3333 2222 1111' -> can be checked strictly - # at Vendor code because we need the correct data for all sepa exports. - 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; @@ -299,6 +293,7 @@ sub action_create_invoice { TEMPLATES_GL => $use_vendor_filter && @{ $templates_ap } ? undef : $templates_gl, TEMPLATES_AP => $templates_ap, vendor_name => $use_vendor_filter && @{ $templates_ap } ? $vendor_of_transaction->name : undef, + BT_ID => $::form->{bt_id}, ); } @@ -900,7 +895,7 @@ sub load_ap_record_template_url { } sub load_gl_record_template_url { - my ($self, $template) = @_; + my ($self, $template, $bt_id) = @_; return $self->url_for( controller => 'gl.pl', @@ -909,6 +904,7 @@ sub load_gl_record_template_url { 'form_defaults.amount_1' => abs($self->transaction->amount), # always positive 'form_defaults.transdate' => $self->transaction->transdate_as_date, 'form_defaults.callback' => $self->callback, + 'form_defaults.bt_id' => $self->transaction->id, ); } diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 8529e3d52..5e9d2208a 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -1329,7 +1329,35 @@ sub post_transaction { } # /saving the history - if ($form->{callback} =~ /BankTransaction/) { + # called from BankTransaction - Assign RecordLink and update BankTransaction + if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) { + # set invoice_amount - we only rely on bt_id in form, do all other stuff ui independent + # die if we have a unlogic or NYI case and (TODO) chain this transaction safe (post_transaction + history_erp + this) + my ($bt, $chart_id, $payment); + + $bt = SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id}); + die "No bank transaction found" unless $bt; + + $chart_id = SL::DB::Manager::BankAccount->find_by(id => $bt->local_bank_account_id)->chart_id; + die "no chart id:" unless $chart_id; + + $payment = SL::DB::Manager::AccTransaction->get_all(where => [ trans_id => $::form->{id}, + chart_link => { like => '%AR_paid%' }, + chart_id => $chart_id ]); + die "guru meditation error: Can only assign amount to one bank account booking" if scalar @{ $payment } > 1; + + # credit/debit * -1 matches the sign for bt.amount and bt.invoice_amount + $bt->update_attributes(invoice_amount => $bt->invoice_amount + ($payment->[0]->amount * -1)); + + # create record_link + my @props = ( + from_table => 'bank_transactions', + from_id => $::form->{bt_id}, + to_table => 'gl', + to_id => $::form->{id}, + ); + SL::DB::RecordLink->new(@props)->save; + print $form->redirect_header($form->{callback}); $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}); } diff --git a/templates/webpages/bank_transactions/_template_list.html b/templates/webpages/bank_transactions/_template_list.html index 245f0629d..5c88b4e2a 100644 --- a/templates/webpages/bank_transactions/_template_list.html +++ b/templates/webpages/bank_transactions/_template_list.html @@ -42,7 +42,7 @@ [% FOREACH template = TEMPLATES_GL %] - [% P.link_tag(SELF.load_gl_record_template_url(template), template.template_name) %] + [% P.link_tag(SELF.load_gl_record_template_url(template, BT_ID), template.template_name) %] [% HTML.escape(template.reference) %] [% HTML.escape(template.employee.name || template.employee.login) %] [% HTML.escape(template.itime_as_date) %] diff --git a/templates/webpages/gl/form_footer.html b/templates/webpages/gl/form_footer.html index e2780802d..8e7d74dc5 100644 --- a/templates/webpages/gl/form_footer.html +++ b/templates/webpages/gl/form_footer.html @@ -20,6 +20,7 @@
+ [%- IF id && follow_ups.size %]

[% LxERP.t8('There are #1 unfinished follow-ups of which #2 are due.', follow_ups.size , follow_ups_due) %]