$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
my ($default_taxchart, $taxchart_to_use);
- my $amount_chart_id = $form->{"AP_amount_chart_id_$i"} || $default_ap_amount_chart_id;
- my $chart_has_changed = $::form->{"previous_AP_amount_chart_id_$i"} && ($amount_chart_id != $::form->{"previous_AP_amount_chart_id_$i"});
- my @taxcharts = GL->get_active_taxes_for_chart($amount_chart_id, $transdate);
+ my $amount_chart_id = $form->{"AP_amount_chart_id_$i"} || $default_ap_amount_chart_id;
+ my @taxcharts = GL->get_active_taxes_for_chart($amount_chart_id, $transdate);
foreach my $item (@taxcharts) {
my $key = $item->id . "--" . $item->rate;
$taxchart_to_use = $item if $key eq $form->{"taxchart_$i"};
}
- $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+ $taxchart_to_use //= $default_taxchart // $first_taxchart;
my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate;
$form->{"selected_taxchart_$i"} = $selected_taxchart;
$form->{"AP_amount_chart_id_$i"} = $amount_chart_id;
};
my (%taxchart_labels, @taxchart_values, $default_taxchart, $taxchart_to_use);
- my $amount_chart_id = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id;
- my $chart_has_changed = $::form->{"previous_AR_amount_chart_id_$i"} && ($amount_chart_id != $::form->{"previous_AR_amount_chart_id_$i"});
+ my $amount_chart_id = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id;
foreach my $item ( GL->get_active_taxes_for_chart($amount_chart_id, $transdate) ) {
my $key = $item->id . "--" . $item->rate;
$taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %';
}
- $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+ $taxchart_to_use //= $default_taxchart // $first_taxchart;
my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate;
$transaction->{selectAR_amount} =
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 $accno_id = $::form->{"accno_id_$i"};
+ my $chart = $charts_by_id{$accno_id} // $default_chart;
+ $accno_id = $chart->{id};
my ($first_taxchart, $default_taxchart, $taxchart_to_use);
foreach my $item ( GL->get_active_taxes_for_chart($accno_id, $transdate) ) {
$taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %';
}
- $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+ $taxchart_to_use //= $default_taxchart // $first_taxchart;
my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate;
my $accno = qq|<td>| .