X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/af131a4635b49e0615dec59c9b7423f0c828e027..2409735739fd290ad659b6d5aab83ff00dbcacef:/SL/Controller/BankTransaction.pm diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index 8b0c9216a..13b65b798 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -337,18 +337,15 @@ sub action_ajax_payment_suggestion { my @select_options = $invoice->get_payment_select_options_for_bank_transaction($::form->{bt_id}); my $html; - $html .= SL::Presenter->input_tag('invoice_ids.' . $::form->{bt_id} . '[]', $::form->{prop_id} , type => 'hidden'); - $html .= SL::Presenter->escape(t8('Invno.') . ': ' . $invoice->invnumber . ' '); - $html .= SL::Presenter->escape(t8('Open amount') . ': ' . $::form->format_amount(\%::myconfig, $invoice->open_amount, 2) . ' '); - $html .= SL::Presenter->select_tag('invoice_skontos.' . $::form->{bt_id} . '[]', - \@select_options, - value_key => 'payment_type', - title_key => 'display' ) - if @select_options; - $html .= SL::Presenter->html_tag('a', 'x', href => '#', onclick => "kivi.BankTransaction.delete_invoice(" . $::form->{bt_id} . ',' . $::form->{prop_id} . ")"); - $html = SL::Presenter->html_tag('div', $html, id => $::form->{bt_id} . '.' . $::form->{prop_id}, 'data-invoice-amount' => $invoice->open_amount * 1); - - $self->render(\ SL::JSON::to_json( { 'html' => $html } ), { layout => 0, type => 'json', process => 0 }); + $html = $self->render( + 'bank_transactions/_payment_suggestion', { output => 0 }, + bt_id => $::form->{bt_id}, + prop_id => $::form->{prop_id}, + invoice => $invoice, + SELECT_OPTIONS => \@select_options, + ); + + $self->render(\ SL::JSON::to_json( { 'html' => "$html" } ), { layout => 0, type => 'json', process => 0 }); }; sub action_filter_drafts { @@ -511,6 +508,8 @@ sub save_invoices { push @{ $self->problems }, $self->save_single_bank_transaction( bank_transaction_id => $bank_transaction_id, invoice_ids => $invoice_ids, + sources => ($::form->{sources} // {})->{$_}, + memos => ($::form->{memos} // {})->{$_}, ); $count += scalar( @{$invoice_ids} ); } @@ -519,6 +518,8 @@ sub save_invoices { push @{ $self->problems }, $self->save_single_bank_transaction( bank_transaction_id => $bank_transaction_id, invoice_ids => $invoice_ids, + sources => [ map { $::form->{"sources_${bank_transaction_id}_${_}"} } @{ $invoice_ids } ], + memos => [ map { $::form->{"memos_${bank_transaction_id}_${_}"} } @{ $invoice_ids } ], ); $count += scalar( @{$invoice_ids} ); } @@ -537,6 +538,7 @@ sub action_save_invoices { sub action_save_proposals { my ($self) = @_; + if ( $::form->{proposal_ids} ) { my $propcount = scalar(@{ $::form->{proposal_ids} }); if ( $propcount > 0 ) { @@ -620,6 +622,8 @@ sub save_single_bank_transaction { my $n_invoices = 0; foreach my $invoice (@{ $data{invoices} }) { + my $source = ($data{sources} // [])->[$n_invoices]; + my $memo = ($data{memos} // [])->[$n_invoices]; $n_invoices++ ; @@ -665,6 +669,8 @@ sub save_single_bank_transaction { trans_id => $invoice->id, amount => $open_amount, payment_type => $payment_type, + source => $source, + memo => $memo, transdate => $bank_transaction->transdate->to_kivitendo); } elsif ( $invoice->is_sales && $invoice->type eq 'credit_note' ) { # no check for overpayment/multiple payments @@ -672,6 +678,8 @@ sub save_single_bank_transaction { trans_id => $invoice->id, amount => $invoice->open_amount, payment_type => $payment_type, + source => $source, + memo => $memo, transdate => $bank_transaction->transdate->to_kivitendo); } else { # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary my $overpaid_amount = $amount_of_transaction - $invoice->open_amount; @@ -679,6 +687,8 @@ sub save_single_bank_transaction { trans_id => $invoice->id, amount => $amount_of_transaction, payment_type => $payment_type, + source => $source, + memo => $memo, transdate => $bank_transaction->transdate->to_kivitendo); $bank_transaction->invoice_amount($bank_transaction->amount); $amount_of_transaction = 0;