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 {
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} );
}
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} );
}
sub action_save_proposals {
my ($self) = @_;
+
if ( $::form->{proposal_ids} ) {
my $propcount = scalar(@{ $::form->{proposal_ids} });
if ( $propcount > 0 ) {
my $n_invoices = 0;
foreach my $invoice (@{ $data{invoices} }) {
+ my $source = ($data{sources} // [])->[$n_invoices];
+ my $memo = ($data{memos} // [])->[$n_invoices];
$n_invoices++ ;
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
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;
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;