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 $deliverydate = $::form->{deliverydate} ? DateTime->from_kivitendo($::form->{deliverydate}) : undef;
my ($source, $memo, $source_hidden, $memo_hidden);
for my $i (1 .. $form->{rowcount}) {
$accno_id = $chart->{id};
my ($first_taxchart, $default_taxchart, $taxchart_to_use);
- foreach my $item ( GL->get_active_taxes_for_chart($accno_id, $transdate) ) {
+
+ my $taxdate = $deliverydate ? $deliverydate : $transdate;
+ foreach my $item ( GL->get_active_taxes_for_chart($accno_id, $taxdate) ) {
my $key = $item->id . "--" . $item->rate;
$first_taxchart //= $item;
$default_taxchart = $item if $item->{is_default};
}
sub get_tax_dropdown {
- my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
- my @tax_accounts = GL->get_active_taxes_for_chart($::form->{accno_id}, $transdate);
+ my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
+ my $deliverydate = $::form->{deliverydate} ? DateTime->from_kivitendo($::form->{deliverydate}) : undef;
+ my @tax_accounts = GL->get_active_taxes_for_chart($::form->{accno_id}, $deliverydate // $transdate);
my $html = $::form->parse_html_template("gl/update_tax_accounts", { TAX_ACCOUNTS => \@tax_accounts });
print $::form->ajax_response_header, $html;
$.ajax({
url: 'gl.pl?action=get_tax_dropdown',
- data: { accno_id: $(obj).val(),
- transdate: $('#transdate').val() },
+ data: { accno_id: $(obj).val(),
+ transdate: $('#transdate').val(),
+ deliverydate: $('#deliverydate').val() },
dataType: 'html',
success: function (new_html) {
$("#taxchart_" + row).html(new_html);