-
-
-
-$jsscript
-|;
-
- $amount = $locale->text('Amount');
- $project = $locale->text('Project');
-
- for $i (1 .. 1) {
-
-# $form->{"selectAP_amount"} =~ s/ selected//;
-# $form->{"selectAP_amount"} =~ s/option>\Q$form->{"AP_amount_$i"}\E/option selected>$form->{"AP_amount_$i"}/;
+
+ 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");
+ 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.
+ $form->{totalpaid} = sum map { $form->{"paid_${_}"} } (1..$form->{paidaccounts});
+
+ setup_ap_display_form_action_bar();
+
+ $form->header();
+
+ for my $i (1 .. $form->{rowcount}) {
# format amounts
$form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
- print qq|
-
- $amount |
- {"amount_$i"} $readonly> |
- $project |
-
- {"project_id_$i"}>
- |
- |
-
-|;
- $amount = "";
- $project = "";
+ my ($default_taxchart, $taxchart_to_use);
+ 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;
+ $first_taxchart //= $item;
+ $default_taxchart = $item if $item->{is_default};
+ $taxchart_to_use = $item if $key eq $form->{"taxchart_$i"};
+ }
+
+ $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;
+ $form->{"taxcharts_$i"} = \@taxcharts;
}
- $taxlabel = ($form->{taxincluded}) ? $locale->text('Tax Included') : $locale->text('Tax');
- # format and reverse tax
- $form->{"tax"} = $form->format_amount(\%myconfig, $form->{"tax"}, 2);
-
- print qq|
-
- ${taxlabel} |
- {"tax"} $readonly> |
- |
- |.$locale->text('Correct Tax').qq| |
- |
-
-|;
-
-
-
-
-
-
+ $form->{taxchart_value_title_sub} = sub {
+ my $item = shift;
+ return [
+ $item->{id} .'--'. $item->{rate},
+ $item->{taxdescription} .' '. ($item->{rate} * 100) .' %',
+ ];
+ };
+
+ $form->{AP_paid_value_title_sub} = sub {
+ my $item = shift;
+ return [
+ $item->{accno},
+ $item->{accno} .'--'. $item->{description}
+ ];
+ };
+
+ $form->{invtotal_unformatted} = $form->{invtotal};
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
- print qq|
-
- |.$locale->text('Total').qq| |
- $form->{invtotal} |
-
- {oldinvtotal}>
- {oldtotalpaid}>
-
-
-
- |
- |
-
-
-
-
- |.$locale->text('Notes').qq| |
- $notes |
-
-
- |
-
-
-
-
- |
-
-