X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/52b04172a511edae60ec9b5ada327f3cdcd150e2..a2179ea178c2e8cdcef9fd0cab517048778383de:/bin/mozilla/ap.pl diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 31ac25d09..2fe8041c9 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -413,20 +413,7 @@ sub form_header { $form->{creditremaining_plus} = ($form->{creditremaining} =~ /-/) ? "0" : "1"; - my @old_project_ids = (); - map( - { - if ($form->{"project_id_$_"}) { - push(@old_project_ids, $form->{"project_id_$_"}); - } - } - (1..$form->{"rowcount"}) - ); - - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, - "charts" => { "key" => "ALL_CHARTS", + $form->get_lists("charts" => { "key" => "ALL_CHARTS", "transdate" => $form->{transdate} }, ); @@ -437,10 +424,7 @@ sub form_header { $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; - my %project_labels = (); - foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { - $project_labels{$item->{id}} = $item->{projectnumber}; - } + my %project_labels = map { $_->id => $_->projectnumber } @{ SL::DB::Manager::Project->get_all }; my %charts; my $default_ap_amount_chart_id; @@ -459,7 +443,7 @@ sub form_header { my $follow_up_vc = $form->{vendor_id} ? SL::DB::Vendor->load_cached($form->{vendor_id})->name : ''; 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"); + $::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", "autocomplete_project.js"); # $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. @@ -468,8 +452,11 @@ sub form_header { setup_ap_display_form_action_bar(); $form->header(); - - my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; + # 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}) { @@ -485,7 +472,7 @@ sub form_header { } 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, $used_tax_id); + 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; @@ -640,7 +627,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}) { @@ -950,8 +937,6 @@ sub search { $form->{title} = $locale->text('Vendor Invoices & AP Transactions'); - $form->get_lists(projects => { "key" => "ALL_PROJECTS", "all" => 1 }); - $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; # constants and subs for template $form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };