X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fap.pl;h=0417cd060fdb66abacee09e3fbab87588b08373b;hb=33ae80773d86157519a284de8c147ba0ec94e3f8;hp=e3a92675cbb944f5642fb08525a0c75cd3dc865f;hpb=9a14696176033f03c97244f420d93f9c15efed61;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index e3a92675c..0417cd060 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -428,8 +428,7 @@ sub form_header { "old_id" => \@old_project_ids }, "charts" => { "key" => "ALL_CHARTS", "transdate" => $form->{transdate} }, - "taxcharts" => { "key" => "ALL_TAXCHARTS", - "module" => "AP" },); + ); map( { $_->{link_split} = [ split(/:/, $_->{link}) ]; } @@ -461,9 +460,6 @@ sub form_header { my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; $::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.File.js", "kivi.AP.js", "kivi.CustomerVendor.js", "kivi.Validator.js"); - my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; - my $first_taxchart; - # $form->{totalpaid} is used by the action bar setup to determine # whether or not canceling is allowed. Therefore it must be # calculated prior to the action bar setup. @@ -472,6 +468,12 @@ sub form_header { setup_ap_display_form_action_bar(); $form->header(); + # get the correct date for tax + my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; + my $deliverydate = $::form->{deliverydate} ? DateTime->from_kivitendo($::form->{deliverydate}) : undef; + my $taxdate = $deliverydate ? $deliverydate : $transdate; + # helper for loop + my $first_taxchart; for my $i (1 .. $form->{rowcount}) { @@ -480,9 +482,13 @@ sub form_header { $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2); my ($default_taxchart, $taxchart_to_use); + my $used_tax_id; + if ( $form->{"taxchart_$i"} ) { + ($used_tax_id) = split(/--/, $form->{"taxchart_$i"}); + } 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); + my @taxcharts = GL->get_active_taxes_for_chart($amount_chart_id, $taxdate, $used_tax_id); foreach my $item (@taxcharts) { my $key = $item->id . "--" . $item->rate; $first_taxchart //= $item; @@ -637,7 +643,7 @@ sub update { map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); - my @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id taxchart); + my @flds = qw(amount AP_amount_chart_id projectnumber oldprojectnumber project_id taxchart tax); my $count = 0; my (@a, $j, $totaltax); for my $i (1 .. $form->{rowcount}) {