-
-
-
-$jsscript
-|;
+ $charts{$item->{accno}} = $item;
+ }
- $amount = $locale->text('Amount');
- $project = $locale->text('Project');
+ 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)";
- for $i (1 .. 1) {
+ $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js");
+ my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
+ my $first_taxchart;
- # $form->{"selectAP_amount"} =~ s/ selected//;
- # $form->{"selectAP_amount"} =~ s/option>\Q$form->{"AP_amount_$i"}\E/option selected>$form->{"AP_amount_$i"}/;
+ $form->header();
- # format amounts
- $form->{"amount_$i"} =
- $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
-
- print qq|
-
- | $amount |
- {"amount_$i"} $readonly> |
- $project |
-
- {"project_id_$i"}>
- |
- |
-
-|;
- $amount = "";
- $project = "";
- }
-
- $taxlabel =
- ($form->{taxincluded})
- ? $locale->text('Tax Included')
- : $locale->text('Tax');
+ for my $i (1 .. $form->{rowcount}) {
- # format and reverse tax
- $form->{"tax"} = $form->format_amount(\%myconfig, $form->{"tax"}, 2);
+ # format amounts
+ $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $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);
+
+ 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"};
+ }
- print qq|
-
- | ${taxlabel} |
- {"tax"} $readonly> |
- |
- | . $locale->text('Correct Tax') . qq| |
- |
-
-|;
+ $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+ 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;
+ }
+ $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 |
-
-
- |
-
-
- |
-
- |
-
-