+ my %project_labels = ();
+ my @project_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@project_values, $item->{"id"});
+ $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
+ my %charts_by_id = map { ($_->{id} => $_) } @{ $::form->{ALL_CHARTS} };
+ my $default_chart = $::form->{ALL_CHARTS}[0];
+ my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
+
+ my ($source, $memo, $source_hidden, $memo_hidden);
+ for my $i (1 .. $form->{rowcount}) {
+ if ($form->{show_details}) {
+ $source = qq|
+ <td><input name="source_$i" value="$form->{"source_$i"}" size="16"></td>|;
+ $memo = qq|
+ <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16"></td>|;
+ } else {
+ $source_hidden = qq|
+ <input type="hidden" name="source_$i" value="$form->{"source_$i"}" size="16">|;
+ $memo_hidden = qq|
+ <input type="hidden" name="memo_$i" value="$form->{"memo_$i"}" size="16">|;
+ }
+
+ my %taxchart_labels = ();
+ my @taxchart_values = ();
+
+ my $accno_id = $::form->{"accno_id_$i"};
+ my $chart = $charts_by_id{$accno_id} // $default_chart;
+ $accno_id = $chart->{id};
+ my $chart_has_changed = $::form->{"previous_accno_id_$i"} && ($accno_id != $::form->{"previous_accno_id_$i"});
+ my ($first_taxchart, $default_taxchart, $taxchart_to_use);
+
+ foreach my $item ( GL->get_active_taxes_for_chart($accno_id, $transdate) ) {
+ my $key = $item->id . "--" . $item->rate;
+ $first_taxchart //= $item;
+ $default_taxchart = $item if $item->{is_default};
+ $taxchart_to_use = $item if $key eq $form->{"taxchart_$i"};
+
+ push(@taxchart_values, $key);
+ $taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %';
+ }
+
+ $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+ my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate;
+
+ my $accno = qq|<td>| .
+ $::request->presenter->chart_picker("accno_id_$i", $accno_id, style => "width: 300px") .
+ $::request->presenter->hidden_tag("previous_accno_id_$i", $accno_id)
+ . qq|</td>|;
+ my $tax_ddbox = qq|<td>| .
+ NTI($cgi->popup_menu('-name' => "taxchart_$i",
+ '-id' => "taxchart_$i",
+ '-style' => 'width:200px',
+ '-values' => \@taxchart_values,
+ '-labels' => \%taxchart_labels,
+ '-default' => $selected_taxchart))
+ . qq|</td>|;
+
+ my ($fx_transaction, $checked);